Ignore this
This commit is contained in:
		
							
								
								
									
										77
									
								
								packages/geometry/geometry.grnd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								packages/geometry/geometry.grnd
									
									
									
									
									
										Normal 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 | ||||
							
								
								
									
										45
									
								
								packages/grogs/moreGrogs.grnd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								packages/grogs/moreGrogs.grnd
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										0
									
								
								programs/test2.grnd
									
									
									
									
									
										Normal file
									
								
							
		Reference in New Issue
	
	Block a user