-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add binding for vector-light.lua in vrld/hump * add binding for vector.lua in vrld/hump * add binding for camera.lua in vrld/hump * add binding for signal.lua in vrld/hump * add binding for timer.lua in vrld/hump * add ..(crude) binding for gamestate.lua in vrld/hump * update camera.lua with pre-existing smoothing functions, module callable to create an instance, varargs to lockX, lockY, varargs to SmoothingFUnction. * update signal.lua to have signatures that match global form as well
- Loading branch information
Showing
6 changed files
with
244 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
local record camera | ||
|
||
type DrawFunction = function() | ||
type SmoothingFunction = function(x: number, y: number, ...: any): number, number | ||
|
||
record smooth | ||
none: function(): SmoothingFunction | ||
linear: function(speed: number): SmoothingFunction | ||
damped: function(stiffness: number): SmoothingFunction | ||
end | ||
|
||
new: function(x: number, y: number, zoom: number, rot: number): camera | ||
|
||
move: function(self: camera, dx: number, dy: number): camera | ||
lookAt: function(self: camera, x: number, y: number): camera | ||
position: function(self: camera): number, number | ||
|
||
rotate: function(self: camera, angle: number): camera | ||
rotateTo: function(self: camera, angle: number): camera | ||
|
||
zoom: function(self: camera, mul: number): camera | ||
zoomTo: function(self: camera, zoom: number): camera | ||
|
||
attach: function(self: camera) | ||
detach: function(self: camera) | ||
|
||
draw: function(self: camera, func: DrawFunction) | ||
worldCoords: function(self: camera, x: number, y: number): number, number | ||
cameraCoords: function(self: camera, x: number, y: number): number, number | ||
mousePosition: function(self: camera): number, number | ||
|
||
lockX: function(self: camera, x: number, smoother: SmoothingFunction, ...: any) | ||
lockY: function(self: camera, y: number, smoother: SmoothingFunction, ...: any) | ||
lockPosition: function(self: camera, x: number, y: number, smoother: SmoothingFunction, ...: any) | ||
lockWindow: function(self: camera, x: number, y: number, x_min: number, x_max: number, y_min: number, y_max: number, smoother: SmoothingFunction, ...: any) | ||
|
||
-- module is callable as a function to create a new camera | ||
metamethod __call: function(self: camera, x: number, y: number, zoom: number, rot: number): camera | ||
|
||
smoother: SmoothingFunction | ||
scale: number | ||
x: number | ||
y: number | ||
|
||
end | ||
|
||
return camera |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
local record gamestate | ||
|
||
new: function(): gamestate | ||
|
||
switch: function(to: table, ...: any): any... | ||
current: function(): table | ||
|
||
push: function(to: table, ...: any): any... | ||
pop: function(): any... | ||
|
||
registerEvents: function() | ||
registerEvents: function({string}) | ||
|
||
-- hardcoded love lifecycle functions here, just the very basics :I | ||
update: function(dt: number) | ||
draw: function() | ||
|
||
end | ||
|
||
return gamestate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
local record signal | ||
|
||
new: function(self: signal): signal | ||
|
||
register: function(s: string, f: function): function | ||
register: function(self: signal, s: string, f: function): function | ||
|
||
emit: function(s: string, ...: any) | ||
emit: function(self: signal, s: string, ...: any) | ||
|
||
remove: function(...: function) | ||
remove: function(self: signal, ...: function) | ||
|
||
clear: function(s: string) | ||
clear: function(self: signal, s: string) | ||
|
||
emitPattern: function(p: string, ...: any) | ||
emitPattern: function(self: signal, p: string, ...: any) | ||
|
||
removePattern: function(p: string, ...: function) | ||
removePattern: function(self: signal, p: string, ...: function) | ||
|
||
clearPattern: function(p: string) | ||
clearPattern: function(self: signal, p: string) | ||
|
||
end | ||
|
||
return signal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
local record timer | ||
|
||
enum TweenType | ||
"linear" | ||
"quad" | ||
"cubic" | ||
"quart" | ||
"quint" | ||
"sine" | ||
"expo" | ||
"circ" | ||
"back" | ||
"bounce" | ||
"elastic" | ||
end | ||
|
||
type CallbackFunction = function() | ||
type DeltaCallbackFunction = function(dt: number) | ||
type WaitFunction = function(seconds: number) | ||
type Handle = table | ||
|
||
new: function(): timer | ||
|
||
script: function(func: WaitFunction) | ||
script: function(self: timer, func: WaitFunction) | ||
|
||
after: function(self: timer, delay: number, func: CallbackFunction): Handle | ||
after: function(delay: number, func: CallbackFunction): Handle | ||
|
||
every: function(delay: number, func: CallbackFunction): Handle | ||
every: function(self: timer, delay: number, func: CallbackFunction): Handle | ||
|
||
during: function(delay: number, func: DeltaCallbackFunction): Handle | ||
during: function(self: timer, delay: number, func: DeltaCallbackFunction): Handle | ||
|
||
during: function(delay: number, func: DeltaCallbackFunction, after: CallbackFunction): Handle | ||
during: function(self: timer, delay: number, func: DeltaCallbackFunction, after: CallbackFunction): Handle | ||
|
||
cancel: function(handle: Handle) | ||
cancel: function(self: timer, handle: Handle) | ||
|
||
clear: function() | ||
clear: function(self: timer) | ||
|
||
update: function(dt: number) | ||
update: function(self: timer, dt: number) | ||
|
||
tween: function(duration: number, subject: table, target: table, method: TweenType): Handle | ||
tween: function(self: timer, duration: number, subject: table, target: table, method: TweenType): Handle | ||
|
||
tween: function(duration: number, subject: table, target: table, method: TweenType, after: function, ...: any): Handle | ||
tween: function(self: timer, duration: number, subject: table, target: table, method: TweenType, after: function, ...: any): Handle | ||
|
||
end | ||
|
||
return timer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
local record vector_light | ||
|
||
str: function(x: number, y: number) | ||
|
||
fromPolar: function(angle: number, radius: number): number, number | ||
toPolar: function(x: number, y: number): number, number | ||
randomDirection : function(len_min: number, len_max: number): number, number | ||
|
||
-- arithmetic | ||
mul: function(s: number, x: number, y: number): number, number | ||
div: function(s: number, x: number, y: number): number, number | ||
idiv: function(s: number, x: number, y: number): number, number | ||
add: function(x1: number, y1: number, x2: number, y2: number): number, number | ||
sub: function(x1: number, y1: number, x2: number, y2: number): number, number | ||
permul: function(x1: number, y1: number, x2: number, y2: number): number, number | ||
dot: function(x1: number, y1: number, x2: number, y2: number): number | ||
cross: function(x1: number, y1: number, x2: number, y2: number): number | ||
det: function(x1: number, y1: number, x2: number, y2: number): number | ||
|
||
-- relation | ||
eq: function(x1: number, y1: number, x2: number, y2: number): boolean | ||
le: function(x1: number, y1: number, x2: number, y2: number): boolean | ||
lt: function(x1: number, y1: number, x2: number, y2: number): boolean | ||
|
||
-- misc operations | ||
len: function(x: number, y: number): number | ||
len2: function(x: number, y: number): number | ||
dist: function(x1: number, y1: number, x2: number, y2: number): number | ||
dist2: function(x1: number, y1: number, x2: number, y2: number): number | ||
normalize: function(x: number, y: number): number | ||
rotate: function(phi: number, x: number, y: number): number, number | ||
perpendicular: function(x: number, y: number): number, number | ||
project: function(x: number, y: number, u: number, v: number): number, number | ||
mirror: function(x: number, y: number, u: number, v: number): number, number | ||
angleTo: function(x: number, y: number, u: number, v: number): number | ||
trim: function(max_length: number, x: number, y: number): number, number | ||
end | ||
|
||
return vector_light |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
local record vector | ||
|
||
new: function(x: number, y: number): vector | ||
fromPolar: function(angle: number, radius: number): vector | ||
randomDirection: function(len_min: number, len_max: number): vector | ||
|
||
isvector: function(self: any): boolean | ||
clone: function(self: vector): vector | ||
unpack: function(self: vector): number, number | ||
permul: function(self: vector, other: vector): vector | ||
|
||
len: function(self: vector): number | ||
toPolar: function(self: vector): number, number | ||
len2: function(self: vector): number | ||
|
||
dist: function(self: vector, other: vector): number | ||
dist2: function(self: vector, other: vector): number | ||
|
||
normalized: function(self: vector): vector | ||
normalizeInPlace: function(self: vector): vector | ||
rotated: function(self: vector, angle: number): vector | ||
rotateInPlace: function(self: vector, angle: number): vector | ||
|
||
perpendicular: function(self: vector): vector | ||
projectOn: function(self: vector, v: vector): vector | ||
mirrorOn: function(self: vector, v: vector): vector | ||
cross: function(self: vector, other: vector): number | ||
angleTo: function(self: vector, other: vector): number | ||
|
||
trimmed: function(self: vector, max_length: number): vector | ||
trimInPlace: function(self: vector, max_length: number): vector | ||
|
||
metamethod __call: function(self: vector, x: number, y: number): vector | ||
|
||
metamethod __add: function(self: vector, other: vector): vector | ||
metamethod __sub: function(self: vector, other: vector): vector | ||
|
||
metamethod __mul: function(self: vector, other: vector): vector | ||
metamethod __mul: function(self: vector, scalar: number): vector | ||
|
||
metamethod __div: function(self: vector, other: vector): vector | ||
metamethod __div: function(self: vector, scalar: number): vector | ||
metamethod __idiv: function(self: vector, scalar: number): vector | ||
|
||
metamethod __eq: function(self: vector, other: vector): boolean | ||
metamethod __lt: function(self: vector, other: vector): boolean | ||
metamethod __le: function(self: vector, other: vector): boolean | ||
|
||
x: number | ||
y: number | ||
|
||
end | ||
|
||
return vector |