Parallax scrolling backgrounds.

A place for people with an interest in developing new shmups.
Post Reply
User avatar
Drum
Banned User
Posts: 2116
Joined: Sun Feb 07, 2010 4:01 pm

Parallax scrolling backgrounds.

Post by Drum »

Any good examples for Game Maker? I'd like the same scene to parallax horizontally and vertically.

Who better to demonstrate than Ulillillia:

http://www.youtube.com/watch?v=84M-0q5Dl84

If I can match that, I will be very happy.
IGMO - Poorly emulated, never beaten.

Hi-score thread: http://shmups.system11.org/viewtopic.php?f=2&t=34327
User avatar
S20-TBL
Posts: 440
Joined: Mon Jan 18, 2010 6:48 am
Location: Frying over a jungle and saving the nature
Contact:

Re: Parallax scrolling backgrounds.

Post by S20-TBL »

Hydorah, especially the Path of Scylla level.

Also, Nimbus Sky Princess.

From experience, it's harder to do multiple scrolling styles in a single level unless your background is tiled both vertically and horizontally, and your level design is planned out meticulously to the point where you know what type of scrolling to use and when. But it can be done.
--Papilio v0.9 Beta now on itch.io! (development thread)--
Xyga wrote:Blondest eyelashes ever.
User avatar
BarfHappy
Posts: 160
Joined: Fri Jan 14, 2011 11:20 pm
Location: In a CAVE

Re: Parallax scrolling backgrounds.

Post by BarfHappy »

I have absolutely no idea whatsoever of how works game maker.
So, hey, do your own backgrounds using sprites.
In a lot of arcade hardware you only get 2 tiled plans anyway, one is fix character plan for the UI the other is the background. To create multiple scrolling speed they either use raster effects (when the beam arrives at the end of a line, the game interrupts to a routine where you increase/decrease the position offset of the tiled background) or add sprites in front and back of the bg tile plan (usually even tiles plan can be made transparent).
Since raster interrupts are nice but not always apply (in verts, it s a mess, and is seldom used, except in few places like the sea in pink sweets and it looks bad), really, you are better served by yourself, and build your own background layers using sprites.

We live in a world where computing power do not matter anymore, so you can have thousands and thousands of quads at the same time on screen :p

Ho by the way, don t go too crazy on the multilayered scroll, it really kills readability even if it gives depth.
st5ex0boss/st5ex0boss.cpp, st5ex0boss/st5ex0b_appear.cpp, st5ex0boss/st5ex0b_disp.cpp, st5ex0boss/st5ex0b_move.cpp, st5ex0boss/st5ex0b_anime.cpp, st5ex0boss/st5ex0b_check.cpp

And there shall be TTLB... <3 Muwohohoho
User avatar
BPzeBanshee
Posts: 4859
Joined: Sun Feb 08, 2009 3:59 am

Re: Parallax scrolling backgrounds.

Post by BPzeBanshee »

By parallaxing horizontally and vertically are you talking like Thunder Force II? http://www.youtube.com/watch?v=dpHnBE5rFdY
User avatar
Drum
Banned User
Posts: 2116
Joined: Sun Feb 07, 2010 4:01 pm

Re: Parallax scrolling backgrounds.

Post by Drum »

S20-TBL wrote:Hydorah, especially the Path of Scylla level.

Also, Nimbus Sky Princess.

From experience, it's harder to do multiple scrolling styles in a single level unless your background is tiled both vertically and horizontally, and your level design is planned out meticulously to the point where you know what type of scrolling to use and when. But it can be done.
Sorry, by examples I meant actual gmk code I can use in my game. I am way too dumb and lazy to code this stuff myself, kekeke. I googled, and there are a few good examples of .gmk's with straight left-right parallax but that's all.

I'll need a generic algorithm because the game is not autoscrolling - the parallax scrolls along with the character in whatever direction the character is moving, like Ulilillia's. So if you go right, the bg objects go left at different speeds based on how close to the 'camera' they are, and if you go up, they drift apart - pretty much exactly like in the clip I posted. Another example: http://www.youtube.com/watch?v=TlXq9HDW ... re=related
BPzeBanshee wrote:By parallaxing horizontally and vertically are you talking like Thunder Force II? http://www.youtube.com/watch?v=dpHnBE5rFdY
Yessir, though it will look more like a platformer background, loosely similar to Bangaio: http://www.youtube.com/watch?v=zMJf2L5AA0g or Kolibri: http://www.youtube.com/watch?v=AxkvXu4Q5mE
I have absolutely no idea whatsoever of how works game maker.
So, hey, do your own backgrounds using sprites.
In a lot of arcade hardware you only get 2 tiled plans anyway, one is fix character plan for the UI the other is the background. To create multiple scrolling speed they either use raster effects (when the beam arrives at the end of a line, the game interrupts to a routine where you increase/decrease the position offset of the tiled background) or add sprites in front and back of the bg tile plan (usually even tiles plan can be made transparent).
Since raster interrupts are nice but not always apply (in verts, it s a mess, and is seldom used, except in few places like the sea in pink sweets and it looks bad), really, you are better served by yourself, and build your own background layers using sprites.

