Here is a Shorter Version of my Question Below

BlitzPlus Forums/BlitzPlus Programming/Here is a Shorter Version of my Question Below

En929(Posted 2009) [#1]
Here's a shorter version of my question so that there isn't as much to sift through (I hope). I was trying to make it so that when the player gets to the ORBE character, it pushes the ORBE in which ever direction the player is going. But, I ran into some problems.

1) When the player goes up, the ORBE goes up when the player has NOT collided with the ORBE.

2) The ORBE is not colliding at all, even when I have the "ImageCollide" commands in it

3) My problems actually started when I put in the following command:


If (o <> Null) Then


DrawImage (ORBE,(b\x + o\x),o\y)

EndIf

Maybe I did something wrong here or I didn't put it in right. I hope that I could get help with this. Below, inside the code, I commented where I think the problems are located so that they could be more easily found. Thanks!






Graphics 900, 900
SetBuffer BackBuffer()

;Loading images
 
EATUM = LoadImage ("Eatum.png") 
ORBE = LoadImage("Orbe.png")
BACKGROUND =  LoadImage("Clouds.jpg")


;Setting up the image types

Type EATUM

Field x,y


End Type 	

Type ORBE

	Field x,y

End Type 

Type BACKGROUND
	
	Field x,y
	Field image
	
	
End Type 



;giving the images a shorter name and telling their locations

e.EATUM= New EATUM

e\x = 70
e\y = 200


o.ORBE = New ORBE
o\x = 100
o\y = -200

b.BACKGROUND = New BACKGROUND

b\x = -500
b\y = 20
b\image = BACKGROUND 




While Not KeyDown (1)  


Cls

		
		

TileImage (b\image,b\x,b\y)





;this moves the player to the left and if the player runs into the ORBE, 
;the ORBE is supposed to be pushed to the left

If KeyDown(203)
b\x = b\x + 4

 
	If (o <> Null) Then
	
	
			If ImagesCollide(EATUM, e\x, e\y,0,ORBE, o\x, o\y,0) Then 
			
			o\x = o\x - 3

			EndIf 
	EndIf
	
EndIf
	


;this moves the player to the right and if the player runs into the 
;ORBE, the ORBE is supposed to be pushed to the rght

If KeyDown(205)
 

b\x = b\x - 4

 

	If (o <> Null) Then
	

		If ImagesCollide(EATUM,e\x,e\y,0,ORBE,o\x,o\y,0) Then 
				
			 o\x = o\x + 3
	
	
	
		EndIf 

	EndIf

EndIf 


;Here's one of the problems that I've had. I was trying to make it so 
;that when the player collides with the ORBE, the ORBE goes 
;up when  the player collides with it. But, the problem is that when 
;the player goes up and gets to a certain proximity to the ORBE, the 
;ORBE goes up at a time when the player HAS NOT collided with it. So 
;thus, I was wondering what am I doing wrong here. Gosh, computers 
;do some strange things...


If KeyDown(200)
 e\y = e\y - 3


	If (o <> Null) Then

		If ImagesCollide(EATUM,e\x,e\y,0,ORBE, o\x,o\y,0) Then 
		
			 o\y = o\y - 3
 

		EndIf 

	EndIf
	
EndIf 	
			

;this moves the player down and if the player runs into the ORBE 
;while going down, the ORBE is supposedly to be pushed down.


If KeyDown(208) 
e\y = e\y + 3

	If (o <> Null) Then


		If ImagesCollide(EATUM,e\x,e\y,0,ORBE, o\x,o\y,0) Then
		
			  o\y = o\y + 3


		EndIf 


	EndIf 
	
EndIf 



;here's where another problem lies. Here, I was trying to make it so 
;that the player has to actually get to the ORBE in order
;to push it. But, it won't collide at all even though I put in 
;the "ImagesCollide" command. And once again, when the player 
;pushes the up button, when it gets to a certain PROXIMITY to the 
;ORBE, the ORBE may moves up when the player HASN'T collided with
;it. Thus, how do I fix this. Thanks


If (o <> Null) Then

	
			DrawImage (ORBE,(b\x + o\x),o\y) 

EndIf 




DrawImage (EATUM,e\x,e\y)
	
	
	Flip

Wend