Skip to content

Instantly share code, notes, and snippets.

(defonce pushers @[])
(defonce pullers @[])
(array/clear pushers)
(array/clear pullers)
(defonce click-buffer @[])
(array/clear click-buffer)
(defonce move-buffer @[])
(def mario @{:x 0 :y 0 :vx 0 :vy 0})
(defn physics
[dt mario]
(-> mario
(update :x + (* (mario :vx) dt))
(update :y + (* (mario :vy) dt))))
(defn walk
[x mario]
# two kinds of renders
(var mouse-stolen false)
(defn mouse-button-down?
[k]
(if ((dyn :context) :captured-mouse)
true
(and (not mouse-stolen)
(raylib/mouse-button-down? k))))
@saikyun
saikyun / caching.janet
Created April 13, 2021 15:59
Caching with hopefully nice ui.
(defn invalidate!
"Invalidates the cache, i.e. forces it to rerender next `cached-render` call."
[& [c]]
(default c (dyn :cache))
(put c :valid false))
(defn update!
"Like update, but also runs invalidate!"
[& args]
(update ;args)
41.09 How to handle focus
Kinds of focus
- Mouse clicks
- Hover
- Drag
- Keyboard handling
- (Re)rendering
How to detect focus
(use ./build/jaylib)
(set-config-flags
:msaa-4x-hint)
(init-window 800 600 "Chart")
(init-audio-device)
(set-target-fps 60)
(def current-animations @{})
@saikyun
saikyun / deps.edn
Last active February 10, 2021 14:04
import csv into sql server
{:deps {seancorfield/next.jdbc {:mvn/version "1.0.13"}
org.clojure/data.csv {:mvn/version "1.0.0"}
clojure.java-time {:mvn/version "0.3.2"}
com.microsoft.sqlserver/mssql-jdbc {:mvn/version "8.2.0.jre8"}}}
/*******************************************************************************************
*
* raylib [core] example - Basic window
*
* Welcome to raylib!
*
* To test examples, just press F6 and execute raylib_compile_execute script
* Note that compiled executable is placed in the same folder as .c file
*
* You can find all basic examples on C:\raylib\raylib\examples folder or
/*******************************************************************************************
*
* raylib [core] example - Basic window
*
* Welcome to raylib!
*
* To test examples, just press F6 and execute raylib_compile_execute script
* Note that compiled executable is placed in the same folder as .c file
*
* You can find all basic examples on C:\raylib\raylib\examples folder or
@saikyun
saikyun / main.janet
Last active November 26, 2020 19:40
repling with jaylib
# build jaylib (or use it as a dependency if you can)
# run `janet main.janet`
# in another terminal, run `janet main.janet connect`
# then modify and eval the `(defn frame ...)` form
# then run `(set frame-f frame)`
(use ./build/jaylib)
(import spork/netrepl)
(var font nil)