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. --- game.scm | 97 ++++++++++++---------------------------------------------------- 1 file changed, 17 insertions(+), 80 deletions(-) (limited to 'game.scm') 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 -- cgit v1.2.3