diff --git a/two_player_cleaning_game/.DS_Store b/two_player_cleaning_game/.DS_Store index 3488215..ee089d4 100644 Binary files a/two_player_cleaning_game/.DS_Store and b/two_player_cleaning_game/.DS_Store differ diff --git a/two_player_cleaning_game/assets/dust_001.aseprite b/two_player_cleaning_game/assets/dust_001.aseprite deleted file mode 100644 index 6a7b47a..0000000 Binary files a/two_player_cleaning_game/assets/dust_001.aseprite and /dev/null differ diff --git a/two_player_cleaning_game/assets/dust_001.png b/two_player_cleaning_game/assets/dust_001.png deleted file mode 100644 index 65bbbf8..0000000 Binary files a/two_player_cleaning_game/assets/dust_001.png and /dev/null differ diff --git a/two_player_cleaning_game/main.fnl b/two_player_cleaning_game/main.fnl index fc30edd..1b7e742 100644 --- a/two_player_cleaning_game/main.fnl +++ b/two_player_cleaning_game/main.fnl @@ -1,40 +1,12 @@ -(local map-util (require "map-util.fnl")) - (var player-sprite nil) ; 20x20 pixels -(var dust-sprite nil) ; 35x35 pixels (local game-state { :player-pos [0 0] - :level 1 - :world [] }) -(fn start-level [] - ;; set player position to the start of the current level - (tset game-state :player-pos - (. map-util :levels (. game-state :level) :player-start)) - ;; set fresh world - (let [world []] - (each [y walls (ipairs (. map-util :levels (. game-state :level) :walls))] - (table.insert world []) - (each [x wall (ipairs walls)] - (table.insert (. world y) {:revealed false :type - (if (= wall 1) :wall :floor) - }) - ) - ) - (tset game-state :world world) - ) -) - - (fn love.load [] - (map-util:load) (love.window.setMode 600 640) (set player-sprite (love.graphics.newImage "assets/player_001.png")) - (set dust-sprite (love.graphics.newImage "assets/dust_001.png")) - (start-level) - (print (fennel.view game-state)) ;; start a thread listening on stdin (: (love.thread.newThread "require('love.event') while 1 do love.event.push('stdin', io.read('*line')) end") :start)) @@ -45,7 +17,6 @@ while 1 do love.event.push('stdin', io.read('*line')) end") :start)) (print (if ok (fennel.view val) val)))) - ;; drawing (lambda color [full-r full-g full-b] (let [(r g b) (love.math.colorFromBytes full-r full-g full-b)] @@ -54,57 +25,23 @@ while 1 do love.event.push('stdin', io.read('*line')) end") :start)) (local off-white (color 237 230 200)) (local black [0 0 0]) -(local black-half-tone [0 0 0 0.25]) (fn draw-game-outline [] (love.graphics.setColor (unpack black)) (love.graphics.rectangle "line" 50 50 500 500)) -(fn draw-world [] - (love.graphics.setColor (unpack black)) - ; (love.graphics.rectangle "fill" 50 50 500 500)) - (each [y cells (ipairs (. game-state :world))] - (each [x cell (ipairs cells)] - (case [(. cell :revealed) (. cell :type)] - [false _] (do - (love.graphics.setColor 1 1 1) ; reset color to white (no tinting) - (love.graphics.draw dust-sprite (+ 45 (* 25 (- x 1))) (+ 45 (* 25 (- y 1))))) - - [true :wall] (love.graphics.rectangle "fill" (+ 50 (* 25 (- x 1))) (+ 50 (* 25 (- y 1))) 25 25) - ) - ) - ) -) - - -; (print (fennel.view game-state)) (fn draw-player [] (love.graphics.setColor 1 1 1) ; reset color to white (no tinting) - (let [[player-x player-y] (. game-state :player-pos)] - (love.graphics.draw player-sprite - (* 25 player-x) - (* 25 player-y) - 0 1.25 1.25))) - -(fn draw-ghost-grid [] - (love.graphics.setColor (unpack black-half-tone)) - (for [y 0 19 1] - (for [x 0 19 1] - (love.graphics.rectangle "line" - (+ 50 (* x 25)) - (+ 50 (* y 25)) - 25 25)))) + (love.graphics.draw player-sprite 50 50 0 1.25 1.25)) (fn love.draw [] ;; clear the screen and set bg to off white (love.graphics.clear) (love.graphics.setColor (unpack off-white)) (love.graphics.rectangle "fill" 0 0 600 640) - (draw-game-outline) - (draw-ghost-grid) - (draw-world) (draw-player) + (draw-game-outline) ) ; (love.graphics.print "Hello from Fennel!\nPress any key to quit" 10 10)) diff --git a/two_player_cleaning_game/map-util.fnl b/two_player_cleaning_game/map-util.fnl deleted file mode 100644 index 0ff9d4b..0000000 --- a/two_player_cleaning_game/map-util.fnl +++ /dev/null @@ -1,36 +0,0 @@ -(local name "travis") - -(local levels [ - {:image-path "assets/level_002.png" :player-start [10 19] :walls []} -]) - -; "20 x 20 array with the outter edge set to 1 (walls) and the inner edge set to 0 (floor)" -(local empty-level - (let [level []] - (for [y 0 19 1] (table.insert level [])) ; empty rows - (each [y row (ipairs level)] - (for [x 0 19 1] (table.insert row 0))) - level - ) -) - -(lambda load-walls [level] - (let [image-data (love.image.newImageData (. level :image-path))] - (each [y row (ipairs (. level :walls))] - (each [x wall (ipairs row)] - (let [(r g b) (image-data:getPixel (- x 1) (- y 1))] - ; (print (.. x "," y " -> " r "," g "," b)) - (tset row x (if (= (.. r g b) "111") 0 1))))))) - -(fn load [] - "load levels" - (each [_ level (pairs levels)] - (tset level :walls empty-level) - (load-walls level)) - ; (print (fennel.view levels)) - ) - -{ - :load load - :levels levels -}