HOW TO USE :?:
First create the bitmap images. The bitmap MUST:
- Level Oriented
- Have a size of 1600 and 1200
Variables: prevCamX, prevCamY, camSpX, camSpY, and i must exist.
The image must be set up like this
The image has to be duplicated 4 times in a grid for the parallax to loop correctly (The black square must be copied over the red squares)
Code: Select all
'===PARALLAX ==='
call BmpCreate(1, 1, 1, 1, 0, 0, 1600, 1200, 0, 0, 1, 1, 800, 600, 0, -1)
Bitmap(1).zpos = 0.9 'Set the bitmap as background
v(prevCamX) = sysval(player1scrx)
v(prevCamY) = sysval(player1scry)
call sleep(1)
do
v(camSpX) = sysval(player1scrx) - v(prevCamX)
v(camSpY) = sysval(player1scry) - v(prevCamY)
'Edit the X and Y speeds by changing the last number
Bitmap(1).destx = Bitmap(1).destx + v(camSpX)*(0.5)
Bitmap(1).desty = Bitmap(1).desty + v(camSpY)*(-2)
for v(i) = 1 to 0 'CHANGE THE 0 TO THE NUMBER OF BITMAPS THE PARALLAX USES
with Bitmap(v(i))
if .destx > 0 then
.destx = .destx - 800
elseif .destx < -800 then
.destx = .destx + 800
end if
if .desty > 0 then
.desty = .desty - 600
elseif .desty < -600 then
.desty = .desty + 600
end if
end with
next
v(prevCamX) = sysval(player1scrx)
v(prevCamY) = sysval(player1scry)
call sleep(1)
loop
EXAMPLE: https://cdn.discordapp.com/attachments/3816559699 ... 07289947775565835/Parallax.zip