58 lines
1.9 KiB
Scheme
58 lines
1.9 KiB
Scheme
|
(define-module (game render other)
|
||
|
#:use-module (game model other)
|
||
|
#:use-module (chickadee)
|
||
|
#:use-module (chickadee math vector)
|
||
|
#:use-module (chickadee graphics sprite)
|
||
|
#:use-module (chickadee graphics texture)
|
||
|
#:export (render-other
|
||
|
render-other-load))
|
||
|
|
||
|
|
||
|
|
||
|
(define other-atlas #f)
|
||
|
|
||
|
(define (render-other-load)
|
||
|
(set! other-atlas (split-texture (load-image "assets/images/simples_pimples.png") 16 16)))
|
||
|
|
||
|
;; start index of the walk animation
|
||
|
(define other-walking-offset 3926)
|
||
|
(define other-falling-offset 3930)
|
||
|
(define other-climbing-offset 3929)
|
||
|
|
||
|
(define (other-sprite-walking other)
|
||
|
(let* ((x (other-x other))
|
||
|
(animation-frame (remainder x 3))
|
||
|
(other-index (+ other-walking-offset animation-frame)))
|
||
|
(texture-atlas-ref other-atlas other-index)))
|
||
|
|
||
|
(define (other-sprite-stationary _other)
|
||
|
(texture-atlas-ref other-atlas other-walking-offset))
|
||
|
|
||
|
(define (other-sprite-falling other)
|
||
|
(texture-atlas-ref other-atlas other-climbing-offset))
|
||
|
|
||
|
(define (other-sprite-climbing other)
|
||
|
(texture-atlas-ref other-atlas other-climbing-offset))
|
||
|
|
||
|
(define (render-other other)
|
||
|
(case (other-state other)
|
||
|
((stationary) (draw-sprite
|
||
|
(other-sprite-stationary other)
|
||
|
(vec2+ (other-position other) (vec2 -0.0 1.0))))
|
||
|
((fall) (draw-sprite
|
||
|
(other-sprite-falling other)
|
||
|
(vec2+ (other-position other) (vec2 -0.0 1.0))))
|
||
|
((climb) (draw-sprite
|
||
|
(other-sprite-climbing other)
|
||
|
(vec2+ (other-position other) (vec2 -0.0 1.0))))
|
||
|
((go-left) (draw-sprite
|
||
|
(other-sprite-walking other)
|
||
|
(vec2+ (other-position other) (vec2 0.0 1.0))
|
||
|
#:scale (vec2 -1.0 1.0)
|
||
|
))
|
||
|
((go-right) (draw-sprite
|
||
|
(other-sprite-walking other)
|
||
|
(vec2+ (other-position other) (vec2 -0.0 1.0))))
|
||
|
)
|
||
|
)
|