From 2fce9e80092c28b51d2d8795ca04fecb43aed277 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 15 May 2016 20:11:58 -0400 Subject: Extract data types into their own modules. --- Makefile.am | 8 +++- configure.ac | 2 +- game.scm | 97 +++++++++--------------------------------------- gamejam/dummy | 1 - lisparuga/bullets.scm | 38 +++++++++++++++++++ lisparuga/enemies.scm | 43 +++++++++++++++++++++ lisparuga/explosions.scm | 32 ++++++++++++++++ lisparuga/player.scm | 41 ++++++++++++++++++++ lisparuga/stats.scm | 35 +++++++++++++++++ lisparuga/utils.scm | 23 ++++++++++++ lisparuga/world.scm | 42 +++++++++++++++++++++ 11 files changed, 279 insertions(+), 83 deletions(-) delete mode 100644 gamejam/dummy create mode 100644 lisparuga/bullets.scm create mode 100644 lisparuga/enemies.scm create mode 100644 lisparuga/explosions.scm create mode 100644 lisparuga/player.scm create mode 100644 lisparuga/stats.scm create mode 100644 lisparuga/utils.scm create mode 100644 lisparuga/world.scm diff --git a/Makefile.am b/Makefile.am index 4bc7f58..ef006ae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,6 +37,13 @@ moddir=$(prefix)/share/guile/site/$(GUILE_EFFECTIVE_VERSION) godir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/ccache SOURCES = \ + lisparuga/utils.scm \ + lisparuga/bullets.scm \ + lisparuga/enemies.scm \ + lisparuga/explosions.scm \ + lisparuga/player.scm \ + lisparuga/stats.scm \ + lisparuga/world.scm \ game.scm imagesdir = $(pkgdatadir)/images @@ -73,7 +80,6 @@ EXTRA_DIST += \ AUTHORS \ pre-inst-env.in \ guix.scm \ - gamejam/dummy \ assets/images/enemies.xcf \ assets/images/chain.xcf \ assets/images/db16_v1_analyze.png \ diff --git a/configure.ac b/configure.ac index e0958df..d898a1c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl -*- Autoconf -*- -AC_CONFIG_SRCDIR(gamejam) AC_INIT(lisparuga, 0.1.1) +AC_CONFIG_SRCDIR(lisparuga) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([color-tests -Wall -Wno-portability foreign]) AM_SILENT_RULES([yes]) diff --git a/game.scm b/game.scm index 0455300..2c9f257 100644 --- a/game.scm +++ b/game.scm @@ -1,19 +1,18 @@ -;;; Sly -;;; Copyright (C) 2016 David Thompson +;;; Lisparuga +;;; Copyright © 2016 David Thompson ;;; -;;; This program 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 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. ;;; -;;; This program is distributed in the hope that it will be useful, -;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; 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 this program. If not, see -;;; . +;;; along with Lisparuga. If not, see . (use-modules (ice-9 format) (ice-9 match) @@ -29,88 +28,26 @@ (sly render tileset) (srfi srfi-1) (srfi srfi-9) - (srfi srfi-11)) + (srfi srfi-11) + (lisparuga bullets) + (lisparuga enemies) + (lisparuga explosions) + (lisparuga player) + (lisparuga stats) + (lisparuga utils) + (lisparuga world)) ;;; ;;; Model ;;; -(define resolution (vector2 120 160)) (define bounds (make-rect (vector2 0 0) resolution)) (define player-bounds (rect-inflate bounds -6 -8)) (define bullet-bounds (rect-inflate bounds 32 32)) (define player-speed 1.1) (define player-attack 1) -(define origin2 (vector2 0 0)) - - -;;; -;;; Data types -;;; - -(define-record-type* - %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))) - -(define-record-type* - %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)) - -(define-record-type* - %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)) - -(define-record-type* - %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)) - -(define-record-type* - %make-explosion make-explosion - explosion? - (type explosion-type 'regular) - (position explosion-position origin2) - (time explosion-time 0)) - -(define-record-type* - %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 '())) - ;;; ;;; Enemies diff --git a/gamejam/dummy b/gamejam/dummy deleted file mode 100644 index b8728b2..0000000 --- a/gamejam/dummy +++ /dev/null @@ -1 +0,0 @@ -Nothing to see here. Just making autoconf happy. 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 +;;; +;;; 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 . + +(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* + %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 +;;; +;;; 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 . + +(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* + %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 +;;; +;;; 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 . + +(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* + %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 +;;; +;;; 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 . + +(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* + %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 +;;; +;;; 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 . + +(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* + %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 +;;; +;;; 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 . + +(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 +;;; +;;; 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 . + +(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* + %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 '())) -- cgit v1.2.3