summaryrefslogtreecommitdiff
path: root/super-bloom/common.scm
blob: 08d4eae09bd2fcec1cb7e6796ca17dc364d1ff10 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
;;; Copyright 2023 David Thompson
;;;
;;; Licensed under the Apache License, Version 2.0 (the "License");
;;; you may not use this file except in compliance with the License.
;;; You may obtain a copy of the License at
;;;
;;;    http://www.apache.org/licenses/LICENSE-2.0
;;;
;;; Unless required by applicable law or agreed to in writing, software
;;; distributed under the License is distributed on an "AS IS" BASIS,
;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;;; See the License for the specific language governing permissions and
;;; limitations under the License.

(define-module (super-bloom common)
  #:use-module (catbird asset)
  #:use-module (chickadee)
  #:use-module (chickadee audio)
  #:use-module (chickadee graphics text)
  #:use-module (oop goops)
  #:export (%default-width
            %default-height
            %game-width
            %game-height
            %game-width:float
            %game-height:float
            scope-datadir
            monogram-font
            explosion-sound
            absorb-sound
            watered-sound
            spray-sound
            random:float
            steps
            water))

(define %default-width 640)
(define %default-height 480)
(define %game-width 320)
(define %game-height 240)
(define %game-width:float (exact->inexact %game-width))
(define %game-height:float (exact->inexact %game-height))

(define (scope-datadir file-name)
  (let ((prefix (or (getenv "SUPERBLOOM_DATADIR") (getcwd))))
    (string-append prefix "/" file-name)))

(define-asset (monogram-font (file (scope-datadir "assets/fonts/monogram_extended.ttf")))
  (load-font file 12 #:smooth? #f))

(define-asset (explosion-sound (file (scope-datadir "assets/audio/explosion.wav")))
  (load-audio file))

(define-asset (absorb-sound (file (scope-datadir "assets/audio/absorb.wav")))
  (load-audio file))

(define-asset (watered-sound (file (scope-datadir "assets/audio/watered.wav")))
  (load-audio file))

(define-asset (spray-sound (file (scope-datadir "assets/audio/spray.wav")))
  (load-audio file))

(define (random:float n)
  (* (random:uniform) n))

(define (steps n)
  (* n (current-timestep)))

(define-accessor water)