package components import ( coreobjects "github.com/DegustatorPonos/RuinesOfRafdolon/CoreObjects" rl "github.com/gen2brain/raylib-go/raylib" ) // The scene implimetation that represents one playable scene type World struct { Manager coreobjects.SceneManager Name string Floor []FloorTile StaticObjects []coreobjects.GameObject Player *Player Camera *rl.Camera2D // ========== Cache ========== // the collection of the colliders that belong to static objects - world, buildings, etc staticColliders []*coreobjects.Collider } func (base *World) Create(manager coreobjects.SceneManager) { base.Manager = manager base.Player.Init(manager) } func (base *World) Destroy() { base.Player.Destroy() } func (base *World) Update() { base.Player.Update() base.Player.SnapCamera(base.Camera) base.handleZoom() } func (base *World) handleZoom() { var zoomSpeed = 50 * rl.GetFrameTime() base.Camera.Zoom += zoomSpeed * rl.GetMouseWheelMove() } func (base *World) collectStaticColliders() { base.staticColliders = make([]*coreobjects.Collider, 0) } func (base *World) GetStaticColliders() []*coreobjects.Collider { if base.staticColliders == nil { base.collectStaticColliders() } return base.staticColliders } func (base *World) Draw() { rl.BeginMode2D(*base.Camera) defer rl.EndMode2D() for _, v := range base.Floor { v.Draw() } for _, v := range base.StaticObjects { v.Draw() } base.Player.Draw() } // The single texture drawn at level 0 of the world type FloorTile struct { Position rl.Vector2 Texture *rl.Texture2D } func (base *FloorTile) Draw() { rl.DrawTexture( *base.Texture, int32(base.Position.X), int32(base.Position.Y), rl.White, ) }