grogs+ package (WIP)
This commit is contained in:
		
							
								
								
									
										36
									
								
								packages/grogs+/grogs+.grnd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								packages/grogs+/grogs+.grnd
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,36 @@ | ||||
| extern "grogs" | ||||
|  | ||||
| fun -list !init | ||||
|     setlist &keyChecks 32 97 | ||||
|     setlist &keyDown false false | ||||
|     setlist &keyTracker $keyChecks $keyDown | ||||
|     return $keyTracker | ||||
| endfun | ||||
|  | ||||
| fun -int !keyPressed -list &keyTracker | ||||
|     getlistat &keyTracker 0 &keyChecks | ||||
|     getlistat &keyTracker 1 &keyDown | ||||
|  | ||||
|     !grogs:getLastKey &key | ||||
|     set &idx 0 | ||||
|     getlistsize &keyChecks &len | ||||
|     @loop | ||||
|         equal $idx $len &cond | ||||
|         if $cond %false | ||||
|  | ||||
|         getlistat &keyChecks $idx &store | ||||
|         equal $store $key &cond | ||||
|         getlistat &keyDown $idx &store | ||||
|         inequal $cond $store &cond | ||||
|         if $cond %true | ||||
|  | ||||
|         add $idx 1 &idx | ||||
|         jump %loop | ||||
|  | ||||
|     @true | ||||
|     getlistat &keyChecks $idx &store | ||||
|     return $store | ||||
|  | ||||
|     @false | ||||
|     return -1 | ||||
| endfun | ||||
| @@ -1,45 +0,0 @@ | ||||
| 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 | ||||
		Reference in New Issue
	
	Block a user