Skip to content

Commit

Permalink
Tons of fixes, and some shitty maps.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Oct 7, 2019
1 parent 8a99c82 commit 0ab806f
Show file tree
Hide file tree
Showing 24 changed files with 191 additions and 55 deletions.
Binary file added data/bionic-eye.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/gun.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/map1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions data/map1/data
@@ -0,0 +1,30 @@
(ground :texture (ld45 map1))
(goal :location (448.0 448.0))
(bionic-eye :location (416.0 224.0))
(player :location (368.59894 -454.80005))
(wall :location (-16.0 -544.0) :size (1120.0 128.0))
(wall :location (560.0 -32.0) :size (160.0 896.0))
(wall :location (-576.0 -64.0) :size (192.0 832.0))
(wall :location (-400.0 416.0) :size (160.0 384.0))
(wall :location (-160.0 544.0) :size (320.0 128.0))
(wall :location (-80.0 368.0) :size (160.0 96.0))
(wall :location (160.0 224.0) :size (192.0 192.0))
(wall :location (-272.0 368.0) :size (96.0 96.0))
(wall :location (-368.0 128.0) :size (96.0 64.0))
(wall :location (-368.0 32.0) :size (96.0 64.0))
(wall :location (-208.0 32.0) :size (96.0 64.0))
(wall :location (-208.0 128.0) :size (96.0 64.0))
(wall :location (-48.0 128.0) :size (96.0 64.0))
(wall :location (-48.0 -64.0) :size (96.0 64.0))
(wall :location (-368.0 -64.0) :size (96.0 64.0))
(wall :location (400.0 144.0) :size (160.0 32.0))
(wall :location (-192.0 -208.0) :size (128.0 32.0))
(wall :location (-144.0 -288.0) :size (32.0 128.0))
(wall :location (-272.0 -368.0) :size (288.0 32.0))
(wall :location (-400.0 -272.0) :size (32.0 160.0))
(wall :location (-352.0 -208.0) :size (64.0 32.0))
(wall :location (160.0 -240.0) :size (192.0 480.0))
(guard :location (187.0 64.0) :angle 0.0 :route ((64.0 64.0 3) (320.0 64.0 3)) :route-index 1 :route-direction 1 :end-action :loop)
(guard :location (-448.0 88.0) :angle -1.5707964 :route ((-192.0 192.0 0) (-192.0 224.0 2) (-192.0 192.0 0) (-448.0 192.0 0) (-448.0 -128.0 0) (-192.0 -128.0 0) (-192.0 -96.0 3) (-192.0 -128.0 0) (32.0 -128.0 0) (32.0 192.0 0)) :route-index 4 :route-direction 1 :end-action :loop)
(wall :location (240.0 368.0) :size (480.0 96.0))
(wall :location (304.0 544.0) :size (608.0 128.0))
2 changes: 2 additions & 0 deletions data/map1/meta.lisp
@@ -0,0 +1,2 @@
(:identifier world :version v0)
(:title "Untitled" :author "Anonymous" :payload "data")
Binary file added data/map2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions data/map2/data
@@ -0,0 +1,26 @@
(ground :texture (ld45 map2))
(goal :location (224.0 448.0))
(radar :location (384.0 0.0))
(player :location (-422.79883 -443.79874))
(wall :location (-224.0 -544.0) :size (576.0 128.0))
(wall :location (272.0 -496.0) :size (416.0 224.0))
(wall :location (560.0 -48.0) :size (160.0 1120.0))
(wall :location (-528.0 -32.0) :size (96.0 896.0))
(wall :location (-384.0 480.0) :size (384.0 128.0))
(wall :location (144.0 512.0) :size (672.0 64.0))
(wall :location (-240.0 -368.0) :size (480.0 96.0))
(wall :location (-64.0 -224.0) :size (128.0 192.0))
(wall :location (-64.0 176.0) :size (128.0 480.0))
(wall :location (240.0 400.0) :size (480.0 32.0))
(wall :location (320.0 240.0) :size (320.0 32.0))
(wall :location (320.0 80.0) :size (320.0 32.0))
(wall :location (320.0 -80.0) :size (320.0 32.0))
(wall :location (320.0 -240.0) :size (320.0 32.0))
(wall :location (176.0 -288.0) :size (32.0 64.0))
(wall :location (176.0 -128.0) :size (32.0 64.0))
(wall :location (176.0 32.0) :size (32.0 64.0))
(wall :location (176.0 192.0) :size (32.0 64.0))
(wall :location (176.0 352.0) :size (32.0 64.0))
(guard :location (-192.0 -102.0) :angle 1.5707964 :route ((-192.0 -256.0 0) (-192.0 352.0 0) (-416.0 352.0 0) (-416.0 160.0 0) (-288.0 160.0 2) (-288.0 -64.0 2) (-416.0 -64.0 0) (-416.0 -256.0 0)) :route-index 1 :route-direction 1 :end-action :loop)
(guard :location (416.0 320.0) :angle 0.0 :route ((288.0 320.0 10) (416.0 320.0 10)) :route-index 1 :route-direction 1 :end-action :loop)
(guard :location (224.36588 -351.7566) :angle -2.5545368 :route ((448.0 -288.0 2) (448.0 -352.0 2) (320.0 -288.0 2) (224.0 -352.0 2) (224.0 -288.0 2) (320.0 -352.0 2)) :route-index 3 :route-direction 1 :end-action :loop)
2 changes: 2 additions & 0 deletions data/map2/meta.lisp
@@ -0,0 +1,2 @@
(:identifier world :version v0)
(:title "Untitled" :author "Anonymous" :payload "data")
Binary file added data/map3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions data/map3/data
@@ -0,0 +1,32 @@
(ground :texture (ld45 map3))
(goal :location (-128.0 480.0))
(goal :location (-96.0 480.0))
(goal :location (-64.0 480.0))
(goal :location (-32.0 480.0))
(goal :location (0.0 480.0))
(goal :location (32.0 480.0))
(goal :location (64.0 480.0))
(gun :location (-256.0 -128.0))
(player :location (-368.2003 -443.99994))
(wall :location (-224.0 -368.0) :size (448.0 96.0))
(wall :location (-464.0 -48.0) :size (32.0 928.0))
(wall :location (0.0 -496.0) :size (896.0 32.0))
(wall :location (464.0 -32.0) :size (32.0 960.0))
(wall :location (272.0 464.0) :size (352.0 96.0))
(wall :location (-320.0 464.0) :size (320.0 96.0))
(wall :location (256.0 -112.0) :size (192.0 160.0))
(wall :location (240.0 80.0) :size (160.0 32.0))
(wall :location (176.0 144.0) :size (32.0 96.0))
(wall :location (240.0 208.0) :size (160.0 32.0))
(wall :location (336.0 192.0) :size (32.0 64.0))
(wall :location (336.0 96.0) :size (32.0 64.0))
(wall :location (-240.0 -240.0) :size (224.0 32.0))
(wall :location (-112.0 -128.0) :size (32.0 256.0))
(wall :location (-240.0 -16.0) :size (224.0 32.0))
(wall :location (-368.0 -32.0) :size (32.0 64.0))
(wall :location (-368.0 -192.0) :size (32.0 128.0))
(wall :location (272.0 -384.0) :size (288.0 128.0))
(guard :location (-224.0 -128.0) :angle 3.1415927 :route ((-192.0 -192.0 0) (-320.0 -192.0 0) (-320.0 -96.0 0) (-416.0 -96.0 0) (-416.0 64.0 0) (-416.0 384.0 0) (416.0 384.0 0) (416.0 32.0 0) (128.0 32.0 0) (-416.0 32.0 0) (-416.0 -96.0 0) (-320.0 -96.0 0) (-192.0 -96.0 0) (-192.0 -128.0 0) (-224.0 -128.0 3) (-192.0 -128.0 0)) :route-index 14 :route-direction 1 :end-action :loop)
(guard :location (256.0 128.0) :angle 0 :route nil :route-index 0 :route-direction 1 :end-action :loop)
(guard :location (23.0 320.0) :angle 0.0 :route ((128.0 320.0 0) (128.0 32.0 0) (128.0 -256.0 0) (-64.0 -256.0 0) (-64.0 128.0 0) (-96.0 128.0 6) (-64.0 128.0 0) (-32.0 128.0 6) (-64.0 128.0 0) (-64.0 320.0 0)) :route-index 0 :route-direction 1 :end-action :loop)
(guard :location (-192.0 320.0) :angle 1.5707964 :route ((-288.0 96.0 3) (-192.0 96.0 3) (-192.0 320.0 3) (-288.0 320.0 3)) :route-index 2 :route-direction 1 :end-action :loop)
2 changes: 2 additions & 0 deletions data/map3/meta.lisp
@@ -0,0 +1,2 @@
(:identifier world :version v0)
(:title "Untitled" :author "Anonymous" :payload "data")
Binary file added data/radar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 22 additions & 20 deletions editor.lisp
@@ -1,14 +1,16 @@
(in-package #:org.shirakumo.fraf.ld45)

(defparameter +grid-size+ 32)
(defparameter +editable-items+ '(wall guard player goal gun radar bionic-eye))

(define-subject editor (located-entity)
((name :initform :editor)
(entity :initform nil :accessor entity)
(mode :initform :select :accessor mode)
(vel :initform (vec 0 0) :accessor vel)
(start-location :initform nil :accessor start-location)
(visible-path :initform nil :accessor visible-path)))
(visible-path :initform nil :accessor visible-path)
(to-place :initform 'wall :accessor to-place)))

(define-subject inactive-editor (editor)
())
Expand Down Expand Up @@ -46,17 +48,12 @@
(define-handler (active-editor delete-entity) (ev)
(setf (mode active-editor) :delete))

(define-handler (active-editor place-wall) (ev)
(setf (mode active-editor) :place-wall))

(define-handler (active-editor place-player) (ev)
(setf (mode active-editor) :place-player))

(define-handler (active-editor place-guard) (ev)
(setf (mode active-editor) :place-guard))

(define-handler (active-editor place-goal) (ev)
(setf (mode active-editor) :place-goal))
(define-handler (active-editor place) (ev)
(case (to-place active-editor)
(wall (setf (mode active-editor) :place-wall))
(player (setf (mode active-editor) :place-player))
(guard (setf (mode active-editor) :place-guard))
(T (setf (mode active-editor) :place))))

;;; Entity manipulation

Expand Down Expand Up @@ -98,6 +95,7 @@
:location location
:size (vec2 0 0))))
(setf (start-location active-editor) location)
(transition wall +world+)
(enter wall +world+)
(setf (entity active-editor) wall)
(setf (mode active-editor) :placing-wall)))
Expand All @@ -111,9 +109,9 @@
(handle-place-guard-press active-editor pos button))
(:placing-guard
(handle-placing-guard-press active-editor pos button))
(:place-goal
(:place
(let* ((location (nvalign (world-location pos) +grid-size+))
(goal (make-instance 'goal
(goal (make-instance (to-place active-editor)
:location location)))
(transition goal +world+)
(enter goal +world+)
Expand Down Expand Up @@ -151,12 +149,16 @@
(update-scene-cache +world+ +world+))))

(define-handler (active-editor mouse-scroll) (ev delta)
(when (or (retained 'key :control)
(retained 'key :left-control) (retained 'key :control-l)
(retained 'key :right-control) (retained 'key :control-r))
(handle-editor-zoom delta))
(when (eq :placing-guard (mode active-editor))
(handle-modify-guard-delay active-editor (if (< 0 delta) 1 -1))))
(cond ((or (retained 'key :control)
(retained 'key :left-control) (retained 'key :control-l)
(retained 'key :right-control) (retained 'key :control-r))
(handle-editor-zoom delta))
((eq :placing-guard (mode active-editor))
(handle-modify-guard-delay active-editor (if (< 0 delta) 1 -1)))
(T
(let ((pos (position (to-place active-editor) +editable-items+)))
(setf (to-place active-editor) (elt +editable-items+ (mod (+ pos (round delta)) (length +editable-items+))))
(v:info :editor "Now placing ~s." (to-place active-editor))))))

(define-handler (active-editor tick) (ev)
(update-visible-path active-editor)
Expand Down
5 changes: 5 additions & 0 deletions goal.lisp
Expand Up @@ -8,11 +8,16 @@
(next-level-name (second (member (current-level-name main)
(level-names main)
:test #'string=))))
(setf *capabilities* (capabilities player))
(when next-level-name
(change-scene main (load-world (level-packet next-level-name)))
(setf (current-level-name main) next-level-name))))

(defmethod collide ((goal goal) (guard guard) hit))

(defmethod paint :around ((goal goal) target)
(when (active-p (unit :editor +world+))
(call-next-method)))

(defmethod paint :before ((goal goal) target)
(scale-by (* 2 (vx (bsize goal))) (* 2 (vy (bsize goal))) 1))
4 changes: 3 additions & 1 deletion ground.lisp
@@ -1,11 +1,13 @@
(in-package #:org.shirakumo.fraf.ld45)

(define-image map1 #p"map1.png")
(define-image map2 #p"map2.png")
(define-image map3 #p"map3.png")

(define-asset (ld45 map-mesh) mesh
(make-rectangle (* 32 32) (* 32 32)))

(define-shader-entity ground (vertex-entity textured-entity)
(define-shader-entity ground (vertex-entity textured-entity game-entity)
((vertex-array :initform (asset 'ld45 'map-mesh))))

(defmethod paint :around ((ground ground) target)
Expand Down
4 changes: 2 additions & 2 deletions guard.lisp
Expand Up @@ -63,8 +63,8 @@

(defmethod paint :around ((guard guard) pass)
(when (and (not (eql :down (state guard)))
;(capable-of :line-of-sight T)
)
(or (capable-of :line-of-sight T)
(active-p (unit :editor +world+))))
(paint (viewcone guard) pass))
(call-next-method))

Expand Down
15 changes: 5 additions & 10 deletions keys.lisp
Expand Up @@ -11,18 +11,9 @@
(define-action delete-entity (editor-command)
(key-press (one-of key :delete)))

(define-action place-wall (editor-command)
(define-action place (editor-command)
(key-press (one-of key :f5)))

(define-action place-player (editor-command)
(key-press (one-of key :f6)))

(define-action place-guard (editor-command)
(key-press (one-of key :f7)))

(define-action place-goal (editor-command)
(key-press (one-of key :f8)))

(define-action loop-guard-path (editor-command)
(key-press (one-of key :l)))

Expand Down Expand Up @@ -102,3 +93,7 @@
(define-action continue-game (player-action)
(key-press (one-of key :enter))
(gamepad-press (one-of button :start)))

(define-action interact (player-action)
(key-press (one-of key :space :enter :e))
(gamepad-press (one-of button :a)))
4 changes: 2 additions & 2 deletions main.lisp
Expand Up @@ -2,7 +2,7 @@

(defclass main (trial:main)
((scene :initform NIL)
(level-names :initform nil :accessor level-names)
(level-names :initform () :accessor level-names)
(current-level-name :initform nil :accessor current-level-name))
(:default-initargs
:clear-color (vec4 0 0 0 0)
Expand Down Expand Up @@ -48,4 +48,4 @@
(connect (port blur-pass 'color) (port light 'fog) scene)))

(defun launch (&optional world)
(trial:launch 'main :world world))
(trial:launch 'main :world world :level-names '("map1/" "map2/" "map3/")))
27 changes: 25 additions & 2 deletions moving.lisp
Expand Up @@ -35,11 +35,34 @@
(location target) (v+ (bsize source) (bsize target))))

(defmethod collide ((moving moving) (wall wall) hit)
(let ((loc (location moving))
(let ((bsize (bsize moving))
(psize (bsize wall))
(loc (location moving))
(pos (hit-location hit))
(vel (velocity moving))
(nor (hit-normal hit)))
(nv+ loc (v* vel (hit-time hit)))
(nv- vel (v* nor (v. vel nor)))
(cond ((and (/= 0 (vy nor))
(< (vy pos) (vy loc))
(< (- (vy loc) (vy bsize))
(+ (vy pos) (vy psize))))
(setf (vy loc) (+ (vy pos) (vy psize) (vy bsize))))
((and (/= 0 (vy nor))
(< (vy loc) (vy pos))
(< (- (vy pos) (vy psize))
(+ (vy loc) (vy bsize))))
(setf (vy loc) (- (vy pos) (vy psize) (vy bsize))))
((and (/= 0 (vx nor))
(< (vx pos) (vx loc))
(< (- (vx loc) (vx bsize))
(+ (vx pos) (vx psize))))
(setf (vx loc) (+ (vx pos) (vx psize) (vx bsize))))
((and (/= 0 (vx nor))
(< (vx loc) (vx pos))
(< (- (vx pos) (vx psize))
(+ (vx loc) (vx bsize))))
(setf (vx loc) (- (vx pos) (vx psize) (vx bsize)))))
T))

(define-subject draggable (moving)
Expand Down Expand Up @@ -70,4 +93,4 @@
(define-shader-subject human (moving animated-sprite-subject)
((vertex-array :initform (asset 'ld45 'human))
(size :initform (vec 32 32))
(bsize :initform (vec 16 16))))
(bsize :initform (vec 14 14))))
9 changes: 8 additions & 1 deletion pickup.lisp
Expand Up @@ -3,15 +3,22 @@
(define-asset (ld45 pickup-mesh) mesh
(make-rectangle 16 16))

(define-shader-entity pickup (vertex-entity textured-entity located-entity solid)
(define-shader-entity pickup (vertex-entity textured-entity located-entity solid game-entity)
((vertex-array :initform (asset 'ld45 'pickup-mesh))))

(defmethod scan ((pickup pickup) (moving moving))
(aabb (location moving) (velocity moving)
(location pickup) (v+ (bsize moving) 8)))

(defmethod collide ((player player) (pickup pickup) hit)
(setf (interactable player) pickup)
NIL)

(defgeneric pickup (pickup player))

(defmethod pickup :after ((pickup pickup) thing)
(leave pickup +world+))

(define-image gun #p"gun.png")

(define-shader-entity gun (pickup)
Expand Down
14 changes: 11 additions & 3 deletions player.lisp
@@ -1,6 +1,7 @@
(in-package #:org.shirakumo.fraf.ld45)

(define-image player #p"player.png")
(defvar *capabilities* ())

(define-global +move-speed+ 200)
(define-global +dragging-move-speed+ 64)
Expand All @@ -14,7 +15,7 @@
((name :initform :player)
(texture :initform (asset 'ld45 'player))
(move-timer :initform 0 :accessor move-timer)
(capabilities :initarg :capabilities :initform NIL :accessor capabilities)
(capabilities :initarg :capabilities :initform *capabilities* :accessor capabilities)
(interactable :initform NIL :accessor interactable)
(viewcone :initform (make-instance 'sector) :reader viewcone))
(:default-initargs
Expand All @@ -23,6 +24,9 @@
(drag 9 17)
(shoot 17 18))))

(defmethod register-object-for-pass :after (pass (player player))
(register-object-for-pass pass (viewcone player)))

(defmethod capable-of (thing (player (eql T)))
(capable-of thing (unit :player +world+)))

Expand Down Expand Up @@ -127,8 +131,8 @@
(define-handler (player continue-game) (ev)
(when (eq :dead (state player))
(v:info :player "Restarting...")
;; FIXME: insert restart logic here
))
(let ((main (handler *context*)))
(change-scene main (load-world (level-packet (current-level-name main)))))))

(define-asset (ld45 bullet-mesh) mesh
(make-rectangle 8 8))
Expand Down Expand Up @@ -167,3 +171,7 @@
(transition bullet +world+)
(enter bullet +world+))
(setf (state player) :shoot)))

(define-handler (player interact) (ev)
(when (interactable player)
(pickup (interactable player) player)))

0 comments on commit 0ab806f

Please sign in to comment.