add menu bg and buttons
This commit is contained in:
70
game.sex
70
game.sex
@@ -99,44 +99,44 @@
|
||||
(draw-tmx-layer (. state map) "FIH" (& (. state cam)))
|
||||
(EndMode2D)
|
||||
|
||||
(DrawText "WASD/arrows: move wheel: zoom click: back to menu"
|
||||
(DrawText "WASD/arrows: move wheel: zoom ESC: back to menu"
|
||||
10 10 20 RAYWHITE)
|
||||
(DrawText (TextFormat "FIH objects: %d"
|
||||
(tmx-object-count (. state map) "FIH"))
|
||||
10 30 20 RAYWHITE)
|
||||
|
||||
(EndDrawing))
|
||||
|
||||
(pub fn process-input-game ((state (* game-state))) void
|
||||
(if (!= (. state map) NULL)
|
||||
(if (== (. state map) NULL)
|
||||
(return))
|
||||
|
||||
(var speed float (* 300.0 (GetFrameTime)))
|
||||
|
||||
(if (|| (IsKeyPressed KEY-LEFT) (IsKeyPressed KEY-A))
|
||||
(-= (. state fih x) TILE-SIZE))
|
||||
(if (|| (IsKeyPressed KEY-RIGHT) (IsKeyPressed KEY-D))
|
||||
(+= (. state fih x) TILE-SIZE))
|
||||
(if (|| (IsKeyPressed KEY-UP) (IsKeyPressed KEY-W))
|
||||
(-= (. state fih y) TILE-SIZE))
|
||||
(if (|| (IsKeyPressed KEY-DOWN) (IsKeyPressed KEY-S))
|
||||
(+= (. state fih y) TILE-SIZE))
|
||||
|
||||
(var map-width float (cast (tmx-pixel-width (. state map)) float))
|
||||
(var map-height float (cast (tmx-pixel-height (. state map)) float))
|
||||
(if (< (. state cam target x) 0.0)
|
||||
(= (. state cam target x) 0.0))
|
||||
(if (> (. state cam target x) map-width)
|
||||
(= (. state cam target x) map-width))
|
||||
(if (< (. state cam target y) 0.0)
|
||||
(= (. state cam target y) 0.0))
|
||||
(if (> (. state cam target y) map-height)
|
||||
(= (. state cam target y) map-height))
|
||||
|
||||
(var wheel float (GetMouseWheelMove))
|
||||
(if (!= wheel 0.0)
|
||||
(do
|
||||
(var speed float (* 300.0 (GetFrameTime)))
|
||||
(+= (. state cam zoom) (* wheel 0.5))
|
||||
(if (< (. state cam zoom) 0.5)
|
||||
(= (. state cam zoom) 0.5))
|
||||
(if (> (. state cam zoom) 8.0)
|
||||
(= (. state cam zoom) 8.0))))
|
||||
|
||||
(if (|| (IsKeyPressed KEY-LEFT) (IsKeyPressed KEY-A))
|
||||
(-= (. state fih x) TILE-SIZE))
|
||||
(if (|| (IsKeyPressed KEY-RIGHT) (IsKeyPressed KEY-D))
|
||||
(+= (. state fih x) TILE-SIZE))
|
||||
(if (|| (IsKeyPressed KEY-UP) (IsKeyPressed KEY-W))
|
||||
(-= (. state fih y) TILE-SIZE))
|
||||
(if (|| (IsKeyPressed KEY-DOWN) (IsKeyPressed KEY-S))
|
||||
(+= (. state fih y) TILE-SIZE))
|
||||
|
||||
(var map-width float (cast (tmx-pixel-width (. state map)) float))
|
||||
(var map-height float (cast (tmx-pixel-height (. state map)) float))
|
||||
(if (< (. state cam target x) 0.0)
|
||||
(= (. state cam target x) 0.0))
|
||||
(if (> (. state cam target x) map-width)
|
||||
(= (. state cam target x) map-width))
|
||||
(if (< (. state cam target y) 0.0)
|
||||
(= (. state cam target y) 0.0))
|
||||
(if (> (. state cam target y) map-height)
|
||||
(= (. state cam target y) map-height))
|
||||
|
||||
(var wheel float (GetMouseWheelMove))
|
||||
(if (!= wheel 0.0)
|
||||
(do
|
||||
(+= (. state cam zoom) (* wheel 0.5))
|
||||
(if (< (. state cam zoom) 0.5)
|
||||
(= (. state cam zoom) 0.5))
|
||||
(if (> (. state cam zoom) 8.0)
|
||||
(= (. state cam zoom) 8.0)))))))
|
||||
(if (IsKeyReleased KEY-ESCAPE)
|
||||
(.change-page (. state app-state) (sum-type page menu))))
|
||||
|
||||
Reference in New Issue
Block a user