I was wondering what do I do if I wanted the background to stop scrolling at a specific point. That is, after the character collides with a post, I want the background to become a still screen.
Hence, I guess my other question is how do I stop a keydown command (or commands like this) and go back to such again if I need it? At first, I tried the Function, and Goto commands, but maybe I had something missing form the code when I tried it.
Below is a condensed example with notes on what I'm trying to do now.
Graphics 1640, 1000
SetBuffer BackBuffer ()
;----------------------------------------------------------------------------
;Load Items
HENRY = LoadAnimImage ("Move2.png",400,370,0,13)
BACKGROUND = LoadImage ("BackgroundTree.jpg")
BACKGROUND2 = LoadImage ("Spaceship.jpg")
PLATFORM = LoadImage ("Big Platform2.png")
POST = LoadImage ("Border.png")
Type HENRY
Field x,y
Field frame
End Type
Type POST
Field x,y
End Type
Type BACKGROUND
Field x,y
Field image
End Type
Type PLATFORM
Field x,y
End Type
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 = 100
p\y = 300
pst.POST = New POST
pst\x = 800
pst\y = 180
While Not KeyDown(1)
Cls
TileImage (b\image,b\x,b\y)
;after my character gets to this post, I was trying to make it so that the background doesn't scroll anymore (see keydown)
If (pst <> Null) Then
DrawImage (POST,(b\x + pst\x),pst\y)
If ImagesCollide (HENRY,h\x,h\y,0,POST,pst\x,pst\y,0) Then
EndIf
EndIf
If KeyDown (57)
h\y = h\y -80
EndIf
If Not KeyHit (57)
h\y = h\y + 10
EndIf
;I'm trying to stop the b\x = b\x - 3 in the Keydown (205) section,
; and the b\x = b\x + 3 in Keydown (203) section after my
; character collides with the post.
If KeyDown(205)
b\x = b\x - 3
h\frame = h\frame + 1
If h\frame > 2 Then
h\frame = 0
EndIf
EndIf
If KeyDown(203)
b\x = b\x + 3
h\frame = h\frame + 1
If h\frame > 12 Then
h\frame = 6
EndIf
EndIf
DrawImage (HENRY,h\x,h\y,h\frame)
DrawImage (PLATFORM,(b\x + p\x),p\y)
If ImagesCollide(HENRY,h\x,h\y,0,PLATFORM,(b\x + p\x),p\y,0) Then
h\y = 310
Else
h\y = h\y + 10
EndIf
Flip
Wend
|