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 Camera *rl.Camera2D } func (base *World) Create(manager coreobjects.SceneManager) { base.Manager = manager } func (base *World) Destroy() { } func (base *World) Update() { base.handleFreecam() } func (base *World) handleFreecam() { var speed = 150 * rl.GetFrameTime() var zoomSpeed = 0.2 * rl.GetFrameTime() if rl.IsKeyDown(rl.KeyW) { base.Camera.Target.Y -= speed } if rl.IsKeyDown(rl.KeyS) { base.Camera.Target.Y += speed } if rl.IsKeyDown(rl.KeyA) { base.Camera.Target.X -= speed } if rl.IsKeyDown(rl.KeyD) { base.Camera.Target.X += speed } if rl.IsKeyDown(rl.KeyEqual) { base.Camera.Zoom += zoomSpeed } if rl.IsKeyDown(rl.KeyMinus) { base.Camera.Zoom -= zoomSpeed } } func (base *World) Draw() { rl.BeginMode2D(*base.Camera) defer rl.EndMode2D() for _, v := range base.Floor { v.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, ) }