single sprite parallax effect?

PS_VITA

Active member
https://youtu.be/7unDOJza434?t=148
Hi guys - how can I make a single lamp post as seen in that streets of rage video appear to be in front of everything and parallax move
with the character whenever he moves forward or backwards.

My current code is this (
Code:
data/levels/stage1/front_lamp.gif 0.1 0 0 0
)
but the problem is that I have to make an entire gif the size of the entire stage just to have one lamppost show up near the beginning of the stage, seems rather wasteful of both size and optimizing the game.

Are there any other more ways to do this?
 
use  fglayer

from the manual

fglayer {path} {z} {xratio} {zratio} {xposition} {zposition} {xspacing} {zspacing} {xrepeat} {zrepeat} {transparency} {alpha} {watermode} {amplitude} {wavelength} {wavespeed} {bgspeedratio}

This is for setting custom foreground layer in current level.
{path} is the location relative to data folder where the graphic is
Just like any image used by OpenBoR, fglayers must use paletted images. In 8 bit colourdepth (default), it must use same palette as 'background' (see above). In 16/32 bit, it can use different palette
Beware though, if bglayers use different palette than background, 'palette' command (see below) won't work
{z} sets location of the layer. Give positive value to make it closer to screen or negative value to make it farther from screen.
Other parameters ( {xratio}, {zratio}, {xposition}, {zposition}, {xspacing}, {zspacing}, {xrepeat}, {zrepeat}, {transparency}, {alpha} and {bgspeedratio} ) have same effect like in 'bglayer' above.
Currently {watermode}, {amplitude}, {wavelength} and {wavespeed} aren't working. Still, you need to fill them if you want to set {bgspeedratio}.


heres an example from one of my mods



#                                                  {z}    {xratio}  {zratio} {xposition} {zposition} {xspacing} {zspacing} {xrepeat} {zrepeat} {transparency}
fglayer    data/bgs/lev0/ff.gif  200  -0.1            0                0                -8                0                0                -1              1                1
 
Currently {watermode}, {amplitude}, {wavelength} and {wavespeed} aren't working. Still, you need to fill them if you want to set {bgspeedratio}.

danno, which manual are you quoting? That bit about watermode not working isn't correct at all and needs an update. Watermode works perfectly with fglayer, and it's one of the more powerful uses of it.

DC
 
http://www.chronocrash.com/apps/wiki/obor/index.php?title=OpenBOR_Legacy_Manual

Now I know it works I can add a little more spice to my level  8)
 
danno said:
use  fglayer

from the manual

fglayer {path} {z} {xratio} {zratio} {xposition} {zposition} {xspacing} {zspacing} {xrepeat} {zrepeat} {transparency} {alpha} {watermode} {amplitude} {wavelength} {wavespeed} {bgspeedratio}

This is for setting custom foreground layer in current level.
{path} is the location relative to data folder where the graphic is
Just like any image used by OpenBoR, fglayers must use paletted images. In 8 bit colourdepth (default), it must use same palette as 'background' (see above). In 16/32 bit, it can use different palette
Beware though, if bglayers use different palette than background, 'palette' command (see below) won't work
{z} sets location of the layer. Give positive value to make it closer to screen or negative value to make it farther from screen.
Other parameters ( {xratio}, {zratio}, {xposition}, {zposition}, {xspacing}, {zspacing}, {xrepeat}, {zrepeat}, {transparency}, {alpha} and {bgspeedratio} ) have same effect like in 'bglayer' above.
Currently {watermode}, {amplitude}, {wavelength} and {wavespeed} aren't working. Still, you need to fill them if you want to set {bgspeedratio}.


heres an example from one of my mods



#                                                  {z}    {xratio}  {zratio} {xposition} {zposition} {xspacing} {zspacing} {xrepeat} {zrepeat} {transparency}
fglayer    data/bgs/lev0/ff.gif  200  -0.1            0                0                -8                0                0                -1              1                1

Thank you Danno! I copied pasted your example and it worked right away - I'm just trying to figure out how to stop repeating it so much. :)

Danno, do you also know if I can adjust  fglayer to be behind my panel (main stage background) for a different single  sprite lamp post that goes behind the panel (main stage background).
 
turn the repeat off  {xrepeat} {zrepeat} 
                                          0              0

ChronoCrash said:
Danno, do you also know if I can adjust  fglayer to be behind my panel (main stage background) for a different single  sprite lamp post that goes behind the panel (main stage background).

fglayer is for foreground use bglayer for background stuffs
 
danno said:
turn the repeat off  {xrepeat} {zrepeat} 
                                          0              0