We live in a world where computing power do not matter anymore, so you can have thousands and thousands of quads at the same time on screen :p

Ho by the way, don t go too crazy on the multilayered scroll, it really kills readability even if it gives depth.
My game is sort of a special case. The levels are large and object-heavy, and it's not auto-scrolling so I can't just destroy stuff when it moves off-screen, meaning I gotta be careful about using objects.

I'm not tooooo worried about readability - I think Thunder Force IV is ok and that is around the level I'm aiming at (though scrolling will be a lot slower). bgs will be muted/darkened appropriately. I have yet to even draw mountain #1 so I can't give any examples of what I'm trying for just yet.
IGMO - Poorly emulated, never beaten.

Hi-score thread: http://shmups.system11.org/viewtopic.php?f=2&t=34327
User avatar
S20-TBL
Posts: 440
Joined: Mon Jan 18, 2010 6:48 am
Location: Frying over a jungle and saving the nature
Contact:

Re: Parallax scrolling backgrounds.

Post by S20-TBL »

Here's some old code I had for a platformer that's currently shelved.

Code: Select all

// This code sets the speeds at which the different background
// layers scroll, relative to both the view speed and the speed
// of the character being followed by the view. This technique
// is used to create a parallax scrolling effect. It is VITAL
// that this code be found in the Step event, since it takes
// priority over all other events coded into the object.

// Set the vertical scroll speeds of the background layers.
// To do this, we must utilize the gravity constant returned by
// the player object per step. Using the vspeed variable will
// only cause the background to wobble even though the view
// itself isn't moving.

background_y[0]=view_yview[0];
background_y[1]=(view_yview[0]-obj_char.gravity)/1.5;
background_y[2]=(view_yview[0]-obj_char.gravity)/2.5;
background_y[3]=(view_yview[0]-obj_char.gravity)/6;

// Set the horizontal scroll speeds of the background layers.
// To do this, we must utilize the hspeed variable returned by
// the player character's movement, since this too is programmed
// to change (normal walk and dash). Moreso if your character
// uses the hspeed and friction variables to accelerate, instead
// of changing the x-axis position like this game's character
// uses.

background_x[0]=view_xview[0];
background_x[1]=(view_xview[0]-obj_char.hspeed)/1.5;
background_x[2]=(view_xview[0]-obj_char.hspeed)/2.5;
background_x[3]=(view_xview[0]-obj_char.hspeed)/6;
You could technically use vspeed for the first set if your shooter is a bangaioh styled free-roaming arena shmup, but I haven't tried.

You could also use this code taken from the Zero Engine, which is more efficient as it uses view_xview and view_yview instead of tying the scrolling to the character movement:

Code: Select all

//draw_background_parallax(depth) //give credit to Ace

//Draws the backgrounds defined in the room with various parallax movements at a given depth.
//Leave argument0 blank to draw the backgrounds at default background depths.
//This script is for fast parallax prototyping. 
//Experiment with scroll speeds to achieve the effect you like.

if argument0=0 && depth=0 then depth=1000000

if background_exists(background_index[0]) then draw_background_tiled(background_index[0], view_xview[view_current]*1, view_yview[view_current]*1) //Distant BG 00 - Fixed Scroll

if background_exists(background_index[1]) then draw_background_tiled(background_index[1], view_xview[view_current]*0.985, view_yview[view_current]*0.998) //Distant BG 0 - Slowest Scroll...

if background_exists(background_index[2]) then draw_background_tiled(background_index[2], view_xview[view_current]*0.90, view_yview[view_current]*0.90)//Distant BG 1

if background_exists(background_index[3]) then draw_background_tiled(background_index[3], view_xview[view_current]*0.80, view_yview[view_current]*0.85) //Closer BG 2

if background_exists(background_index[4]) then draw_background_tiled(background_index[4], view_xview[view_current]*0.70, view_yview[view_current]*0.80) //Even Closer BG 3

if background_exists(background_index[5]) then draw_background_tiled(background_index[5], view_xview[view_current]*0.45, view_yview[view_current]*0.70) //Really Close BG 4

if background_exists(background_index[6]) then draw_background_tiled(background_index[6], view_xview[view_current]*0.20, view_yview[view_current]*0.55) //Closest BG 5 - Fastest Scroll...
--Papilio v0.9 Beta now on itch.io! (development thread)--
Xyga wrote:Blondest eyelashes ever.
User avatar
Drum
Banned User
Posts: 2116
Joined: Sun Feb 07, 2010 4:01 pm

Re: Parallax scrolling backgrounds.

Post by Drum »

Thanks, that is exactly the sort of thing I am looking for. Can't get that Zero Engine to run in GM8, unfortunately (which is a shame, because there is an awful lot of stuff I'd like to swipe from that) - what on earth am I meant to be deleting? I fixed the name of that script but I have no idea what to do with those /'s. Bah. Sorry, not your problem.
IGMO - Poorly emulated, never beaten.

