summaryrefslogtreecommitdiff
path: root/scripts/inevitable.in
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/inevitable.in')
-rw-r--r--scripts/inevitable.in62
1 files changed, 62 insertions, 0 deletions
diff --git a/scripts/inevitable.in b/scripts/inevitable.in
new file mode 100644
index 0000000..07401b1
--- /dev/null
+++ b/scripts/inevitable.in
@@ -0,0 +1,62 @@
+#!@GUILE@ --no-auto-compile
+-*- scheme -*-
+!#
+;;; Inevitable Game
+;;; Copyright © 2021 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/>.
+
+(use-modules (ice-9 match)
+ (chickadee)
+ (chickadee graphics)
+ (chickadee math matrix)
+ (config)
+ (scenes intro))
+
+(define *current-scene* scene)
+(define (get kw scene)
+ (or (and=> (memv kw scene) cadr)
+ (const #true)))
+
+(match (command-line)
+ ((_ scale)
+ (set! %scale-factor (string->number scale)))
+ (_ #false))
+
+(run-game #:window-title "Inevitable"
+ #:window-width (* %scale-factor %width)
+ #:window-height (* %scale-factor %height)
+ #:load
+ ;; This is only used for the first scene.
+ (get #:load *current-scene*)
+ #:draw
+ (lambda (alpha)
+ (with-projection
+ (orthographic-projection 0 %width %height 0 0 1)
+ ((get #:draw *current-scene*) alpha)))
+ #:update
+ (lambda (dt)
+ (let ((tag (make-prompt-tag)))
+ (call-with-prompt tag
+ (lambda ()
+ (catch 'switch-scene
+ (lambda ()
+ ((get #:update *current-scene*) dt))
+ (lambda (key new-scene)
+ ((get #:quit *current-scene*))
+ (set! *current-scene* new-scene)
+ ((get #:load *current-scene*))
+ (abort-to-prompt tag))))
+ (const #true)))))