149 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			149 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| extern "grogs"
 | |
| 
 | |
| struct -character
 | |
|     init &xpos -int
 | |
|     init &ypos -int
 | |
| endstruct
 | |
| 
 | |
| init &player -character
 | |
| set &player.xpos 100
 | |
| set &player.ypos 100
 | |
| 
 | |
| set &movingUp false
 | |
| set &movingDown false
 | |
| set &movingLeft false
 | |
| set &movingRight false
 | |
| 
 | |
| pusharg "Grogs Window" 800 600
 | |
| call !grogs:initSDL &result
 | |
| 
 | |
| @mainLoop
 | |
| 
 | |
| !grogs:pollEvent &event
 | |
| 
 | |
| # nothing
 | |
| equal $event -1 &cond
 | |
| if $cond %skipChecks
 | |
| 
 | |
| # exit
 | |
| equal $event 0 &cond
 | |
| if $cond %endMainLoop
 | |
| 
 | |
| # key pressed
 | |
| equal $event 1 &cond
 | |
| if $cond %checkPressedKey
 | |
| 
 | |
| # key unpressed
 | |
| equal $event 2 &cond
 | |
| if $cond %checkUnpressedKey
 | |
| 
 | |
| @checkPressedKey
 | |
| !grogs:getLastKey &key
 | |
| 
 | |
| # up
 | |
| equal $key 1073741906 &cond
 | |
| if $cond %processUpPress
 | |
| 
 | |
| # down
 | |
| equal $key 1073741905 &cond
 | |
| if $cond %processDownPress
 | |
| 
 | |
| # left
 | |
| equal $key 1073741904 &cond
 | |
| if $cond %processLeftPress
 | |
| 
 | |
| #right
 | |
| equal $key 1073741903 &cond
 | |
| if $cond %processRightPress
 | |
| 
 | |
| jump %skipChecks
 | |
| 
 | |
| @processUpPress
 | |
| set &movingUp true
 | |
| jump %skipChecks
 | |
| 
 | |
| @processDownPress
 | |
| set &movingDown true
 | |
| jump %skipChecks
 | |
| 
 | |
| @processLeftPress
 | |
| set &movingLeft true
 | |
| jump %skipChecks
 | |
| 
 | |
| @processRightPress
 | |
| set &movingRight true
 | |
| jump %skipChecks
 | |
| 
 | |
| @checkUnpressedKey
 | |
| !grogs:getLastKey &key
 | |
| 
 | |
| # up
 | |
| equal $key 1073741906 &cond
 | |
| if $cond %processUpUnpress
 | |
| 
 | |
| # down
 | |
| equal $key 1073741905 &cond
 | |
| if $cond %processDownUnpress
 | |
| 
 | |
| # left
 | |
| equal $key 1073741904 &cond
 | |
| if $cond %processLeftUnpress
 | |
| 
 | |
| #right
 | |
| equal $key 1073741903 &cond
 | |
| if $cond %processRightUnpress
 | |
| 
 | |
| jump %skipChecks
 | |
| 
 | |
| @processUpUnpress
 | |
| set &movingUp false
 | |
| jump %skipChecks
 | |
| 
 | |
| @processDownUnpress
 | |
| set &movingDown false
 | |
| jump %skipChecks
 | |
| 
 | |
| @processLeftUnpress
 | |
| set &movingLeft false
 | |
| jump %skipChecks
 | |
| 
 | |
| @processRightUnpress
 | |
| set &movingRight false
 | |
| jump %skipChecks
 | |
| @skipChecks
 | |
| 
 | |
| if $movingUp %processUp
 | |
| jump %checkDown
 | |
| @processUp
 | |
| subtract $player.ypos 10 &player.ypos
 | |
| 
 | |
| @checkDown
 | |
| if $movingDown %processDown
 | |
| jump %checkLeft
 | |
| @processDown
 | |
| add $player.ypos 10 &player.ypos
 | |
| 
 | |
| @checkLeft
 | |
| if $movingLeft %processLeft
 | |
| jump %checkRight
 | |
| @processLeft
 | |
| subtract $player.xpos 10 &player.xpos
 | |
| 
 | |
| @checkRight
 | |
| if $movingRight %processRight
 | |
| jump %endMovement
 | |
| @processRight
 | |
| add $player.xpos 10 &player.xpos
 | |
| 
 | |
| @endMovement
 | |
| 
 | |
| pusharg $player.xpos $player.ypos 20 0 255 255
 | |
| !grogs:drawCircle &out
 | |
| 
 | |
| !grogs:renderFrame &out
 | |
| !grogs:clearRenderer &out
 | |
| pusharg 16
 | |
| !grogs:delay &out
 | |
| jump %mainLoop
 | |
| @endMainLoop
 |