/
main.lisp
52 lines (44 loc) · 1.98 KB
/
main.lisp
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
(in-package #:org.shirakumo.fraf.ld45)
(defclass main (trial:main)
((scene :initform NIL)
(level-names :initform () :accessor level-names)
(current-level-name :initform nil :accessor current-level-name))
(:default-initargs
:clear-color (vec4 0 0 0 0)
:title "LD45"
:width 1280
:height 720))
(defun level-packet (level-name)
(with-packet (packet (merge-pathnames (uiop:parse-unix-namestring level-name)
(pool-path 'ld45 nil))
:direction :input)
packet))
(defmethod initialize-instance ((main main) &key world level-names)
(call-next-method)
(when (and level-names (null world))
(let ((first-level-name (first level-names)))
(setf (level-names main) level-names)
(setf (current-level-name main) first-level-name)
(setf world (level-packet first-level-name))))
(setf (scene main)
(cond
(world (load-world world))
(t (make-instance 'empty-world)))))
(defmethod (setf scene) :after (scene (main main))
(setf +world+ scene))
(defmethod finalize :after ((main main))
(setf +world+ NIL))
(defmethod setup-rendering :after ((main main))
(disable :cull-face :scissor-test :depth-test :stencil-test))
(defmethod setup-scene ((main main) scene)
(enter (make-instance 'inactive-editor) scene)
(enter (make-instance 'camera) scene)
(let ((fog-of-war (make-instance 'fog-of-war))
(h-blur (make-instance 'gaussian-blur-pass :uniforms `(("dir" ,(vec 1 1)) ("intensity" 4.0))))
(v-blur (make-instance 'gaussian-blur-pass :uniforms `(("dir" ,(vec 0 1)) ("intensity" 4.0))))
(light (make-instance 'lighting-pass)))
(connect (port fog-of-war 'color) (port h-blur 'previous-pass) scene)
(connect (port h-blur 'color) (port v-blur 'previous-pass) scene)
(connect (port v-blur 'color) (port light 'fog) scene)))
(defun launch (&optional world)
(trial:launch 'main :world world :level-names '("credits/" "intro/" "map1/" "map2/" "map3/" "credits/")))