Basic Parallax

Description: You made a script? Submit it here to show your creation to the public, share, take reviews, provision of the help and support is here!
Moderators: Yoshi021, Lx Xzit, 5438A38A, Moderators, Semi-moderatos

Yoshi021 M
Topic author, Moderator
Moderator
Avatar
Yoshi021 M
Topic author, Moderator
Moderator
Age: 23
Reputation: 170
Posts: 693
Joined: 15 Feb 2016
Location: Yoshi's Island

Post #1by Yoshi021 » 5 Jun 2018, 19:14

Hey, do you want a simple parallax that consists of a looping image, but using layer causes lag and is a bit tedious to set up? Then try Basic Parallax! This system is much less laggy and easier to set up at the expense of customization.

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
Image
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
Links
ImageImageImage
Image
Image
"Going to University is FUN!" :pardon:

Return to “Script submission”

Who is online (over the past 5 minutes)

Users browsing this forum: 2 guests