Reduce size of exported maps.
This commit is contained in:
parent
f1afd9e177
commit
793a9ef027
4 changed files with 62 additions and 33 deletions
19
game.scm
19
game.scm
|
@ -44,8 +44,6 @@
|
|||
|
||||
(define game-width 320.0)
|
||||
(define game-height 240.0)
|
||||
(define tile-width 16.0)
|
||||
(define tile-height 16.0)
|
||||
(define level-width (inexact->exact (floor (/ game-width tile-width))))
|
||||
(define level-height (inexact->exact (floor (/ game-height tile-height))))
|
||||
|
||||
|
@ -324,15 +322,14 @@
|
|||
(('electric-switch pos on?) (draw-electric-switch pos on?))))
|
||||
|
||||
(define (draw-background)
|
||||
(let* ((bv (level-background *level*))
|
||||
(len (bytevector-length bv)))
|
||||
(let lp ((i 0))
|
||||
(when (< i len)
|
||||
(let ((x (bytevector-ieee-single-native-ref bv i))
|
||||
(y (bytevector-ieee-single-native-ref bv (+ i 4)))
|
||||
(idx (bytevector-u16-native-ref bv (+ i 8))))
|
||||
(draw-tile context tileset idx x y)
|
||||
(lp (+ i 10)))))))
|
||||
(let ((bg (level-background *level*))
|
||||
(k (* level-width level-height)))
|
||||
(do ((i 0 (1+ i)))
|
||||
((= i k))
|
||||
(let* ((tile (vector-ref bg i))
|
||||
(pos (level-tile-position tile))
|
||||
(id (level-tile-id tile)))
|
||||
(draw-tile context tileset id (vec2-x pos) (vec2-y pos))))))
|
||||
|
||||
(define (draw-level)
|
||||
(draw-background)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue