Init fennel setup
This commit is contained in:
parent
9575795f2b
commit
8cc7a39d5a
6 changed files with 6817 additions and 1 deletions
23
README.md
23
README.md
|
|
@ -1,8 +1,29 @@
|
|||
|
||||
Playing around with [Love 2D](https://www.love2d.org/), [Lua](https://www.lua.org/),
|
||||
and [Fennel](https://fennel-lang.org/).
|
||||
|
||||
## Dev
|
||||
|
||||
### Init
|
||||
|
||||
Follow steps at [here](https://love2d.org/wiki/Getting_Started)
|
||||
to download, install, and add Love 2d to path.
|
||||
|
||||
Once done games can be started with `love ./game_dir`
|
||||
|
||||
### Dir setup
|
||||
|
||||
Fennel setup copied from [~benthor/absolutely-minimal-love2d-fennel](https://git.sr.ht/~benthor/absolutely-minimal-love2d-fennel/tree/master/item/README.md).
|
||||
Since fennel.lua and main.lua are the same for each game/project I put them on root level and soft linked to them
|
||||
in the project folders.
|
||||
|
||||
```
|
||||
.
|
||||
├── README.md
|
||||
├── fennel-1.5.3.lua
|
||||
├── fennel_bootstrap.lua
|
||||
└── hello_world
|
||||
├── fennel.lua -> ../fennel-1.5.3.lua
|
||||
├── main.fnl
|
||||
└── main.lua -> ../fennel_bootstrap.lua
|
||||
````
|
||||
|
||||
|
|
|
|||
6767
fennel-1.5.3.lua
Normal file
6767
fennel-1.5.3.lua
Normal file
File diff suppressed because one or more lines are too long
11
fennel_bootstrap.lua
Normal file
11
fennel_bootstrap.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fennel = require("fennel")
|
||||
debug.traceback = fennel.traceback
|
||||
table.insert(package.loaders, function(filename)
|
||||
if love.filesystem.getInfo(filename) then
|
||||
return function(...)
|
||||
return fennel.eval(love.filesystem.read(filename), {env=_G, filename=filename}, ...), filename
|
||||
end
|
||||
end
|
||||
end)
|
||||
-- jump into Fennel
|
||||
require("main.fnl")
|
||||
1
hello_world/fennel.lua
Symbolic link
1
hello_world/fennel.lua
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../fennel-1.5.3.lua
|
||||
15
hello_world/main.fnl
Normal file
15
hello_world/main.fnl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
(fn love.load []
|
||||
;; start a thread listening on stdin
|
||||
(: (love.thread.newThread "require('love.event')
|
||||
while 1 do love.event.push('stdin', io.read('*line')) end") :start))
|
||||
|
||||
(fn love.handlers.stdin [line]
|
||||
;; evaluate lines read from stdin as fennel code
|
||||
(let [(ok val) (pcall fennel.eval line)]
|
||||
(print (if ok (fennel.view val) val))))
|
||||
|
||||
(fn love.draw []
|
||||
(love.graphics.print "Hello from Fennel!\nPress any key to quit" 10 10))
|
||||
|
||||
(fn love.keypressed [key]
|
||||
(love.event.quit))
|
||||
1
hello_world/main.lua
Symbolic link
1
hello_world/main.lua
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../fennel_bootstrap.lua
|
||||
Loading…
Add table
Add a link
Reference in a new issue