Browse Source

Add next button, tweak puzzles.txt loading

master
Macoy Madson 3 years ago
parent
commit
761e8d15e7
  1. BIN
      assets/Next_Button.xcf
  2. BIN
      data/Next_Button.bmp
  3. 26
      src/Main.cake

BIN
assets/Next_Button.xcf

Binary file not shown.

BIN
data/Next_Button.bmp

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

26
src/Main.cake

@ -293,6 +293,7 @@
(return true))
;; Loaded by PuzzleIO.cake
(defstruct puzzle-data
num-moves char
num-states int
@ -301,6 +302,8 @@
(var-global g-puzzle-list (* puzzle-data) null)
(var-global g-num-puzzles int 0)
(var g-current-puzzle (* puzzle-data) null)
(defun-local game-piece-grid-position-to-screen-position (piece (* (const board-piece)) &return vec2)
(var piece-position vec2 (array (type-cast (vec-x (path piece > grid-position)) float)
(type-cast (vec-y (path piece > grid-position)) float)))
@ -439,9 +442,6 @@
(return (path piece > is-primary-piece)))
(return false))
(var g-current-puzzle (* puzzle-data) null)
(defun game-board-load-next-puzzle ()
(when g-num-puzzles
(set g-current-puzzle (addr (at (mod (rand) g-num-puzzles) g-puzzle-list)))
@ -739,6 +739,10 @@ Rush Hour database from Michael Fogleman.\n\n")
(sdl-texture-from-bmp
(in-data-dir "Undo_Button.bmp") renderer))
(unless undo-button-texture (return 1))
(var next-button-texture (* SDL_Texture)
(sdl-texture-from-bmp
(in-data-dir "Next_Button.bmp") renderer))
(unless next-button-texture (return 1))
(var font-texture (* SDL_Texture)
(sdl-texture-from-bmp
@ -752,6 +756,7 @@ Rush Hour database from Michael Fogleman.\n\n")
win-texture
theme-button-texture
undo-button-texture
next-button-texture
font-texture))
(sdl-print-time-delta start-load-ticks "Textures loaded")
@ -887,9 +892,12 @@ Rush Hour database from Michael Fogleman.\n\n")
(set exit-reason "Render error"))
(scope ;; UI
(when (do-button (addr in-state) (array 0.f 0.f) (array 166.f 166.f) renderer theme-button-texture)
(when (do-button (addr in-state) (array 10.f 10.f) (array 166.f 166.f) renderer theme-button-texture)
(set is-day-mode (not is-day-mode)))
(when (do-button (addr in-state) (array 300.f 0.f) (array 166.f 166.f) renderer undo-button-texture)
(when (do-button (addr in-state) (array 190.f 1900.f) (array 166.f 166.f) renderer undo-button-texture)
(set current-move-count 0)
(game-board-load-next-puzzle))
(when (do-button (addr in-state) (array 724.f 1900.f) (array 166.f 166.f) renderer next-button-texture)
(set current-move-count 0)
(game-board-load-next-puzzle)))
@ -1158,9 +1166,17 @@ Rush Hour database from Michael Fogleman.\n\n")
;; do that, but a much bigger project would be well served by such a feature.
(defun-comptime copy-src-files-to-android (manager (& ModuleManager) module (* Module) &return bool)
(Log "copy-src-files-to-android: Copying files to SDL Android project\n")
;; Bug in cakelisp where hooks aren't ordered predictably
(unless (fileExists "../../data/puzzles.bin")
(Log "copy-src-files-to-android: Didn't find data/puzzles.bin. Has generate-puzzles-list not
been executed yet?\n")
(return false))
(run-process-sequential-or
;; Note that we're still relative to Dependencies/gamelib
("rsync" "--verbose" "--recursive" "--update"
"--exclude=puzzles.txt"
"../../data"
"../../Android/app/src/main/assets/")
(Log "copy-src-files-to-android: failed to sync data/ to Android assets folder\n

Loading…
Cancel
Save