| Stickman Fighting Game - How to Jump? 
 
	 
	
		| Author | Message |   
		| Lawlly 
 
 
 
 
 | 
			
				|  Posted: Tue Dec 18, 2007 12:57 pm    Post subject: Stickman Fighting Game - How to Jump? |  |   
				| 
 |  
				| My friend and I have created this small stickman game. We have only basic turing knowledge and are stumped in an early stage. We don't have a clue how to make our stickpeople jump. We've managed to make them go up when you hold a key, but not a smooth motion of going up to a point and coming back down hitting a key only once. 
 Also when you attack with one of the stickmen it freezes the entire program instead of initiating just the arm punch.
 
 Suggestions and guidance will be much appreciated.
 
 Here is our simple program:
 
 Controls: A,D, and Spacebar for player 1.
 Left/Right arrow keys and Numpad 0 for player 2.
 
 
 	  | code: |  	  |  View.Set ("offscreenonly") %%% GETS RID OF THAT PESKY FLICKER!!!! %%%
 var keys : array char of boolean
 var myposition : int := 0
 var enemyposition : int := 400
 var myhp : int := 0
 var enemyhp : int := 100
 
 
 % PLAYER 1 MOVING
 loop
 
 Input.KeyDown (keys)
 if keys ('d') and myposition < 515 then
 myposition += 1
 delay (10)
 elsif keys ('a')and myposition > -80 then
 myposition -= 1
 delay (10)
 end if
 
 % PLAYER 2 MOVING
 if keys (KEY_LEFT_ARROW)and enemyposition >-80  then
 enemyposition -= 1
 delay (10)
 elsif keys (KEY_RIGHT_ARROW) and enemyposition < 515 then
 enemyposition += 1
 delay (10)
 end if
 
 % PLAYER 1 ATTACKING
 if myposition + 40 > enemyposition and keys (' ') then
 drawline (myposition + 100, 75, myposition + 125, 70, black)
 Time.DelaySinceLast (500)
 enemyhp -= 15
 end if
 
 %PLAYER 2 ATTACKING
 if enemyposition - 40 < myposition and keys ('0') then
 drawline (enemyposition + 75, 70, enemyposition + 100, 75, black)
 Time.DelaySinceLast (500)
 myhp += 15
 end if
 
 % PLAYER 1 BODY
 drawoval (myposition + 100, 100, 15, 15, black)
 drawline (myposition + 100, 85, myposition + 100, 50, black)
 drawline (myposition + 100, 50, myposition + 80, 20, black)
 drawline (myposition + 100, 50, myposition + 120, 20, black)
 drawline (myposition + 100, 75, myposition + 125, 90, black)
 
 %PLAYER 1 HP BAR
 drawfillbox (myhp + 50, 320, 160, 340, brightred)
 
 % PLAYER 1 HP BAR SETTINGS
 if myhp > 100 then
 put " PLAYER 1 LOSES!!!!!"
 exit
 end if
 
 
 
 %PLAYER 2 BODY
 drawoval (enemyposition + 100, 100, 15, 15, black)
 drawline (enemyposition + 100, 85, enemyposition + 100, 50, black)
 drawline (enemyposition + 100, 50, enemyposition + 80, 20, black)
 drawline (enemyposition + 100, 50, enemyposition + 120, 20, black)
 drawline (enemyposition + 100, 75, enemyposition + 75, 90, black)
 
 % PLAYER 2 HP BAR
 drawfillbox (enemyhp + 450, 320, 440, 340, brightred)
 
 % PLAYER 2 HP BAR SETTINGS THING
 if enemyhp < 0 then
 enemyhp := 0
 put " PLAYER 2 LOSES!!!!!!"
 end if
 exit when enemyhp <= 0
 
 
 
 View.Update     % NEEDED FOR ANTI FLICKER   %%%   >:(   %%%
 cls
 
 put myposition
 put enemyposition
 
 end loop
 
 | 
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| HeavenAgain 
 
  
 
 
 | 
			
				|  Posted: Tue Dec 18, 2007 1:07 pm    Post subject: RE:Stickman Fighting Game - How to Jump? |  |   
				| 
 |  
				| the stick man doesnt go up because you dont have a variable to carry the y coordinate of the stick man and when you attack the program freezes because you have this Time.DelaySinceLast which causes the program to freeze for what? 0.5 seconds?
 at a time like this, i suggest you fork them both (attacking) by using process
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Lawlly 
 
 
 
 
 | 
			
				|  Posted: Tue Dec 18, 2007 1:21 pm    Post subject: Re: Stickman Fighting Game - How to Jump? |  |   
				| 
 |  
				| Well we did make our y value have a variable in our jump test program. And like I've said before,  we've managed to make them go up when you hold a key, but not a smooth motion of going up to a point and coming back down when you hit a key only once. 
 Here is our failed jump:
 
 We've managed to make them go up when you hold a key, but not a smooth motion of going up to a point and coming back down hitting a key only once.
 
 
 	  | code: |  	  | View.Set ("offscreenonly")
 var keys : array char of boolean
 var counter : int := 0
 var y : int := 1
 
 loop % moving the person
 Input.KeyDown (keys)
 if keys (KEY_RIGHT_ARROW) then
 counter += 1
 elsif keys (KEY_LEFT_ARROW) then
 counter -= 1
 elsif keys (KEY_UP_ARROW) then
 put "JUMP!"
 y += 1
 elsif keys (KEY_DOWN_ARROW) then
 y -= 1
 end if
 
 %person
 drawoval (counter + 100, y + 100, 15, 15, black)
 drawline (counter + 100, y + 85, counter + 100, y + 50, black)
 drawline (counter + 100, y + 50, counter + 80, y + 20, black)
 drawline (counter + 100, y + 50, counter + 120, y + 20, black)
 drawline (counter + 100, y + 75, counter + 125, y + 90, black)
 
 
 delay (10)
 View.Update
 cls
 end loop
 
 | 
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| HeavenAgain 
 
  
 
 
 | 
			
				|  Posted: Tue Dec 18, 2007 1:42 pm    Post subject: RE:Stickman Fighting Game - How to Jump? |  |   
				| 
 |  
				| instead of having it like that, you could consider something like this: have a boolean variable to check if up is pressed if pressed, then you will do a for loop of how many pixel you want to jump
 for example, this is what i managed to do with an oval based on your code,
 	  | code: |  	  | View.Set ("offscreenonly")
 var keys : array char of boolean
 var jump : boolean := false
 var y : int := maxy div 2
 loop
 jump := false
 Input.KeyDown (keys)
 if keys (KEY_UP_ARROW) then
 jump := true
 end if
 if (jump) then
 for i : 1 .. 100
 if ( i < 50) then
 drawoval (maxx div 2, y + i, 10, 10, black)
 else
 drawoval (maxx div 2, y + (100-i), 10, 10, black)
 end if
 delay (5)
 View.Update
 cls
 end for
 end if
 end loop
 | 
  |  
				|  |  |   
		|  |  |  
	  
		|  |   
		|  |  
 |