Hi-score thread: http://shmups.system11.org/viewtopic.php?f=2&t=34327
User avatar
S20-TBL
Posts: 440
Joined: Mon Jan 18, 2010 6:48 am
Location: Frying over a jungle and saving the nature
Contact:

Re: Parallax scrolling backgrounds.

Post by S20-TBL »

Drum wrote:Thanks, that is exactly the sort of thing I am looking for. Can't get that Zero Engine to run in GM8, unfortunately (which is a shame, because there is an awful lot of stuff I'd like to swipe from that) - what on earth am I meant to be deleting? I fixed the name of that script but I have no idea what to do with those /'s. Bah. Sorry, not your problem.
I got confused by that too, but actually to get the Zero Engine to run, you need to find and delete the rpgmaker_char script, then rename the rpgmaker_char_GM8 script to match the one you deleted.

The //s are used to comment out lines in the code, don't touch them if you don't want the code to crash.
--Papilio v0.9 Beta now on itch.io! (development thread)--
Xyga wrote:Blondest eyelashes ever.
User avatar
BPzeBanshee
Posts: 4859
Joined: Sun Feb 08, 2009 3:59 am

Re: Parallax scrolling backgrounds.

Post by BPzeBanshee »

S20-TBL wrote:
Drum wrote:Thanks, that is exactly the sort of thing I am looking for. Can't get that Zero Engine to run in GM8, unfortunately (which is a shame, because there is an awful lot of stuff I'd like to swipe from that) - what on earth am I meant to be deleting? I fixed the name of that script but I have no idea what to do with those /'s. Bah. Sorry, not your problem.
I got confused by that too, but actually to get the Zero Engine to run, you need to find and delete the rpgmaker_char script, then rename the rpgmaker_char_GM8 script to match the one you deleted.

The //s are used to comment out lines in the code, don't touch them if you don't want the code to crash.
I investigated the Zero Engine for its scrolling text functions while trying to find such for GMOSSE and gave up on it. The engine in GM8 has so many bugs even after you deal with the rpgmaker_char object that it's a waste of time trying to get anything serious out of it.
If platformers is your thing I would strongly recommend Hello Engine IV. Should be easy enough to find via Google, and Alluro uses it as a base for Super Mario Fusion Revival if memory serves. Being a Mario engine it should have some parallax scrolling around here and there but I can't precisely recall any spots.
User avatar
Drum
Banned User
Posts: 2116
Joined: Sun Feb 07, 2010 4:01 pm

Re: Parallax scrolling backgrounds.

Post by Drum »

BPzeBanshee wrote:
S20-TBL wrote:
Drum wrote:Thanks, that is exactly the sort of thing I am looking for. Can't get that Zero Engine to run in GM8, unfortunately (which is a shame, because there is an awful lot of stuff I'd like to swipe from that) - what on earth am I meant to be deleting? I fixed the name of that script but I have no idea what to do with those /'s. Bah. Sorry, not your problem.
I got confused by that too, but actually to get the Zero Engine to run, you need to find and delete the rpgmaker_char script, then rename the rpgmaker_char_GM8 script to match the one you deleted.

The //s are used to comment out lines in the code, don't touch them if you don't want the code to crash.
I investigated the Zero Engine for its scrolling text functions while trying to find such for GMOSSE and gave up on it. The engine in GM8 has so many bugs even after you deal with the rpgmaker_char object that it's a waste of time trying to get anything serious out of it.
If platformers is your thing I would strongly recommend Hello Engine IV. Should be easy enough to find via Google, and Alluro uses it as a base for Super Mario Fusion Revival if memory serves. Being a Mario engine it should have some parallax scrolling around here and there but I can't precisely recall any spots.
Hello Engine is a great piece of work, and I can see myself using a lot of code from it, but I'm not seeing anything at all in the way of parallax effects. I think Zero Engine might be the way to go, at least for those few lines of code - I have my own engine that's a variation of pgil's (http://pgilfarmer.blogspot.com/) procedural level generator.
IGMO - Poorly emulated, never beaten.

Hi-score thread: http://shmups.system11.org/viewtopic.php?f=2&t=34327
User avatar
Sumez
Posts: 8778
Joined: Fri Feb 18, 2011 10:11 am
Location: Denmarku
Contact:

Re: Parallax scrolling backgrounds.

Post by Sumez »

The theory of parallax is extremely simple, and with today's technology obviously not very demanding at all.

Simply assign a "z level" value to each background layer, and when applying the scroll to both the X and Y coordinate of the texture, simply multiply by the z level value (ie. with a z level of 0.5 the layer will only scroll half as fast as the "main" layer (ie. the one that controls the scrolling/the one where the player character is located - this one has z level 1). Layers that are really far away, such as the sun or the moon, etc. would have a value of 0 or almost 0 so they won't appear to be scrolling at all.

And of course, in order to make a level in front of the main layer (clouds, trees, etc.) just assign it a z level value higher than 1.
Post Reply