Browse Source

Add loading screen, reencode textures, free memory

master
Macoy Madson 3 years ago
parent
commit
054764b4d7
  1. BIN
      assets/Loading.xcf
  2. BIN
      data/Board.bmp
  3. BIN
      data/Loading.bmp
  4. BIN
      data/Win.bmp
  5. 31
      src/Main.cake

BIN
assets/Loading.xcf

Binary file not shown.

BIN
data/Board.bmp

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 MiB

After

Width:  |  Height:  |  Size: 4.8 MiB

BIN
data/Loading.bmp

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
data/Win.bmp

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 938 KiB

31
src/Main.cake

@ -555,12 +555,28 @@ Rush Hour database from Michael Fogleman.\n\n")
;; Scale the render to fit the window
(SDL_RenderSetLogicalSize renderer g-window-width g-window-height)
(scope ;; Show loading screen
(var loading-texture (* SDL_Texture) (sdl-texture-from-bmp (in-data-dir "Loading.bmp")
renderer))
(unless loading-texture (return 1))
(SDL_RenderClear renderer)
(var loading-width int (* 2 200)) ;; Scale it up a bit
(var loading-height int (* 2 80))
(var loading-rect SDL_Rect (array (/ (- g-window-width loading-width) 2)
(/ (- g-window-height loading-height) 2)
loading-width loading-height))
(unless (= 0 (SDL_RenderCopy renderer loading-texture null (addr loading-rect)))
(sdl-print-error)
(return 1))
(SDL_RenderPresent renderer)
(SDL_DestroyTexture loading-texture))
(var background-texture (* SDL_Texture) (sdl-texture-from-bmp (in-data-dir "Board.bmp")
renderer))
(unless background-texture (return 1))
(var grid-texture (* SDL_Texture) (sdl-texture-from-bmp (in-data-dir "Grid.bmp")
renderer))
(unless grid-texture (return 1))
;; (var grid-texture (* SDL_Texture) (sdl-texture-from-bmp (in-data-dir "Grid.bmp")
;; renderer))
;; (unless grid-texture (return 1))
(var pieces-texture (* SDL_Texture)
(sdl-texture-from-bmp-color-to-transparent
@ -795,6 +811,15 @@ Rush Hour database from Michael Fogleman.\n\n")
(SDL_DestroyTexture background-texture)
(set background-texture null)
;; (SDL_DestroyTexture grid-texture)
;; (set grid-texture null)
(SDL_DestroyTexture pieces-texture)
(set pieces-texture null)
(SDL_DestroyTexture win-texture)
(set win-texture null)
(SDL_DestroyRenderer renderer)
(sdl-shutdown window)
(return 0))

Loading…
Cancel
Save