ChronoCrash said:
Danno, do you also know if I can adjust  fglayer to be behind my panel (main stage background) for a different single  sprite lamp post that goes behind the panel (main stage background).

fglayer is for foreground use bglayer for background stuffs

so in theory I could just copy and past the same code - change the f letter to b in fglayer and adjust my lamp post correct?
(I will test this when I get home )
 
danno said:
fglayer is for foreground use bglayer for background stuffs

Noooooooo! Seriously, fglayer is not for foreground only. It's essentially a newer, better bglayer. Bglayer is always behind the panel layer and when there's more than one are just drawn in order you declare them.

Fglayer adds a Z position adjustment. It defaults to being in front of the panel, but you can put the fglayer exactly where you want it in relation to other layers, panels, entities, and so on. It's much more versatile.

DC
 
I see, I assumed he wanted another sprite behind the panel in the background and no need for z adjusting considering the example he gave, my bad for not explaining how versatile fglayer can be.  :o

ChronoCrash said:
same code - change the f letter to b in fglayer and adjust my lamp post correct?
(I will test this when I get home )

nope they have similar but different parameters

Code:
bglayer {path} {xratio} {zratio} {xposition} {zposition} {xspacing} {zspacing} {xrepeat} {zrepeat} {transparency} {alpha} {watermode} {amplitude} {wavelength} {wavespeed} {bgspeedratio}

background {path} {xratio} {zratio} {xposition} {zposition} {xspacing} {zspacing} {xrepeat} {zrepeat} {transparency} {alpha}

These 2 command have same effect which is create a background layer with the image at {path}.
The image used must have a width which is a multiple of 4 (ex. 4, 200, 128, not 3, 202, 130).
The height could be any size but make sure it matches screen resolution to avoid void background areas.
Just like any image used by OpenBoR, background and bglayers must use paletted images. In 8 bit colourdepth (default), it must use same palette as 'background' (see above). In 16/32 bit, it can use different palette
Beware though, if bglayers use different palette than background, 'palette' command (see below) won't work
The graphic automatically repeats if the stage is longer than the background.
Layers are drawn in the order they are defined; currently, up to 100 are supported. However 'background' sets the bottommost layer while 'bglayer' sets layers in front of it.
{xratio} and {zratio} determine how fast the layer will scroll; 1 = same scroll speed as panel, 0.5 = same as background, any float value can be used for them. It works also in levels with direction up or down but the layers will autoscroll just like background.
{xposition} and {zposition} determine where the top left corner of the first layer will be. {xposition} is measured from left for direction right levels, from right for direction left, from bottom for direction up and from top for direction down levels.
{xspacing} and {zspacing} determine how how much blank space there will be between repeated layers. Only works if you set repeating layers (see below).
{xrepeat} and {zrepeat} determine how many times the image will repeat. Setting 0 will make layer not drawn at all (it will become palette holder). Setting -1 will make it repeat forever
use 1 for {transparency} to have your transparency color not appear. Remember that this is more processor intensive, so don't use it on images that won't benefit from it. And don't use it for 'background' too since it's the bottommost layer. In 16/32 bit mode, pure black color will be used instead.
{alpha} will display the image using alpha transparency. It works just like for entities. Possible values are 0 to 6. Don't use it for background too.
{watermode} determines water effect. Currently there are 3 modes.
0 = No water effect for this bglayer
1 = Water effect for this bglayer is on
3 = Mode 7 effect
{amplitude} determines the amplitude of sine wave for water effect. Only apply if {watermode} is not 3 (see below)
{wavelength} determines length of sine wave in pixels. It's repeated since it's sine wave. Only apply if {watermode} is not 3 (see below)
{wavespeed} determines the moving speed of sine wave. Only apply if {watermode} is not 3 (see below)
When {watermode} is set to 3, the next 3 parameters ( {amplitude} {wavelength} {wavespeed} ) becomes new ones: {beginsize} {endsize} {perspective}
{beginsize} and {endsize} defines size multiplier of upper and lower border
respectively. The upper border should be smaller than lower one cause the former is farther

{perspective} defines z depth effect it should have
0 = No effect (default)
1 = Perspective & tile
2 = Perspective & stretch
{bgspeedratio} determines the moving ratio of this bglayer relative to main background. Defaults to 0 (no movement).

Or as Damon states use fglayer and adjust z
 
