Loading...
Loading...
Compare original and translation side by side
Update()Draw()slice = slice[:0]sync.PoolDrawImageNewImageGame.Draw()Channelsync.RWMutexebiten.Image.Dispose()slice = slice[:0]sync.PoolUpdate()Draw()DrawImageNewImageGame.Draw()Channelsync.RWMutexebiten.Image.Dispose()Updatefmt.Sprintfmake([]int)&Vector{}go func()invalid memory addressmapUpdatefmt.Sprintfmake([]int)&Vector{}Updatego func()invalid memory addressmapUpdate切勿将所有代码塞进。请遵循 Go 标准项目布局。main.go
cmd/game/main.gointernal/game/internal/assets/embed.FSinternal/ecs/go mod init <module>internal/game/game.goGamecmd/game/main.goebiten.RunGame(&game.Game{})Never stuff all code into. Follow the Go standard project layout.main.go
cmd/game/main.gointernal/game/internal/assets/embed.FSinternal/ecs/go mod init <module>internal/game/game.goGameebiten.RunGame(&game.Game{})cmd/game/main.go游戏不是一个大循环,而是一系列场景的切换(Logo -> Menu -> Play -> Over)。
SceneUpdate() errorDraw(screen *ebiten.Image)GamecurrentScene SceneSceneManagerSwitchTo(Scene)Game.Update()return g.currentScene.Update()TitleSceneA game is not a single big loop, but a series of scene switches (Logo -> Menu -> Play -> Over).
SceneUpdate() errorDraw(screen *ebiten.Image)currentScene SceneGameSceneManagerSwitchTo(Scene)Game.Update()return g.currentScene.Update()TitleScene随着实体数量增加,OOP 继承树会成为性能瓶颈。
GameObject*Sprite*PositiondonburiarcheComponentSystemMovementSystemVelocityAs the number of entities increases, OOP inheritance trees become performance bottlenecks.
GameObject*Sprite*PositiondonburiarcheComponentSystemMovementSystemVelocity不要直接在逻辑代码里写。ebiten.IsKeyPressed(ebiten.KeySpace)
InputSystemActionJumpActionShootinput.IsActionJustPressed(ActionJump)AssetLoadersync.MapmapDon't directly writein logic code.ebiten.IsKeyPressed(ebiten.KeySpace)
InputSystemActionJumpActionShootinput.IsActionJustPressed(ActionJump)AssetLoadersync.Mapmap本地能跑不代表能发给玩家。
.air.tomlMakefilescripts/build.pyGOOS=windows GOARCH=amd64 go build -ldflags="-H windowsgui -s -w"GOOS=js GOARCH=wasm go build -o game.wasmWorking locally doesn't mean it can be distributed to players.
.air.tomlMakefilescripts/build.pyGOOS=windows GOARCH=amd64 go build -ldflags="-H windowsgui -s -w"GOOS=js GOARCH=wasm go build -o game.wasmreferences/ebitengine_patterns.mdreferences/vfx_guide.mdreferences/publishing.mdreferences/genre_cardgame.mdreferences/genre_simulation.mdscripts/build_all.pyreferences/ebitengine_patterns.mdreferences/vfx_guide.mdreferences/publishing.mdreferences/genre_cardgame.mdreferences/genre_simulation.mdscripts/build_all.py