summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--art/logo.pngbin2119 -> 3510 bytes
-rw-r--r--credits.fnl67
-rw-r--r--game.fnl25
-rw-r--r--maps/demo.fnl3
-rw-r--r--maps/demo.pngbin0 -> 217 bytes
-rw-r--r--menu.fnl117
-rw-r--r--wrap.fnl6
7 files changed, 204 insertions, 14 deletions
diff --git a/art/logo.png b/art/logo.png
index 564af68..57b87be 100644
--- a/art/logo.png
+++ b/art/logo.png
Binary files differ
diff --git a/credits.fnl b/credits.fnl
new file mode 100644
index 0000000..6851d37
--- /dev/null
+++ b/credits.fnl
@@ -0,0 +1,67 @@
+;;;; Copyright (C) 2018 Jakob L. Kreuze, All Rights Reserved.
+;;;;
+;;;; This file is part of slime-the-world.
+;;;;
+;;;; slime-the-world 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.
+;;;;
+;;;; slime-the-world 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 slime-the-world. If not, see <http://www.gnu.org/licenses/>.
+
+(local text ["And with that,"
+ "our little"
+ "slimewad friend"
+ "was finally"
+ "content. The"
+ "basement was"
+ "covered in"
+ "slime!"
+ ""
+ "Thanks for"
+ "taking the"
+ "time to play"
+ "my entry to"
+ "this game jam!"
+ ""
+ "Be sure to read"
+ "the README.org"
+ "for greetz."
+ ""
+ "With love,"
+ "Jakob"])
+
+(var offset (- 216))
+
+(fn draw []
+ (each [i line (ipairs text)]
+ (let [height (: (love.graphics.getFont) :getHeight)
+ width (: (love.graphics.getFont) :getWidth line)
+ x (/ (- screen-width width) 2)
+ y (- (* height i) offset)]
+ (love.graphics.print line x y))))
+
+(fn update [dt set-mode]
+ (set offset (+ offset (* 16 dt)))
+ (when (> offset 420)
+ (set-mode :menu)))
+
+(fn keypressed []
+ (set offset (+ offset 16)))
+
+(fn keyreleased [])
+
+(fn click []
+ (set offset (+ offset 16)))
+
+{:draw draw
+ :update update
+ :keypressed keypressed
+ :keyreleased keyreleased
+ :click click}
diff --git a/game.fnl b/game.fnl
index b9d4e69..49ba063 100644
--- a/game.fnl
+++ b/game.fnl
@@ -32,14 +32,14 @@
(var current-camera nil)
(fn next-map []
- (set screen-alpha 1)
- (set welcome-message-y (- (: (love.graphics.getFont) :getHeight)))
- (set welcome-message-timer 64)
-
(let [map-name (table.remove map-order 1)]
- (set current-player (player.new))
- (set current-world (world.new map-name current-player))
- (set current-camera (camera.new current-world screen-width screen-height))
+ (when (~= nil map-name)
+ (set screen-alpha 1)
+ (set welcome-message-y (- (: (love.graphics.getFont) :getHeight)))
+ (set welcome-message-timer 64)
+ (set current-player (player.new))
+ (set current-world (world.new map-name current-player))
+ (set current-camera (camera.new current-world screen-width screen-height)))
(~= nil map-name)))
(next-map)
@@ -67,7 +67,7 @@
camera-y (. current-camera :y-pos)]
(: current-world :draw camera-x camera-y screen-width screen-height))
(draw-welcome-message)
- (draw-fade-in-mask))
+ (draw-fade-in-mask))
(fn update [dt set-mode]
(: current-world :update dt)
@@ -77,8 +77,8 @@
(tset current-camera :y-pos camera-y))
(when (= (. current-world :surfaces-slimed) (. current-world :surfaces-total))
- ;; if (next-map) returns nil, set-mode to endgame
- (next-map)))
+ (when (not (next-map))
+ (set-mode :credits))))
(fn keypressed [key set-mode]
(when (= key "x")
@@ -97,7 +97,10 @@
(when method
(: current-player method))))
+(fn click [])
+
{:draw draw
:update update
:keypressed keypressed
- :keyreleased keyreleased}
+ :keyreleased keyreleased
+ :click click}
diff --git a/maps/demo.fnl b/maps/demo.fnl
new file mode 100644
index 0000000..e76d4d7
--- /dev/null
+++ b/maps/demo.fnl
@@ -0,0 +1,3 @@
+{:name "Demonstration"
+ :player-spawn-x 32
+ :player-spawn-y 32}
diff --git a/maps/demo.png b/maps/demo.png
new file mode 100644
index 0000000..a26d2fd
--- /dev/null
+++ b/maps/demo.png
Binary files differ
diff --git a/menu.fnl b/menu.fnl
new file mode 100644
index 0000000..23e0166
--- /dev/null
+++ b/menu.fnl
@@ -0,0 +1,117 @@
+;;;; Copyright (C) 2018 Jakob L. Kreuze, All Rights Reserved.
+;;;;
+;;;; This file is part of slime-the-world.
+;;;;
+;;;; slime-the-world 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.
+;;;;
+;;;; slime-the-world 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 slime-the-world. If not, see <http://www.gnu.org/licenses/>.
+
+(local camera (require :camera))
+(local player (require :player))
+(local world (require :world))
+
+(local logo (love.graphics.newImage "art/logo.png"))
+
+(fn button-width [button]
+ (: (love.graphics.getFont) :getWidth (. button :text)))
+
+(fn button-height [button]
+ (: (love.graphics.getFont) :getHeight))
+
+(fn new-button [text offset function]
+ {:text text
+ :offset offset
+ :function function})
+
+(fn draw-logo [screen-width screen-height]
+ (let [x (/ (- screen-width (: logo :getWidth)) 2)
+ y (/ (- screen-height (: logo :getHeight)) 8)]
+ (love.graphics.draw logo x y)))
+
+(fn draw-button [button]
+ (let [text (. button :text)
+ offset (. button :offset)
+ width (button-width button)
+ height (button-height button)
+ x (/ (- screen-width width) 2)
+ y (+ (* height offset)
+ (/ (- screen-height height) 2))]
+ (love.graphics.print text x y)))
+
+(fn play-clicked [set-mode]
+ (set-mode :game))
+
+(fn sound-clicked []
+ (print "No sound"))
+
+(fn quit-clicked []
+ (love.event.quit))
+
+(local buttons [(new-button "Play" 0 play-clicked)
+ (new-button "Toggle Sound" 1 sound-clicked)
+ (new-button "Quit" 2 quit-clicked)])
+
+;; Demo world.
+(local current-player (player.new))
+(local current-world (world.new "demo" current-player))
+(local current-camera (camera.new current-world screen-width screen-height))
+
+(local demo-actions [:move-right 1 :stop-right 1 :move-left 1 :jump])
+(var demo-action-index 1)
+(var demo-action-timer 0)
+
+(fn draw []
+ (let [camera-x (. current-camera :x-pos)
+ camera-y (. current-camera :y-pos)]
+ (: current-world :draw camera-x camera-y screen-width screen-height))
+ (draw-logo screen-width screen-height)
+ (each [_ button (ipairs buttons)]
+ (draw-button button)))
+
+(fn update [dt]
+ (set demo-action-timer (- demo-action-timer dt))
+ (when (> 0 demo-action-timer)
+ (if (= "number" (type (. demo-actions demo-action-index)))
+ (set demo-action-timer (. demo-actions demo-action-index))
+ (: current-player (. demo-actions demo-action-index)))
+ (set demo-action-index (+ 1 demo-action-index))
+ (when (> demo-action-index (# demo-actions))
+ (set demo-action-index 1)))
+
+ (: current-world :update dt)
+ (: current-player :update dt)
+ (let [(camera-x camera-y) (: current-camera :focus-on-object current-player dt)]
+ (tset current-camera :x-pos camera-x)
+ (tset current-camera :y-pos camera-y)))
+
+(fn keypressed [])
+
+(fn keyreleased [])
+
+(fn click [mouse-x mouse-y set-mode]
+ (each [_ button (ipairs buttons)]
+ (let [offset (. button :offset)
+ width (button-width button)
+ height (button-height button)
+ x (/ (- screen-width width) 2)
+ y (+ (* height offset)
+ (/ (- screen-height height) 2))]
+ (when (and (>= mouse-x x) (<= mouse-x (+ x width))
+ (>= mouse-y y) (<= mouse-y (+ y height)))
+ ((. button :function) set-mode)))))
+
+{:activate activate
+ :draw draw
+ :update update
+ :keypressed keypressed
+ :keyreleased keyreleased
+ :click click}
diff --git a/wrap.fnl b/wrap.fnl
index 5e8ec7c..e3179e5 100644
--- a/wrap.fnl
+++ b/wrap.fnl
@@ -35,7 +35,7 @@
"abcdefghijklmnopqrstuvwxyz"
"[\\]^_`{|}~")))
-(var mode (require :game))
+(var mode (require :menu))
(fn set-mode [mode-name ...]
(set mode (require mode-name))
@@ -80,5 +80,5 @@
(fn love.keyreleased [key]
(mode.keyreleased key set-mode))
-(fn love.gamepadpressed [_ button]
- (print button))
+(fn love.mousepressed [x y]
+ (mode.click (/ x scale) (/ y scale) set-mode))