diff --git a/assets/images/fennel-logo.svg b/assets/images/fennel-logo.svg new file mode 100644 index 0000000..ea272d4 --- /dev/null +++ b/assets/images/fennel-logo.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/images/logos/1.png b/assets/images/logos/1.png new file mode 100644 index 0000000..73107d6 Binary files /dev/null and b/assets/images/logos/1.png differ diff --git a/assets/images/logos/2.png b/assets/images/logos/2.png new file mode 100644 index 0000000..58074af Binary files /dev/null and b/assets/images/logos/2.png differ diff --git a/assets/images/love-logo-0.10.png b/assets/images/love-logo-0.10.png new file mode 100644 index 0000000..06d1180 Binary files /dev/null and b/assets/images/love-logo-0.10.png differ diff --git a/mapper.fnl b/mapper.fnl index 0517e33..83ed42d 100644 --- a/mapper.fnl +++ b/mapper.fnl @@ -1,4 +1,8 @@ (local state (require :state)) + +; ; ### Use seed to randomize stuff +(love.math.setRandomSeed (state.getSeed)) + ; Cell Stuff ; The "cell-num" is the number of cells across; it is then squared to make the ; grid. Each cell has a "cell-size" of walls ("wall-width") and hallways @@ -8,7 +12,7 @@ (var (hall-width wall-width) (values (. map-meta :h) (. map-meta :w))) (var cell-size (+ hall-width wall-width)) ; (fn wall-seg [] (+ 10 (math.random 1 3))) -(fn wall-seg [] (math.random 11 13)) +(fn wall-seg [] (love.math.random 11 13)) ; Helper functions for dealing with the cell list (fn cell-row [i] (+ 1 (math.floor (/ (- i 1) cell-num)))) (fn map-index [i] @@ -17,8 +21,9 @@ (- (* cell-col cell-size) (- cell-size 1)))) ; Meta-Cells is the data before the digits -(var spawn-cell (math.random 1 cell-num)) -(var leave-cell (math.random (+ (* cell-num (- cell-num 1)) 1) (* cell-num cell-num))) +(var spawn-cell (love.math.random 1 cell-num)) +(var leave-cell (love.math.random + (+ (* cell-num (- cell-num 1)) 1) (* cell-num cell-num))) (var spawn-spot {:x cell-size :y (+ (- (* spawn-cell cell-size) (- cell-size 1)) cell-size)}) @@ -94,7 +99,7 @@ (var chosen-next-cell {}) (when (> (length next-cells) 0) (table.insert cell-stack current-cell) - (set chosen-next-cell (. next-cells (math.random 1 (length next-cells)))) + (set chosen-next-cell (. next-cells (love.math.random 1 (length next-cells)))) ; Adjust walls accordingly (case chosen-next-cell {:d 1} (tset meta-cells (. chosen-next-cell :c) :s true) @@ -173,9 +178,10 @@ (fn print_map [map] (for [i 1 (length map)] - (var r "") + (var (r o) (values "" "")) (for [j 1 (length (. map i))] - (set r (.. r " " (. map i j)))) + (set o (if (= 0 (. map i j)) "00" (. map i j))) + (set r (.. r " " o))) (print r))) (fn generate [] @@ -183,7 +189,7 @@ (var data-maze (convert-cells meta-maze leave-cell)) (var data-map (generate_cell_map data-maze)) (var map (generate_map data-map spawn-cell leave-cell)) - ;(print_map map) + (print_map map) (values map spawn-spot)) ; (print (.. "SPAWN: " spawn-cell "(" (. spawn-spot :x) "," (. spawn-spot :y) ")")) diff --git a/mode-intro.fnl b/mode-intro.fnl index 45f45eb..a85b196 100644 --- a/mode-intro.fnl +++ b/mode-intro.fnl @@ -1,3 +1,4 @@ +(local state (require :state)) (var (screen-width screen-height) (love.window.getMode)) (var (mx my) (values (/ screen-width 2) (/ screen-height 2))) (love.mouse.setGrabbed false) @@ -5,12 +6,23 @@ (love.graphics.setNewFont 30) +(var ticks 0) +;; Start screen logos +(var screen-logos []) +(var screen-logo-files (love.filesystem.getDirectoryItems "assets/images/logos")) +(each [_ v (ipairs screen-logo-files)] + (local logo {}) + (tset logo :i (love.graphics.newImage (.. "assets/images/logos/" v))) + (var imgdata (love.image.newImageData (.. "assets/images/logos/" v))) + (tset logo :w (imgdata:getWidth)) + (tset logo :h (imgdata:getHeight)) + (table.insert screen-logos logo)) -(var footer-font (love.graphics.newFont 19)) +(var footer-font (love.graphics.newFont 11)) (local (major minor revision) (love.getVersion)) (fn helmet-hud [] - (love.graphics.setColor 0 1 0 0.25) + (love.graphics.setColor 0 1 1 1) (love.graphics.line 0 0 (+ (/ screen-width 6) 0) 35 (+ (/ screen-width 3) 0) 30 @@ -19,43 +31,74 @@ screen-width 0)) (var menu-font (love.graphics.newFont 20)) -(fn menu-button [x y t] - (love.graphics.polygon "line" x y +(fn menu-button [x y t la ra sa] + (love.graphics.polygon "line" (- x 100) y (+ x 100) y - (+ x 120) (+ y 20) + (+ x 150) (+ y 20) (+ x 100) (+ y 40) - x (+ y 40) - (- x 20) (+ y 20)) - (love.graphics.printf t x (+ y 11) (+ x 100)) - ) + (- x 100) (+ y 40) + (- x 150) (+ y 20)) + (love.graphics.printf t (- x 109) (+ y 3) (+ x 100))) + +(var show-logos true) +(var (screen-show logo-idx fade-time fade-mod) (values 0 1 0 1)) +(fn reset-logo-timers [] + (set screen-show 0) + (set fade-time 0) + (set fade-mod 1)) +(fn show-logo [x] + (var logo (. screen-logos x)) + (if + (< screen-show 5) + (do + (love.graphics.setColor 0 1 1 fade-time) + (love.graphics.draw (. logo :i) + (- (/ screen-width 2) (/ (. logo :w) 2)) + (- (/ screen-height 2) (/ (. logo :h) 2)))) + ; else + (do + (if (. screen-logos (+ x 1)) + (set logo-idx (+ x 1)) + ; else + (set show-logos false)) + (reset-logo-timers)))) { :draw (fn draw [] - (helmet-hud) - (menu-button (- (/ screen-width 2) 50) 100 (.. mx ", " my)) - ; (love.graphics.setNewFont 50) - ; (love.graphics.setColor 0.75 0.75 0.75) - ; (love.graphics.printf "L4-N-DER Training Simulator" 0 - ; (- (/ screen-height 2) 100) screen-width :center) - ; (love.graphics.setNewFont 20) - ; (love.graphics.setColor 0.55 0.55 0.05) - ; (love.graphics.printf "OFFICIAL LANDER EYES ONLY" 0 - ; (- (/ screen-height 2) 20) screen-width :center) - ; (love.graphics.setColor 0.75 0.75 0.75) - ; (love.graphics.printf "Press D To Deploy" 0 - ; (+ (/ screen-height 2) 20) screen-width :center) - ; (love.graphics.printf "Press Q To Quit" 0 - ; (+ (/ screen-height 2) 40) screen-width :center) - (love.graphics.printf - (: "Made with Love [%s.%s.%s] and Fennel" - :format major minor revision) footer-font 20 (- screen-height 30) screen-width :left) - (love.graphics.printf "A game by Bill Niblock" footer-font -20 (- screen-height 30) screen-width :right) + (if + show-logos + (show-logo logo-idx) + (do + (helmet-hud) + (menu-button (/ screen-width 2) 100 "S U R V I V O R") + (love.graphics.printf "Press P to Play" + 0 (+ (/ screen-height 2) 100) + screen-width :center) + (love.graphics.printf "Press Q to Quit" + 0 (+ (/ screen-height 2) 150) + screen-width :center) + (love.graphics.printf + (: "Made with Love [%s.%s.%s] and Fennel" + :format major minor revision) footer-font 20 (- screen-height 30) screen-width :left) + (love.graphics.printf "A game by Bill Niblock" footer-font -20 (- screen-height 30) screen-width :right))) ) + :update + (fn update [dt] + (set ticks (+ ticks dt)) + (when (> fade-time 2) + (set fade-mod -1)) + (set fade-time (+ fade-time (* fade-mod dt))) + (when (> ticks 1) + (set ticks (- ticks 1)) + (set screen-show (+ screen-show 1)))) + :keypressed (fn keypressed [key set-mode] - (when (= key "d") + (when (= key "p") + (var newseed (+ (love.timer.getTime) mx my)) + (state.setSeed newseed) (set-mode :mode-play)) (when (= key "q") (love.event.quit))) diff --git a/mode-play.fnl b/mode-play.fnl index 32f1b6e..35fcf1b 100644 --- a/mode-play.fnl +++ b/mode-play.fnl @@ -295,7 +295,6 @@ ) :keypressed (fn keypressed [k] - (when (= k "o") (state.modO -1)) - (when (= k "x") (love.event.quit)) + (when (= k "q") (love.event.quit)) ) } diff --git a/notes.md b/notes.md index 1651e9f..a584898 100644 --- a/notes.md +++ b/notes.md @@ -274,3 +274,7 @@ left-action, right-action, and select-action. There should also be a way to navigate with the keyboard. Using up and down arrows or keys will move the "selected" button, left/right arrows/keys will activate the left/right actions, and enter/use will activate the select action. + +Start simple, make the polygon a square, make the areas square. Add buttons for +survivors and supplies and monster and stuff, even though it's not implemented +yet. diff --git a/overlay.fnl b/overlay.fnl index ea2665a..d7f9185 100644 --- a/overlay.fnl +++ b/overlay.fnl @@ -56,7 +56,7 @@ ; This draws barriers around the screen ; Eventually to be improved into a helmet (fn helmet-hud [] - (love.graphics.setColor 0 1 0 0.25) + (love.graphics.setColor 0 1 1 0.25) (love.graphics.line 0 0 (+ (/ screen-width 6) 0) 35 (+ (/ screen-width 3) 0) 30 @@ -98,7 +98,7 @@ (> (+ c n) (length l)) 1 (+ c n))) (fn compass-bar [] - (love.graphics.setColor 0 1 0 0.25) + (love.graphics.setColor 0 1 1 0.25) (var (hc-output hc-padding) (values "" " ")) (var hc-idx (math.floor (+ 10 (* 10 (player.getDirX))))) (var hc-idx-mod 1) diff --git a/state.fnl b/state.fnl index d970d66..08e0ce5 100644 --- a/state.fnl +++ b/state.fnl @@ -1,6 +1,8 @@ ; Handles game-play stateful information (local pi math.pi) +(var game {:seed 14921215311}) + ; The Player table holds all the player stuff ; [x y] coordinates, [d] distance ; [dx dy] direction vector @@ -14,7 +16,9 @@ ; [h w] hall and wall widths (var map {:n 10 :h 2 :w 2}) -{:getPlayer (fn getPlayer [] player) +{:getSeed (fn getSeed [] game.seed) + :setSeed (fn setSeed [x] (set game.seed x)) + :getPlayer (fn getPlayer [] player) :getX (fn getX [] player.x) :setX (fn setX [x] (set player.x x)) :getY (fn getY [] player.y)