I have a part in a game that I've been building where the character is to jump into the door to get to the another part in the game. But, when the player (HENRY) jumps into the door, I get an error message in the "MOVEMENT" variable that says "Object doesn't exist." Thus, I was wondering how do I fix my game so that I don't get that message?
Here's the screenshot
http://authorhenryemphrey.tripod.com/gallery/
and below is how I have my game coded. I added notes in the code so that one can go straight to where I think the problem is.
Graphics 1640, 1000
SetBuffer BackBuffer ()
timer = CreateTimer(20)
;Loading and storing the images that the game will use
HENRY = LoadAnimImage ("Move2.png",400,370,0,13)
PLATFORM = LoadImage ("Platform.png")
DOOR = LoadImage ("Door.png")
BACKGROUND = LoadImage ("BackgroundTree.jpg")
BACKGROUND2 = LoadImage ("Spaceship.jpg")
MONSTER = LoadImage ("Ball.png")
;---------------------------------------------
;Setting the Fields
Type HENRY
Field x,y
Field frame
End Type
Type BACKGROUND
Field x,y
Field image
End Type
Type PLATFORM
Field x,y
Field image
End Type
Type MONSTER
Field x,y
Field image
End Type
Type DOOR
Field x,y
Field image
End Type
;----------------------------
;Setting the original names to variables
h.HENRY = New HENRY
h\x = 500
h\y = 300
h\frame = 0
b.BACKGROUND = New BACKGROUND
b\x = 150
b\y = 150
b\image = BACKGROUND
p.PLATFORM = New PLATFORM
p\x = 200
p\y = 370
p\image = PLATFORM
m.MONSTER = New MONSTER
m\x = 600
m\y = 200
m\image = MONSTER
d.DOOR = New DOOR
d\x = 200
d\y = -200
;-----------------------------
;Miscellaneous and accessories
MOVEMENT = 1
;-----------------------------------
;the game loop
While Not KeyDown(1)
Cls
;making it so that the player appears to move right
If KeyDown(205)
b\x = b\x - 3
h\frame = h\frame + 1
If h\frame > 2 Then
h\frame = 0
EndIf
EndIf
;making it so that the player appears to move left
If KeyDown(203)
b\x = b\x + 3
h\frame = h\frame + 1
If h\frame > 12 Then
h\frame = 6
EndIf
EndIf
;this allows the player to stand on the platform
If ImagesCollide(HENRY,h\x,h\y,0,PLATFORM,(b\x + p\x),p\y,0) Then
h\y = 300
Else
h\y = h\y + 10
EndIf
;this makes the player jump
If KeyHit (57)
h\y = h\y -200
EndIf
;this makes the player come back down after jumping (maybe this is gravity, I think)
If Not KeyHit (57)
h\y = h\y + 10
EndIf
;this makes the player (Henry) appear on screen
DrawImage (HENRY,h\x,h\y,h\frame)
;this makes the platform appear on screen
DrawImage (PLATFORM,(b\x + p\x),p\y)
;here's one of the problems. This is what makes the MONSTER move backwards and forward. But when the player collides with the door,
;there's an error message that says "Object does not exist." This this is the part that I need help with.
m\x = m\x + MOVEMENT
If m\x > 800 Then MOVEMENT = -MOVEMENT
If m\x < 700 Then MOVEMENT = 1
;this makes the Monster appear on screen
DrawImage (MONSTER,(b\x + m\x),m\y)
;this is the door that the player collides with. Again, here is part of the problem. When the player collides with the door, to exit
;to exit the scene, I get an error message above in my MOVEMENT variable. The error message says "Object does not exist." Thus,
;what do I do to fix this?
If (d <> Null) Then
DrawImage (DOOR,(b\x + d\x),d\y)
If ImagesCollide (HENRY,h\x,h\y,0,DOOR,(b\x + d\x),d\y,0) Then
Delete d
Delete m
b\image = BACKGROUND2
EndIf
EndIf
Flip
Thanks
|