help text, improve mode-swapping, fast drop, start in-game
This commit is contained in:
parent
760815c865
commit
2729b438e5
|
@ -8,9 +8,9 @@
|
|||
:names []
|
||||
: std-handlers})
|
||||
|
||||
(fn modes.cycle [self]
|
||||
(set self.mode-index (+ self.mode-index 1))
|
||||
(when (> self.mode-index (length self.names))
|
||||
(fn modes.cycle [self ?name]
|
||||
(set self.mode-index (if ?name (lume.find self.names ?name) (+ self.mode-index 1)))
|
||||
(when (or (not self.mode-index) (> self.mode-index (length self.names)))
|
||||
(set self.mode-index 1))
|
||||
(self:switch (self:current)))
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
Welcome to Edtris, the Editable Tetris!
|
||||
|
||||
This game has a text editor built into it! You are looking at an editor
|
||||
called "lite", which is written in Lua and has been ported to run inside
|
||||
the love2d game engine.
|
||||
This game has a text editor built into it! It is called "lite", and
|
||||
is written in Lua and has been ported to run inside the love2d game engine.
|
||||
|
||||
Edtris is written in Fennel, which is a language in the Lisp family
|
||||
that compiles to Lua.
|
||||
|
@ -32,9 +31,9 @@ to say
|
|||
At any time, you can press "E" to come back to this editor and try new things.
|
||||
Feel free to experiment!
|
||||
|
||||
* What happens if you make the well bigger?
|
||||
* What happens if you make the well deeper? Wider? A different shape?
|
||||
* What happens if you remove the walls of the well?
|
||||
* Can you draw a picture in the well?
|
||||
* Can you turn the well into a picture?
|
||||
|
||||
If you like, you can also run the game and the editor at the same time!
|
||||
If you press Ctrl-Shift-P, type "game" and press enter, a new tab will
|
||||
|
|
|
@ -22,6 +22,17 @@
|
|||
(let [xnext (/ dim.tilesize 2)
|
||||
xwell (* dim.tilesize 5)
|
||||
current (rules.current-tetromino)]
|
||||
(love.graphics.setColor 1 1 1 1)
|
||||
(love.graphics.setNewFont 22)
|
||||
(love.graphics.print "Next:" dim.tilesize 0)
|
||||
(love.graphics.setNewFont 18)
|
||||
(love.graphics.print "Controls:
|
||||
<- / -> = move
|
||||
down = drop
|
||||
spc = fast drop
|
||||
Z/X/up = rotate
|
||||
R = reset
|
||||
E = edit" (/ dim.tilesize 3) (* dim.tilesize 5))
|
||||
(map.draw-tilemap xwell 0 state.well tiles.tetristile)
|
||||
(map.draw-tilemap xnext dim.tilesize (rules.tetromino state.next-piece 1) tiles.tetristile)
|
||||
(when current
|
||||
|
|
|
@ -132,11 +132,18 @@
|
|||
stopped (Rules.collides? tetromino x y)]
|
||||
(if (and stopped (not= dy 0)) ; dropping
|
||||
(do (Rules.place-piece tetromino state.current.x state.current.y)
|
||||
(Rules.play-next-piece))
|
||||
(Rules.play-next-piece)
|
||||
:placed)
|
||||
|
||||
(not stopped)
|
||||
(do (set state.current.x x)
|
||||
(set state.current.y y))))))
|
||||
(set state.current.y y)
|
||||
:moved)
|
||||
|
||||
:blocked))))
|
||||
|
||||
(fn Rules.drop-piece []
|
||||
(while (not= (Rules.try-move-piece 0 1) :placed)))
|
||||
|
||||
(fn Rules.rotate [di]
|
||||
(when state.current
|
||||
|
@ -166,14 +173,19 @@
|
|||
(let [modes (require :editor.lovemode)
|
||||
core (require :core)
|
||||
filename "game/state.fnl"
|
||||
ldoc (core.open_doc filename)
|
||||
f (io.open filename :w)]
|
||||
(f:write (fv state))
|
||||
(f:close)
|
||||
(modes:cycle)
|
||||
(core.root_view:open_doc (core.open_doc filename))))
|
||||
(modes:cycle :editor)
|
||||
; ensure existing state.fnl opens
|
||||
(each [_ view (ipairs (core.root_view.root_node:get_children))]
|
||||
(when (= view.doc ldoc) (core.set_active_view view)))
|
||||
(core.root_view:open_doc ldoc)))
|
||||
|
||||
(set Rules.commands
|
||||
{:move Rules.try-move-piece
|
||||
:drop Rules.drop-piece
|
||||
:rotate Rules.rotate
|
||||
:reset Rules.reset-game
|
||||
:edit Rules.edit-game})
|
||||
|
@ -182,9 +194,10 @@
|
|||
{:left [:move -1 0]
|
||||
:right [:move 1 0]
|
||||
:down [:move 0 1]
|
||||
:up [:rotate 1]
|
||||
:z [:rotate -1]
|
||||
:x [:rotate 1]
|
||||
:up [:rotate -1]
|
||||
:space [:drop]
|
||||
:z [:rotate 1]
|
||||
:x [:rotate -1]
|
||||
:r [:reset]
|
||||
:e [:edit]})
|
||||
|
||||
|
|
13
wrap.fnl
13
wrap.fnl
|
@ -32,4 +32,17 @@
|
|||
"alt+u" "fennel:unload-macro"
|
||||
})
|
||||
|
||||
(set love.load
|
||||
(fn []
|
||||
(local modes (require :editor.lovemode))
|
||||
(let [f (io.open "game/state.fnl" :w)]
|
||||
(f:write "{}")
|
||||
(f:close))
|
||||
|
||||
(core.root_view:open_doc (core.open_doc "edtris.txt"))
|
||||
(: (core.root_view:get_active_node) :split :right)
|
||||
(core.root_view:open_doc (core.open_doc "game/state.fnl"))
|
||||
|
||||
(modes:cycle :game)))
|
||||
|
||||
{}
|
||||
|
|
Loading…
Reference in a new issue