Ignore this

This commit is contained in:
2025-09-23 08:09:25 +10:00
parent acaec4d40b
commit 0e332f3d83
3 changed files with 122 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
use "math"
struct -vector2d
init &xpos -double
init &ypos -double
fun -void !init -double &x -double &y
set &xpos $x
set &ypos $y
return true
endfun
fun -string !toString
tostring $xpos &x1
tostring $ypos &y1
add "(" $x1 &store
add $store ", " &store
add $store $y1 &store
add $store ")" &store
return $store
endfun
fun -double !atan2
pusharg $ypos $xpos
!math:atan2 &store
return $store
endfun
fun -double !modulus
multiply $xpos $xpos &x2
multiply $ypos $ypos &y2
add $x2 $y2 &z2
pusharg $z2
!math:sqrt &z
return $z
endfun
endstruct
struct -line2d
init &gradient -double
init &yint -double
fun -void !initGI -double &g -double &y
set &gradient $g
set &yint $y
return true
endfun
fun -void !initTP -point &p1 -point &p2
subtract $p2.ypos $p1.ypos &rise
subtract $p2.xpos $p1.xpos &run
divide $rise $run &gradient
multiply $gradient $p1.xpos &store
subtract $p1.ypos $store &yint
return true
endfun
fun -vector2d !getPoint -double &x
multiply $gradient $x &store
add $store $yint &y
init &ans -vector2d
pusharg $x $y
!ans.init &store
return $ans
endfun
endstruct
init &line -line2d
pusharg 3 1
!line.initGI &store
pusharg 3
!line.getPoint &store
stdlnout $store.xpos
stdlnout $store.ypos

View File

@@ -0,0 +1,45 @@
extern "grogs"
struct -keyTracker
init &keys -list
init &pressed -list
endstruct
init &keyTracker -keyTracker
setlist *keyTracker.keys 1073741904 1073741903 1073741906 1073741905
setlist *keyTracker.pressed false false false false
pusharg "My Awesome Window" 480 360
!grogs:initSDL &result
fun -int !keyPressed -keyTracker &keyTracker
# A key was just pressed means there is a mismatch between what is stored and the actual key presses
set &idx 0
set &ans -1
!grogs:getLastKey &key
getlistsize *keyTracker.keys &len
@loop
equal $idx $len &cond
if $cond %end
getlistat *keyTracker.keys $idx &store
inequal $key $store &cond
if $cond %increment
getlistat *keyTracker.pressed &cond
if $cond %increment
set &ans $store
@increment
add $idx 1 &idx
jump %loop
@end
return $ans
endfun
@loop
jump %loop

0
programs/test2.grnd Normal file
View File