This is another question for a figure called an ORBE in my game.
In the game that I'm making, I had a part in there in which the player could push an ORBE around in different directions (that is, until the ORBE is pushed into the door). I tried to make it so that the player has to get to the ORBE first in order to move it. However, now my ORBE won't move at all (it worked at first, but now it won't).
Also, I was wondering, what command do I use to make my array of apples disappear when the player goes into a door and thus, into a new scene?
Below, I explain what I tried to do and where I think the problem lies.
---------------------------------------------------------------------------------
Graphics 900, 900
SetBuffer BackBuffer()
EATUM = LoadImage ("Eatum.png")
APPLE = LoadImage("Apple.png")
ORBE = LoadImage("Orbe.png")
DOOR = LoadImage("Door.png")
DOOR2 = LoadImage ("RDoor.png")
DOOR3 = LoadImage ("GDOOR.png")
DOOR4 = LoadImage ("PDOOR.png")
PANCAKES = LoadImage ("Pancakes.png")
INVISIBLEPATCH = LoadImage ("Invisible Patch.png")
MUSIC = LoadSound ("Track1.mp3")
COLLECTIONSOUND = LoadSound ("Collectionsound.mp3")
BACKGROUND = LoadImage("Clouds.jpg")
BACKGROUND2 = LoadImage("stars.jpg")
BACKGROUND3 = LoadImage("Colors[1].jpg")
BACKGROUND4 = LoadImage ("underwater[1].jpg")
BACKGROUND5 = LoadImage ("Background5.jpg")
BACKGROUND6 = LoadImage ("Background6.jpg")
BACKGROUND7 = LoadImage ("Armsup.jpg")
Type EATUM
Field x,y
End Type
Type APPLE
Field x,y
End Type
Type ORBE
Field x,y
End Type
Type DOOR
Field x,y
End Type
Type DOOR2
Field x,y
End Type
Type DOOR3
Field x,y
End Type
Type DOOR4
Field x,y
End Type
Type PANCAKES
Field x,y
End Type
Type INVISIBLEPATCH
Field x,y
End Type
Type BACKGROUND
Field x,y
Field image
End Type
e.EATUM= New EATUM
e\x = 70
e\y = 200
;here's the array of apples in my second question
For z = 1 To 5
a.Apple = New Apple
a\x = 450 + (50*z)
a\y = 30
Next
;this is the ORBE that can be pushed around in each direction
;(I made a previous post about this ORBE in another thread)
o.ORBE = New ORBE
o\x = 100
o\y = -200
d.DOOR = New DOOR
d\x = 50
d\y = 50
b.BACKGROUND = New BACKGROUND
b\x = -500
b\y = 20
b\image = BACKGROUND
Score = 0
amx = 1
PlaySound MUSIC
While Not KeyDown (1)
Cls
TileImage (b\image,b\x,b\y)
Text 150,90, "Score " + Score
For a.APPLE = Each Apple
DrawImage(APPLE,(a\x + b\x),a\y)
If ImagesCollide(EATUM,e\x,e\y,0,APPLE,(a\x + b\x),a\y,0) Then
Delete a
score = score + 1
PlaySound (COLLECTIONSOUND)
EndIf
Next
If KeyDown(203)
e\x = e\x - 1
b\x = b\x + 4
;Anytime where EATUM and the ORBE collides, EATUM pushes the
;ORBE across the screen in whichever direction EATUM is going
;(hence, it is why the four "If ImagesCollide" commands are written
;below the keydown commands).
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
If KeyDown(205)
e\x = e\x + 1
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
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
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
If (o <> Null) Then
;Here is where the problem lies. I was trying to make it so that
;the player has to get to the ORBE in order to push it across the
;screen, but ever since I put in (b\x + o\x)
;inside of this particular DrawImage section, the player has been
;unable to push the ORBE around on screen in the way that it
;used to could do (that is, before I put this line in, the player could
;push the ORBE across the screen)...thus, maybe I'm doing
;something wrong here.
DrawImage (ORBE,(b\x + o\x),o\y)
If (d <> Null) Then
DrawImage (DOOR,(b\x + d\x),d\y)
If ImagesCollide(DOOR,d\x,d\y,0,ORBE,o\x, o\y,0) Then
Delete o
Delete d
;this part pertains to my second question. After the ORBE is pushed
;into the door, I wanted the array of APPLES to disappear (because,
;the player EATUM would be in another room). I put Delete a, but
;I guess that's the wrong command to delete all of them.
Delete a
score = score + 1
b\image = BACKGROUND2
p.PANCAKES = New PANCAKES
p\x = 2300
p\y = 250
EndIf
EndIf
EndIf
If (p <> Null) Then
DrawImage (PANCAKES,(b\x + p\x),p\y)
If ImagesCollide (EATUM,e\x,e\y,0,PANCAKES,(b\x + p\x),p\y,0) Then
Delete p
score = score + 1
b\image = BACKGROUND3
d2.DOOR2 = New DOOR2
d2\x = 20
d2\y = 120
EndIf
EndIf
If (d2 <> Null) Then
DrawImage (DOOR2,d2\x,d2\y)
If ImagesCollide (EATUM,e\x,e\y,0,DOOR2,d2\x,d2\y,0) Then
Delete d2
b\image = BACKGROUND4
d3.DOOR3 = New DOOR3
d3\x = 1400
d3\y = 420
EndIf
EndIf
If (d3 <> Null) Then
DrawImage (DOOR3,(b\x + d3\x),d3\y)
If ImagesCollide (EATUM,e\x,e\y,0,DOOR3,(b\x + d3\x),d3\y,0)
Delete d3
b\image = BACKGROUND5
d4.DOOR4 = New DOOR4
d4\x = 30
d4\y = 30
EndIf
EndIf
If (d4 <> Null) Then
DrawImage (DOOR4,d4\x,d4\y)
If ImagesCollide (EATUM,e\x,e\y,0, DOOR4,d4\x,d4\y,0)
Delete d4
b\image = BACKGROUND6
i.INVISIBLEPATCH = New INVISIBLEPATCH
i\x = 40
i\y = -200
EndIf
EndIf
If (i <> Null) Then
DrawImage (INVISIBLEPATCH,i\x,i\y)
If ImagesCollide (EATUM,e\x,e\y,0,INVISIBLEPATCH,i\x,i\y,0)
Delete i
b\image = BACKGROUND7
EndIf
EndIf
DrawImage (EATUM,e\x,e\y)
Flip
Wend
|