mv ebiten.RunGame to prevent ebitenbind goseq issue

This commit is contained in:
rootVIII 2021-05-29 22:07:49 -04:00
parent d5b82c47f4
commit f52fa5f7a1
4 changed files with 26 additions and 22 deletions

View file

@ -4,7 +4,7 @@
<img src="https://images2.imgbox.com/a6/ab/4hlQKK3q_o.png" alt="ex2"/> <img src="https://images2.imgbox.com/a6/ab/4hlQKK3q_o.png" alt="ex2"/>
###### Run in a local testing environment: ###### gomobile, build .apk for development and testing:
<pre> <pre>
<code> <code>
@ -23,7 +23,15 @@ alias pixel4='$ANDROID_HOME/emulator/emulator -avd "Pixel_4_API_30"'
</pre> </pre>
<img src="https://images2.imgbox.com/1d/4c/i9yuv83m_o.png" alt="ex1"/></a> ###### ebitenmobile, build .aar for Android Studio binding:
<pre>
<code>
// Navigate to skulls/ and generate the <code>.aar</code> binding:
ebitenmobile bind -target android -javapkg com.&lt;your username&gt;.skulls -o skulls.aar github.com/rootVIII/skulls/skullsebitenbind
</code>
</pre>
<ul> <ul>
<li> <li>

View file

@ -619,7 +619,7 @@ func readAudio(context *audio.Context, asset []byte) (*audio.Player, error) {
} }
// Play is the entry point to the game. // Play is the entry point to the game.
func Play() (*Game, error) { func Load() (*Game, error) {
audioContext := audio.NewContext(44100) audioContext := audio.NewContext(44100)
@ -694,22 +694,10 @@ func Play() (*Game, error) {
game.clear.SetVolume(.50) game.clear.SetVolume(.50)
game.beep.SetVolume(.50) game.beep.SetVolume(.50)
// for _, item := range game.skullCollector {
// fmt.Printf("%v\n", item)
// }
// for _, item := range game.skullCoords {
// fmt.Printf("%v\n", item)
// }
game.spawn() game.spawn()
ebiten.SetWindowSize(screenW, screenH) ebiten.SetWindowSize(screenW, screenH)
ebiten.SetWindowTitle("💀") ebiten.SetWindowTitle("💀")
if err := ebiten.RunGame(game); err != nil {
return nil, err
}
return game, nil return game, nil
} }

View file

@ -7,11 +7,11 @@ import (
func init() { func init() {
sp, err := skulls.Play() game, err := skulls.Load()
if err != nil { if err != nil {
panic(err) panic(err)
} }
mobile.SetGame(sp) mobile.SetGame(game)
} }
// Dummy forces gomobile to compile this package. // Dummy forces gomobile to compile this package.

View file

@ -6,15 +6,23 @@ import (
"log" "log"
"os" "os"
"github.com/hajimehoshi/ebiten/v2"
"github.com/rootVIII/skulls" "github.com/rootVIII/skulls"
) )
func exitErr(err error) {
logf, _ := os.OpenFile("SKULLS-ERROR.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
log.SetOutput(logf)
log.Println("** An error occurred during startup **")
log.Fatal(err)
}
func main() { func main() {
_, err := skulls.Play() game, err := skulls.Load()
if err != nil { if err != nil {
logf, _ := os.OpenFile("SKULLS-ERROR.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) exitErr(err)
log.SetOutput(logf) }
log.Println("** An error occurred during startup **") if err := ebiten.RunGame(game); err != nil {
log.Fatal(err) exitErr(err)
} }
} }