GameWrapper struct implements Ebiten’s Game interface to handle updates, rendering, and layout.
GameWrapper
TheGameWrapper is the main entry point for the Ebiten game loop. It wraps the game state and manages packet processing, scene updates, and rendering.
main.go:46-50
Fields
gsm: Scene manager that handles switching between different game scenes (login screen, playground, etc.)packets: Channel for receiving network packets from the servergame: Main game state containing player data, world state, connections, etc.
Update Method
TheUpdate method is called every tick (60 TPS by default) and handles:
- Processing incoming network packets
- Maintaining the window aspect ratio
- Updating the current scene
main.go:52-64
Draw Method
TheDraw method is called every frame and delegates rendering to the current scene.
main.go:66-68
Layout Method
TheLayout method defines the logical screen dimensions used for rendering, regardless of actual window size.
main.go:70-72
Packet Processing
Packets from the server are processed each frame by draining the packet channel and invoking the appropriate handlers.main.go:117-126
Initialization
The game loop is initialized inmain() and started with ebiten.RunGame():
main.go:86-110
Configuration
- Window size: 1152x960 pixels (resizable)
- TPS (Ticks Per Second): 60
- Aspect ratio: Locked to 1152:960 (1.2)
- Initial scene: Login screen
- Packet buffer: 100 packets