blob: edd97fcdf399c11a9df75e3554dba5657b68a7fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
;;; Lisparuga
;;; Copyright © 2020 David Thompson <dthompson2@worcester.edu>
;;;
;;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; Game container. Handles all the state, logic, and rendering for
;; the game itself.
;;
;;; Code:
(define-module (lisparuga game)
#:use-module (chickadee math rect)
#:use-module (chickadee math vector)
#:use-module (chickadee render color)
#:use-module (chickadee render texture)
#:use-module (lisparuga asset)
#:use-module (lisparuga bullets)
#:use-module (lisparuga config)
#:use-module (lisparuga node)
#:use-module (lisparuga node-2d)
#:use-module (lisparuga player)
#:use-module (oop goops)
#:export (<game>
steer-player
start-player-shooting
stop-player-shooting
toggle-player-polarity
fire-player-homing-missiles))
(define-asset clouds (load-image (scope-asset "images/clouds.png")))
(define-asset player-bullet-atlas
(load-tile-atlas (scope-asset "images/player-bullets.png") 16 16))
;; nodes needed:
;; enemies
;; enemy bullets
;; scrolling background
(define-class <game> (<node-2d>))
(define-method (on-boot (game <game>))
(let* ((player-bullets (make <bullet-field>
#:capacity 500
#:texture-atlas player-bullet-atlas))
(player (make-player player-bullets))
(enemy-bullets (make <bullet-field>
#:capacity 1000
#:texture-atlas player-bullet-atlas)))
(attach-to game
(make <sprite>
#:name 'clouds
#:texture clouds)
player
player-bullets
enemy-bullets)))
(define-method (steer-player (game <game>) up? down? left? right?)
(steer (& game player) up? down? left? right?))
(define-method (start-player-shooting (game <game>))
(start-shooting (& game player)))
(define-method (stop-player-shooting (game <game>))
(stop-shooting (& game player)))
(define-method (toggle-player-polarity (game <game>))
(toggle-polarity (& game player)))
(define-method (fire-player-homing-missiles (game <game>))
(fire-homing-missiles (& game player)))
|