Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
(local editor (require :polywell))
(local fennel (require :polywell.lib.fennel))
(local fmt (require :polywell.lib.fnlfmt))
(local completion (require :polywell.completion))
;; from here -- https://github.com/oakmac/parinfer-lua
(local parinfer (require :lib.parinfer))
(local inspect (require :lib.inspect))
import { GRID_TILE_HEIGHT, GRID_TILE_WIDTH } from "../../constants";
import { addxy, left, midpoint, xy } from "../../utils";
import { BattleActorObject } from "../BattleActorObject";
import { damageNumbers } from "../effects/damageNumbers";
import { Sequence } from "./sequence";
export const respawnSequence: Sequence<{
actor: BattleActorObject,
x: number,
y: number
(λ do-attack [action]
(set action.to.animating true)
(set action.from.animating true)
(process-trigger-queue)
(let [mp (action.to.pos:midpoint action.from.pos)]
(timeline.parallel-tween
[0.5 action.to {:pos mp} :outBounce]
[0.5 action.from {:pos mp} :outBounce]))
(set action.from.animating false)
(set action.to.animating false)
(λ do-attack [action]
(set action.to.animating true)
(set action.from.animating true)
(process-trigger-queue)
(let [mp (action.to.pos:midpoint action.from.pos)]
(timeline.parallel-tween
[0.5 action.from {:pos action.to.pos} :outBounce]))
;[0.5 action.from {:pos mp} :outBounce]))
(set action.from.animating false)
(set action.to.animating false)
@MattRoelle
MattRoelle / fennel-smalltalk.fnl
Created February 18, 2022 22:00
A smalltalk style object system written in Fennel Lisp
;; A smalltalk inspired object system for lua and Fennel
;; Where all operations are implemented via message passing
(local MethodTable {})
(set MethodTable.__index MethodTable)
(fn MethodTable.dispatch-effect [self k obj ...]
(when (self:get k)
((self:get k) obj ...))
(each [_ ref (pairs self.refs)]
@MattRoelle
MattRoelle / accumulate.fnl
Created February 7, 2022 00:28
accumulate as a find?
(fn party-has? [type]
(let [team (get-team-list :player)]
(accumulate [result false _ {: actor} (ipairs team)
:until result]
(and actor (= actor.type type)))))
;; Redux style state management
(local initial-state
{:screen nil
:energy 0
:deck (icollect [_ ct (ipairs [:scout :warrior :healer :archer :scout :scout :scout])]
(make-card ct))
:hand []
:field []
:discard []})
(require-macros :golly)
(local golly (require :golly))
(defentity test-entity [self props]
{:x 300 :y 200 :width 200 :height 200}
(mixins (golly.mixins.mouse-interaction))
(field :state
(statemachine :red
(transitions
(turn-red {:to :red})
(def start-grid [[0 0 0 0 0 1 0 0 0 0]
[0 0 0 0 1 0 0 0 0 0]
[0 0 0 0 1 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 1 1 0 0 0]
[0 0 1 0 0 1 1 0 0 0]
[0 1 0 0 0 0 0 0 0 0]
[1 0 0 0 0 0 0 0 0 0]])