summaryrefslogtreecommitdiff
path: root/characters.scm
blob: c3f692bd73dd11a764b2dc764a766cd501063bd9 (about) (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
;;; 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))