summaryrefslogtreecommitdiff
path: root/characters.scm
diff options
context:
space:
mode:
Diffstat (limited to 'characters.scm')
-rw-r--r--characters.scm53
1 files changed, 53 insertions, 0 deletions
diff --git a/characters.scm b/characters.scm
new file mode 100644
index 0000000..c3f692b
--- /dev/null
+++ b/characters.scm
@@ -0,0 +1,53 @@
+;;; The Inevitable Game
+;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
+;;;
+;;; 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.
+;;;
+;;; This program 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
+;;; <http://www.gnu.org/licenses/>.
+
+(define-module (characters)
+ #:use-module (chickadee math rect)
+ #:use-module (chickadee math vector)
+ #:use-module (chickadee render color)
+ #:use-module (chickadee render font)
+ #:use-module (chickadee render shapes)
+ #:use-module (chickadee render texture)
+ #:use-module (chickadee render tiled)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-26)
+ #:use-module (ice-9 match)
+ #:use-module (engine assets)
+ #:use-module (engine node-2d)
+ #:use-module (oop goops)
+ #:export (<character>
+ conversations
+ accepted-messages
+ speaking?
+ velocity
+ walk-speed
+ direction
+ hitbox
+
+ load-atlas))
+
+(define-class <character> (<node-2d>)
+ (conversations #:accessor conversations #:init-keyword #:conversations)
+ (accepted-messages #:accessor accepted-messages #:init-form '((hello "Hello there!")))
+ (speaking? #:accessor speaking? #:init-form #f)
+ (velocity #:getter velocity #:init-form (vec2 0.0 0.0))
+ (walk-speed #:accessor walk-speed #:init-form 0.8)
+ (direction #:accessor direction #:init-form '(idle))
+ (hitbox #:getter hitbox #:init-form (make-rect 8.0 0.0 16.0 16.0)))
+
+(define (load-atlas file-name tile-width tile-height)
+ (split-texture (load-image file-name) tile-width tile-height))