diff options
author | David Thompson <dthompson@vistahigherlearning.com> | 2020-04-14 17:02:17 -0400 |
---|---|---|
committer | David Thompson <dthompson@vistahigherlearning.com> | 2020-04-14 17:02:17 -0400 |
commit | f08e14fd51e2b1f5920ac6816774c5e72cbee5c0 (patch) | |
tree | 3ed2df4b9c78ca2872b8af2aa91ed3dbff004351 /lisparuga.scm | |
parent | 2bdb665cffff93721bbd38b3809a7c420dff2f1c (diff) |
Day 4 progress.
Diffstat (limited to 'lisparuga.scm')
-rw-r--r-- | lisparuga.scm | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lisparuga.scm b/lisparuga.scm index dc611cd..e5fb888 100644 --- a/lisparuga.scm +++ b/lisparuga.scm @@ -65,21 +65,22 @@ (make <sprite> #:name 'background #:rank 0 - #:texture background)) + #:texture background) + (make <game> + #:name 'game + #:rank 1 + #:position (vec2 80.0 0.0)))) + +(define-method (on-enter (lisparuga <lisparuga>)) (new-game-transition lisparuga)) -(define (new-game-transition lisparuga) +(define-method (new-game-transition lisparuga) (set! (state lisparuga) 'play) (let ((game-over (& lisparuga game-over))) (and game-over (detach game-over))) - (let ((old-game (& lisparuga game))) - (and old-game (detach old-game))) - (attach-to lisparuga - (make <game> - #:name 'game - #:rank 1 - #:position (vec2 80.0 0.0))) - (set! (state lisparuga) 'play)) + (reset (& lisparuga game)) + (set! (state lisparuga) 'play) + (start-stage (& lisparuga game))) (define-method (game-over-transition (lisparuga <lisparuga>)) (set! (state lisparuga) 'game-over) @@ -122,14 +123,13 @@ (define-method (on-key-press (lisparuga <lisparuga>) key scancode modifiers repeat?) (match (state lisparuga) ('play - (unless repeat? - (match key - ('z (start-player-shooting (& lisparuga game))) - ('x (toggle-player-polarity (& lisparuga game))) - ('c (fire-player-homing-missiles (& lisparuga game))) - ('r (spawn-enemies (& lisparuga game))) - ('e (set! (energy (& lisparuga game player)) 120)) - (_ #t)))) + (match key + ('z (start-player-shooting (& lisparuga game))) + ('x (unless repeat? + (toggle-player-polarity (& lisparuga game)))) + ('c (unless repeat? + (fire-player-homing-missiles (& lisparuga game)))) + (_ #t))) ((or 'win 'game-over) (match key ('return (new-game-transition lisparuga)) |