summaryrefslogtreecommitdiff
path: root/lisparuga
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2016-05-15 20:11:58 -0400
committerDavid Thompson <dthompson2@worcester.edu>2016-05-15 20:12:49 -0400
commit2fce9e80092c28b51d2d8795ca04fecb43aed277 (patch)
tree441744189ced3e8a14186f28555e0b28b13c6521 /lisparuga
parent4bd5d6c93f6969fd417780b92cc5d2da4d699771 (diff)
Extract data types into their own modules.
Diffstat (limited to 'lisparuga')
-rw-r--r--lisparuga/bullets.scm38
-rw-r--r--lisparuga/enemies.scm43
-rw-r--r--lisparuga/explosions.scm32
-rw-r--r--lisparuga/player.scm41
-rw-r--r--lisparuga/stats.scm35
-rw-r--r--lisparuga/utils.scm23
-rw-r--r--lisparuga/world.scm42
7 files changed, 254 insertions, 0 deletions
diff --git a/lisparuga/bullets.scm b/lisparuga/bullets.scm
new file mode 100644
index 0000000..17322f6
--- /dev/null
+++ b/lisparuga/bullets.scm
@@ -0,0 +1,38 @@
+;;; Lisparuga
+;;; Copyright © 2016 David Thompson <davet@gnu.org>
+;;;
+;;; 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/>.
+
+(define-module (lisparuga bullets)
+ #:use-module (sly records)
+ #:use-module (sly math rect)
+ #:use-module (lisparuga utils)
+ #:export (make-bullet
+ bullet?
+ bullet-type
+ bullet-polarity
+ bullet-live?
+ bullet-position
+ bullet-direction
+ bullet-hitbox))
+
+(define-record-type* <bullet>
+ %make-bullet make-bullet
+ bullet?
+ (type bullet-type 'generic)
+ (polarity bullet-polarity 'light)
+ (live? bullet-live? #t)
+ (position bullet-position origin2)
+ (direction bullet-direction 0)
+ (hitbox bullet-hitbox (make-rect -1 -1 1 1)))
diff --git a/lisparuga/enemies.scm b/lisparuga/enemies.scm
new file mode 100644
index 0000000..06b2036
--- /dev/null
+++ b/lisparuga/enemies.scm
@@ -0,0 +1,43 @@
+;;; Lisparuga
+;;; Copyright © 2016 David Thompson <davet@gnu.org>
+;;;
+;;; 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/>.
+
+(define-module (lisparuga enemies)
+ #:use-module (sly records)
+ #:use-module (sly math rect)
+ #:use-module (sly math vector)
+ #:use-module (lisparuga utils)
+ #:export (make-enemy
+ enemy?
+ enemy-position
+ enemy-aim
+ enemy-type
+ enemy-polarity
+ enemy-hitbox
+ enemy-last-hit-time
+ enemy-health))
+
+(define-record-type* <enemy>
+ %make-enemy make-enemy
+ enemy?
+ (position enemy-position origin2)
+ (aim enemy-aim 0) ; angle for firing bullets
+ ;; TODO: We could leave out the '-light' part and use the polarity
+ ;; field to figure things out, but it's more work so forget it.
+ (type enemy-type 'pincer-dark)
+ (polarity enemy-polarity 'light)
+ (hitbox enemy-hitbox (make-rect -5 -5 10 10))
+ (last-hit-time enemy-last-hit-time #f)
+ (health enemy-health 0))
diff --git a/lisparuga/explosions.scm b/lisparuga/explosions.scm
new file mode 100644
index 0000000..48bf536
--- /dev/null
+++ b/lisparuga/explosions.scm
@@ -0,0 +1,32 @@
+;;; Lisparuga
+;;; Copyright © 2016 David Thompson <davet@gnu.org>
+;;;
+;;; 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/>.
+
+(define-module (lisparuga explosions)
+ #:use-module (sly records)
+ #:use-module (sly math vector)
+ #:use-module (lisparuga utils)
+ #:export (make-explosion
+ explosion?
+ explosion-type
+ explosion-position
+ explosion-time))
+
+(define-record-type* <explosion>
+ %make-explosion make-explosion
+ explosion?
+ (type explosion-type 'regular)
+ (position explosion-position origin2)
+ (time explosion-time 0))
diff --git a/lisparuga/player.scm b/lisparuga/player.scm
new file mode 100644
index 0000000..ca6f491
--- /dev/null
+++ b/lisparuga/player.scm
@@ -0,0 +1,41 @@
+;;; Lisparuga
+;;; Copyright © 2016 David Thompson <davet@gnu.org>
+;;;
+;;; 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/>.
+
+(define-module (lisparuga player)
+ #:use-module (sly records)
+ #:use-module (sly math rect)
+ #:use-module (sly math vector)
+ #:use-module (lisparuga utils)
+ #:export (make-player
+ player?
+ player-polarity
+ player-position
+ player-direction
+ player-shooting?
+ player-hitbox
+ player-absorb-hitbox
+ player-last-death-time))
+
+(define-record-type* <player>
+ %make-player make-player
+ player?
+ (polarity player-polarity 'light)
+ (position player-position (vector2 (/ (vx resolution) 2) 8))
+ (direction player-direction (vector2 0 0))
+ (shooting? player-shooting? #f)
+ (hitbox player-hitbox (make-rect -1 1 2 4))
+ (absorb-hitbox player-absorb-hitbox (make-rect -9 -2 16 6))
+ (last-death-time player-last-death-time #f))
diff --git a/lisparuga/stats.scm b/lisparuga/stats.scm
new file mode 100644
index 0000000..3abcdef
--- /dev/null
+++ b/lisparuga/stats.scm
@@ -0,0 +1,35 @@
+;;; Lisparuga
+;;; Copyright © 2016 David Thompson <davet@gnu.org>
+;;;
+;;; 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/>.
+
+(define-module (lisparuga stats)
+ #:use-module (sly records)
+ #:use-module (lisparuga utils)
+ #:export (make-stats
+ stats?
+ stats-score
+ stats-lives
+ stats-chain
+ stats-chain-type
+ stats-chain-progress))
+
+(define-record-type* <stats>
+ %make-stats make-stats
+ stats?
+ (score stats-score 0)
+ (lives stats-lives 3)
+ (chain stats-chain 0)
+ (chain-type stats-chain-type #f)
+ (chain-progress stats-chain-progress 0))
diff --git a/lisparuga/utils.scm b/lisparuga/utils.scm
new file mode 100644
index 0000000..f5f02b1
--- /dev/null
+++ b/lisparuga/utils.scm
@@ -0,0 +1,23 @@
+;;; Lisparuga
+;;; Copyright © 2016 David Thompson <davet@gnu.org>
+;;;
+;;; 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/>.
+
+(define-module (lisparuga utils)
+ #:use-module (sly math vector)
+ #:export (resolution
+ origin2))
+
+(define resolution (vector2 120 160))
+(define origin2 (vector2 0 0))
diff --git a/lisparuga/world.scm b/lisparuga/world.scm
new file mode 100644
index 0000000..6c7b431
--- /dev/null
+++ b/lisparuga/world.scm
@@ -0,0 +1,42 @@
+;;; Lisparuga
+;;; Copyright © 2016 David Thompson <davet@gnu.org>
+;;;
+;;; 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/>.
+
+(define-module (lisparuga world)
+ #:use-module (sly actor)
+ #:use-module (sly records)
+ #:use-module (lisparuga player)
+ #:use-module (lisparuga stats)
+ #:use-module (lisparuga utils)
+ #:export (make-world
+ world?
+ world-waves
+ world-stats
+ world-player
+ world-player-bullets
+ world-enemies
+ world-enemy-bullets
+ world-explosions))
+
+(define-record-type* <world>
+ %make-world make-world
+ world?
+ (waves world-waves #f)
+ (stats world-stats (make-stats))
+ (player world-player (make-actor (make-player) idle))
+ (player-bullets world-player-bullets '())
+ (enemies world-enemies '())
+ (enemy-bullets world-enemy-bullets '())
+ (explosions world-explosions '()))