Heres the quick example:
SuperStrict
Const screenwidth:Int = 800
Const screenheight:Int = 600
Graphics screenwidth,screenheight,0
Global fighterImage:TImage = LoadImage("fighter.png")
Global bgimage:TImage = LoadAnimImage("bg.png" , 100 , 100 , 0 , 48)
Global bg1image:TImage = LoadAnimImage("bg1.png" , 100 , 100 , 0 , 48)
Global bg2image:TImage = LoadAnimImage("bg1.jpg" , 100 , 100 , 0 , 48)
Global bgTiles:Int[8 , 6]
Global bg1Tiles:Int[8 , 6]
Global bg2Tiles:Int[8 , 6]
Global counter:Int = 0
Global bx# = 0 , bx1# = 0, bx2# = 0
Global px# = 100 , py# = 100
Global dx# = 0 , dy# = 0
For Local j:Int = 0 To 5
For Local i:Int = 0 To 7
bgTiles[i , j] = counter
bg1Tiles[i , j] = counter
bg2Tiles[i , j] = counter
counter:+1
Next
Next
While KeyDown(KEY_ESCAPE) = False
logic()
draw()
Wend
Function logic()
controlFighter()
moveBackground()
End Function
Function draw()
Cls
drawBackgrounds()
drawFighter()
Flip
End Function
Function controlFighter()
Local eex:Float
Local eey:Float
Local ddx:Float
Local ddy:Float
Local speed:Float = 0.2
eex = MouseX()
eey = MouseY()
ddx = (eex - px)
ddy = (eey - py)
Local dist:Float = Sqr(ddx * ddx + ddy * ddy)
ddx:/dist * speed
ddy:/dist * speed
dx = ddx
dy = ddy
If PointInSpot(px, py, eex, eey, 3) Then
dx = 0; dy = 0
End If
px:+dx
py:+dy
End Function
Function drawFighter()
DrawImage fighterImage, px, py
End Function
Function moveBackground()
bx:- 2
bx1:- 1
bx2:- 0.5
If bx < - screenwidth bx = 0
If bx1 < - screenwidth bx1 = 0
If bx2 < - screenwidth bx2 = 0
End Function
Function drawBackgrounds()
For Local i:Int = 0 To 7
For Local j:Int = 0 To 5
DrawImage bg2image, bx2 + i * 100, j * 100, bgTiles[i, j]
DrawImage bg2image, bx2 + screenwidth + i * 100, j * 100, bgTiles[i, j]
Next
Next
For Local i:Int = 0 To 7
For Local j:Int = 0 To 5
DrawImage bg1image, bx1 + i * 100, j * 100, bgTiles[i, j]
DrawImage bg1image, bx1 + screenwidth + i * 100, j * 100, bgTiles[i, j]
Next
Next
For Local i:Int = 0 To 7
For Local j:Int = 0 To 5
DrawImage bgimage , bx + i * 100 , j * 100 , bgTiles[i , j]
DrawImage bgimage, bx + screenwidth + i * 100, j * 100, bgTiles[i, j]
Next
Next
End Function
Function PointInSpot:Int(x1:Float, y1:Float, x2:Float, y2:Float, radius:Float)
Local dx:Float = x2 - x1
Local dy:Float = y2 - y1
Return Sqr(dx * dx + dy * dy) <= radius
EndFunction
http://therevillsgames.googlepages.com/parallax.zipIts a lot smoother in GA's Framework ;-)