Skip to content

Instantly share code, notes, and snippets.

import macros
macro foo(i: static[int]): untyped =
echo $i
foo(1)
foo(2)
macro foo2(i: static[int]): untyped =
echo $i
import
macros,
options,
sets,
strutils,
typetraits
macro foo(i: static[int]): untyped =
echo $i
jsonschema:
GltfId: Natural
GltfProperty:
extensions: JsonNode
extras: JsonNode
GltfAsset extends GltfProperty:
version: string ## The glTF version that this asset targets.
import
macros,
options,
sets,
strutils,
typetraits
type
Either2*[T0, T1] = object
case which: range[0..1]
jsonschema:
GltfId: Natural
GltfProperty:
extensions: JsonNode
extras: JsonNode
GltfAsset extends GltfProperty:
version: string ## The glTF version that this asset targets.
minVersion?: string ## The minimum glTF version that this asset targets.
copyright?: string ## A copyright message suitable for display to credit the content creator.
generator?: string ## Tool that generated this glTF model. Useful for debugging.
import
future,
macros,
options
export UnpackError
type
Result*[T,Err] = object
## A type which stores the result value of a procedure, or error if one occurred.

Gameplay

Controls

Key Description
Mouse Look around. Depending on your current action and held object, character turn speed might be limited.
WASD Walk.
Space Hold to jump higher, then release. Slows you down while you're charging your jump.
Shift Sprint. Uses stamina, similar to other actions.
import macros
type
EventHandler*[T] = proc(event: T)
Event*[T] = distinct seq[EventHandler[T]]
proc newEvent*[T](): Event[T] =
result = newSeq[EventHandler[T]]()
proc subscribe*[T](ev: Event[T], handler: EventHandler[T]) =
import macros
type
EventHandler*[T] = proc(event: T)
EventStore[T] = seq[EventHandler[T]]
proc getEventStore[T](): var EventStore[T] =
static var store = newSeq[T]()
result = store
# input.nim
event InputEvent:
time: uint32
MouseDown, MouseUp:
mousePosition: Point
KeyUp, KeyDown:
keysym: KeySym
# In module 1