gl01/internal/game/game.go

56 lines
1.1 KiB
Go
Raw Normal View History

2022-01-20 21:58:50 +08:00
package game
import (
2022-02-24 20:20:33 +08:00
"time"
"edgaru089.ink/go/gl01/internal/entity"
"edgaru089.ink/go/gl01/internal/render"
"edgaru089.ink/go/gl01/internal/util/itype"
"edgaru089.ink/go/gl01/internal/world"
2022-01-20 21:58:50 +08:00
"github.com/inkyblackness/imgui-go/v4"
_ "edgaru089.ink/go/gl01/internal/entity/entities"
2022-01-20 21:58:50 +08:00
)
// Game holds a game scene.
type Game struct {
world *world.World
player *entity.Entity
2022-02-24 13:18:05 +08:00
view *render.View
render renderData
2022-01-20 21:58:50 +08:00
prevCursorPos itype.Vec2d
cameraPos itype.Vec3d
rotY itype.Angle
rotZ float32 // Degrees in range (-90, 90)
2022-01-26 23:31:40 +08:00
fbSize itype.Vec2i
fullscreen bool
lastPos, lastSize itype.Vec2i // Window size before entering fullscreen
2022-01-20 21:58:50 +08:00
2022-02-24 20:20:33 +08:00
runtime time.Duration
2022-01-20 21:58:50 +08:00
io imgui.IO
2022-01-24 22:40:53 +08:00
gui guiState
2022-01-20 21:58:50 +08:00
paused bool
}
// NewGame creates a new, empty Game.
func NewGame() (g *Game) {
return &Game{
2022-02-24 13:18:05 +08:00
world: world.NewWorld(),
player: entity.NewEntity("player", itype.Vec3d{18, 80, 18}),
cameraPos: itype.Vec3d{18, 80, 18},
rotY: 0,
rotZ: 0,
2022-01-20 21:58:50 +08:00
}
}
// LoadGameFromPath loads a saved game from a filesystem folder in a read-write fashion.
func LoadGameFromPath(path string) (g *Game, err error) {
return
}