;;; Lisparuga ;;; Copyright © 2020 David Thompson ;;; ;;; Lisparuga is free software: you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published ;;; by the Free Software Foundation, either version 3 of the License, ;;; or (at your option) any later version. ;;; ;;; Lisparuga is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with Lisparuga. If not, see . ;;; Commentary: ;; ;; Main scene. ;; ;;; Code: (define-module (lisparuga) #:use-module ((chickadee) #:select (key-pressed?)) #:use-module (chickadee math rect) #:use-module (chickadee math vector) #:use-module (chickadee render color) #:use-module (chickadee render texture) #:use-module (ice-9 match) #:use-module (lisparuga asset) #:use-module (lisparuga config) #:use-module (lisparuga game) #:use-module (lisparuga kernel) #:use-module (lisparuga node) #:use-module (lisparuga node-2d) #:use-module (lisparuga player) #:use-module (lisparuga scene) #:use-module (oop goops) #:export (launch-lisparuga)) (define %framebuffer-width 320) (define %framebuffer-height 240) (define-asset background (load-image (scope-asset "images/background.png"))) (define-class () (state #:accessor state #:init-value 'init)) (define-method (game-over? (lisparuga )) (game-over? (& lisparuga game))) (define-method (complete? (lisparuga )) (complete? (& lisparuga game))) (define-method (on-boot (lisparuga )) ;; Scale a small framebuffer up to the window size. (set! (views lisparuga) (list (make #:camera (make #:width %framebuffer-width #:height %framebuffer-height) #:area (let ((wc (window-config (current-kernel)))) (make-rect 0 0 (window-width wc) (window-height wc)))))) (attach-to lisparuga (make #:name 'background #:rank 0 #:texture background) (make #:name 'game #:rank 1 #:position (vec2 80.0 0.0)))) (define-method (on-enter (lisparuga )) (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))) (reset (& lisparuga game)) (set! (state lisparuga) 'play) (start-stage (& lisparuga game))) (define-method (game-over-transition (lisparuga )) (stop-stage (& lisparuga game)) (set! (state lisparuga) 'game-over) (let ((game-over (make #:name 'game-over #:rank 999))) (attach-to game-over (make