Sorry to be such a newb - as I'm now more confused than ever  :'( - could some give me an actual example of what the code would look like for say a room that's 1257 Wide and 478 high (pixels) and this room happens to have two lamp post  ( one in the foreground and one in the background behind the main stage road) using this piece of code
Code:
#{z}     {xratio}  {zratio} {xposition} {zposition} {xspacing} {zspacing} {xrepeat} {zrepeat} {transparency}
fglayer    data/bgs/lev0/ff.gif   0 0 0 0 0 0 0 0 0 0
 
tkDYcHR.jpg


This is an example of how I'd set it up, pay attention to the first couple parameters z, xratio, zratio, xposition, zposition spend some time adjusting these to see what fits best on your screen bare in mind repeat x, z and transparency. I don't have time to explain more right now, I'll check back in the morning to see how you've progressed.
 
ChronoCrash said:
Sorry to be such a newb - as I'm now more confused than ever  :'( - could some give me an actual example of what the code would look like for say a room that's 1257 Wide and 478 high (pixels) and this room happens to have two lamp post  ( one in the foreground and one in the background behind the main stage road) using this piece of code
Code:
#{z}     {xratio}  {zratio} {xposition} {zposition} {xspacing} {zspacing} {xrepeat} {zrepeat} {transparency}
fglayer    data/bgs/lev0/ff.gif   0 0 0 0 0 0 0 0 0 0

download the BOrlab thing i made & you can see the values of different parallax layers - i may not have used Fglayer, but the values are similar

its the second post:
http://www.chronocrash.com/forum/index.php?topic=4686.msg69336#msg69336

Damon Caskey
I think i found away to animate Fglayer - the same way some MUGEN levels do it:
say you have a FGlayer that is supposed to have 3 frames of animation, what you do is overlay the 3 layers & then with script,
you make the other 2 disappear or have 100% opacity while one is active

so let's say you have a layer with walls that light up red green & yellow, the script has to make the red FGlayer  visible while  fglayer 2 & 3 are invisible, & then fglayer 2 turns visible while fglayer 3 & 1 become invisible

i know that entities can take care of this, but if you need an infinite autos-crolling type of layer this method would work best...
 
danno said:
tkDYcHR.jpg


This is an example of how I'd set it up, pay attention to the first couple parameters z, xratio, zratio, xposition, zposition spend some time adjusting these to see what fits best on your screen bare in mind repeat x, z and transparency. I don't have time to explain more right now, I'll check back in the morning to see how you've progressed.

Wow! thank you for the illustration - you went above and beyond :)

All working now except I'm a process of trial and error trying to get the background lamp post to show behind the panel (street)
I put -900 and it disappeared - If only If knew the value of the z of the panel I would have been done by now.

EDIT: I figured it out already :) thank you Danno! - thank all of you guys.





oldyz said:
ChronoCrash said:
Sorry to be such a newb - as I'm now more confused than ever  :'( - could some give me an actual example of what the code would look like for say a room that's 1257 Wide and 478 high (pixels) and this room happens to have two lamp post  ( one in the foreground and one in the background behind the main stage road) using this piece of code
Code:
#{z}     {xratio}  {zratio} {xposition} {zposition} {xspacing} {zspacing} {xrepeat} {zrepeat} {transparency}
fglayer    data/bgs/lev0/ff.gif   0 0 0 0 0 0 0 0 0 0

download the BOrlab thing i made & you can see the values of different parallax layers - i may not have used Fglayer, but the values are similar

its the second post:
http://www.chronocrash.com/forum/index.php?topic=4686.msg69336#msg69336

Damon Caskey
I think i found away to animate Fglayer - the same way some MUGEN levels do it:
say you have a FGlayer that is supposed to have 3 frames of animation, what you do is overlay the 3 layers & then with script,
you make the other 2 disappear or have 100% opacity while one is active

so let's say you have a layer with walls that light up red green & yellow, the script has to make the red FGlayer  visible while  fglayer 2 & 3 are invisible, & then fglayer 2 turns visible while fglayer 3 & 1 become invisible

i know that entities can take care of this, but if you need an infinite autos-crolling type of layer this method would work best...
This is beyond cool, nice work!
 
Damon Caskey said:
danno said:
fglayer is for foreground use bglayer for background stuffs

Noooooooo! Seriously, fglayer is not for foreground only. It's essentially a newer, better bglayer. Bglayer is always behind the panel layer and when there's more than one are just drawn in order you declare them.

Fglayer adds a Z position adjustment. It defaults to being in front of the panel, but you can put the fglayer exactly where you want it in relation to other layers, panels, entities, and so on. It's much more versatile.

DC
Man I'm so friggin behind on new updates to the engine, I didn't even know FGlayer was a thing. Will have to keep this in mind, not that I need it or even if I know I do, but just to use if it makes for some cool effects.

X)
 
Back
Top Bottom