Animated BGLayer / Entity with XRatio Movement

maxman

Well-known member
As the title says so, I wonder how I could make an entity move like xratio or have a bglayer animated like you set xratio to make it move. I'm not talking about panel level or entity. I tried using panel and none types with the scroll but it seems it always goes along with panel in level. I get confused of how much decimals to make in order to follow the same exact movement.

scroll {value}

    ~Used to make non panel typed entities scroll like panel type.
    ~{value} is in decimals.

How could I make an animated bglayer or entity move the same way as the certain xratio?
 
Damon Caskey: Hi, DC. I'm sorry for not showing some indications on what I got for the entity. I have the panel entity and the bglayer set with the same xratio movement in good rhythm like before (back to getting it fixed), but what I'm always having trouble is that every time 2 characters walk together while scrolling, the panel entity shakes left and right in one pixel, looking like it's cut off and going back. (I knew speedf is 10 times faster than speed.)

Code:
name	ele01
type	panel
#speed 6.38
speedf 0.638
#palette none
subject_to_minz 0
noquake 1 1 #noquake {bi 1} {bi 2} bi 1 is for shaking effect of the screen; bi 2 is for shaking effect of this entity
#offscreenkill 99999
#scroll 0 #-0.275

anim spawn
	delay	1
	offset	1 84
	frame	data/bgs/dhalsim/dhalsim.pcx00020000.png

anim idle
	loop	1
	delay	30
	offset	1 84
	frame	data/bgs/dhalsim/dhalsim.pcx00020000.png
	frame	data/bgs/dhalsim/dhalsim.pcx00020001.png
	frame	data/bgs/dhalsim/dhalsim.pcx00020002.png
	frame	data/bgs/dhalsim/dhalsim.pcx00020001.png
	delay	200
	frame	data/bgs/dhalsim/dhalsim.pcx00020000.png

anim follow1
	loop	1
	delay	45
	offset	1 84
	frame	data/bgs/dhalsim/dhalsim.pcx00020000.png
	frame	data/bgs/dhalsim/dhalsim.pcx00020001.png
	frame	data/bgs/dhalsim/dhalsim.pcx00020002.png
	frame	data/bgs/dhalsim/dhalsim.pcx00020001.png
	delay	194
	frame	data/bgs/dhalsim/dhalsim.pcx00020000.png

One level txt:
Code:
background	data/bgs/dhalsim/back.png  #0 0 0 0 1 1 10 1 1 0 0 0 0 0 0
#bglayer path xratio zratio xposition zposition xspacing zspacing xrepeat zrepeat transparency alpha watermode(1) amplitude wavelength wavespeed 
#bglayer path xratio zratio xposition zposition xspacing zspacing xrepeat zrepeat transparency alpha watermode(3) beginsize endsize perspective


#0.638; 0.637 = 1; 0.635 = 2; 0.634 = 3; 0.633 = 4; 0.632 = 5; 0.63 = 6
bglayer	data/bgs/dhalsim/dhalsim.pcx00000000.png 0.638 0 0 0 1 1 1 1 1 0 0 0 0 0 0
bglayer	data/bgs/dhalsim/dhalsim.pcx00010000.png 0 0 0 176 0 0 2 1 0 0 3 0.5 1 0 0
panel		data/bgs/dhalsim/panello1.png
#panel		data/bgs/dhalsim/dhalsim.pcx00000000.png

direction		both
light  		10   -30
at		0
settime 0
notime 1
order		a
#scrollspeed	15

spawn	ele01
@script
void main(){
	void self = getlocalvar("self");
	changeentityproperty(self, "direction", 1);
}
@end_script
coords 385 162
at 0

spawn	ele01
@script
void main(){
	void self = getlocalvar("self");
	changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
}
@end_script
coords 769 162
at 0
 
maxman said:
Hi, DC. I'm sorry for not showing some indications on what I got for the entity. I have the panel entity and the bglayer set with the same xratio movement in good rhythm like before (back to getting it fixed), but what I'm always having trouble is that every time 2 characters walk together while scrolling, the panel entity shakes left and right in one pixel, looking like it's cut off and going back

Hello, did you found a fix for this?

Im having the same problem
 
but what I'm always having trouble is that every time 2 characters walk together while scrolling, the panel entity shakes left and right in one pixel, looking like it's cut off and going back
Hum, I think I already saw something like this on my game too.
 
Hello, did you found a fix for this?

Im having the same problem
I just did find out about it recently. What I found out is that if the background layer size is irregular, like the total size of the bg layer is 621 pixels wide, for instance, I think it looks like it's cut off with one pixel. It's because the image of the background layer has to be the width which is a multiple of 4. Also, if bglayer is either bigger or smaller than that size, that can make that image go one pixel off while scrolling. You have to make the same size of that image if you want to avoid getting one pixel off from the other bglayer. I highlighted the second line of the explanation in bold font about the width of the image.

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).

The scrolling also should be the same, as well as positions and stuff for (b/f)g layers.

Code:
#### PLEASE USE BOTH THESE IMAGES AS HUD FOR YOUR PLAYER(S) UNLESS IT'S BONUS STAGE #######
fglayer data/sprites/hud_base.png -1 1 0 3 3 1 1 1 1 1 0 0 0 0 0 0
fglayer data/sprites/hud.png -1 1 0 3 3 1 1 1 1 1 0 0 0 0 0 0
###########################################################################################
fglayer data/bgs/dhalsim/dhal000.png -73 0.638 0 0 0 1 1 1 1 1 0 0 0 0 0 0  # 2
fglayer data/bgs/dhalsim/dhal001.png -73 0.638 0 0 0 1 1 1 1 1 0 0 0 0 0 0   # 3
fglayer data/bgs/dhalsim/dhal002.png -73 0.638 0 0 0 1 1 1 1 1 0 0 0 0 0 0  # 4
fglayer data/bgs/dhalsim/dhal001.png -73 0.638 0 0 0 1 1 1 1 1 0 0 0 0 0 0  # 5
fglayer data/bgs/dhalsim/dhal000.png -73 0.638 0 0 0 1 1 1 1 1 0 0 0 0 0 0  # 6
fglayer data/bgs/dhalsim/dhal000.png -73 0.638 0 0 0 1 1 1 1 1 0 0 0 0 0 0  # 7
fglayer data/bgs/dhalsim/dhal000.png -73 0.638 0 0 0 1 1 1 1 1 0 0 0 0 0 0  # 8
fglayer data/bgs/dhalsim/dhal000.png -73 0.638 0 0 0 1 1 1 1 1 0 0 0 0 0 0  # 9
###########################################################################################
bglayer    data/bgs/dhalsim/dhalsim.pcx00000000.png   0.638 0 0 0 1 1 1 1 1 0 0 0 0 0 0 # Wall

background    data/bgs/dhalsim/back.png  #0 0 0 0 1 1 10 1 1 0 0 0 0 0 0
#bglayer path xratio zratio xposition zposition xspacing zspacing xrepeat zrepeat transparency alpha watermode(1)

amplitude wavelength wavespeed
#bglayer path xratio zratio xposition zposition xspacing zspacing xrepeat zrepeat transparency alpha watermode(3)

beginsize endsize perspective
#bglayer    data/bgs/dhalsim/dhalsim.pcx00010000.png   0 0 -150 176 0 0 2 1 0 0 3 0.5 2 0

updatescript data/bgs/dhalsim/dhalsim.c

#bglayer    data/bgs/dhalsim/panel.png 0 0 -264 176 0 0 3 1 0 0 3 0 0 2
#bglayer    data/bgs/dhalsim/dhalsim.pcx00010000.png   0 0 0 176 0 0 2 1 0 0 3 0 1 0

# xratio/zratio - 0.5 same scroll like background; 1 same scroll like panel
# panel type entity - 10 times xratio or zratio speed for background if speed is 5; e.g. speed 5 type panel - move like

background

#bglayer 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# 0 - path
# 1 - xratio
# 2 - zratio
# 3 - xposition
# 4 - zposition
# 5 - xspacing
# 6 - zspacing
# 7 - xrepeat
# 8 - zrepeat
# 9 - transparency
# 10 - alpha
# 11 - watermode (if set to 3, next 3 parameters become beginsize, endsize and perspective; if set to 1, water effect

will play)
# 12 - amplitude (if watermode set to 1, not 3) / beginsize (if watermode set to 3, not 1)
# 13 - wavelength (if watermode set to 1, not 3) / endsize (if watermode set to 3, not 1)
# 14 - wavespeed (if watermode set to 1, not 3) / perspective (if watermode set to 3, not 1)
# 15 - bgspeedratio

# In perspective mode
#~{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).

panel        data/bgs/dhalsim/panello.png
#panel        data/bgs/dhalsim/panel01.png
#panel        data/bgs/dhalsim/dhalsim.pcx00000000.png

direction        both
light          10   -30
at        0
settime 0
notime 1
order        a
#scrollspeed    15

Here is an example in the attachment. You can reverse that image as mirroring in code if you want to make a panel or none type entity for scrolling (I guess), but in level use, you cannot. Yes, they have the same size.
 

Attachments

  • dhal000.png
    dhal000.png
    3.4 KB · Views: 3
  • dhalsim.pcx00000000.png
    dhalsim.pcx00000000.png
    16.2 KB · Views: 3
Last edited:
Back
Top Bottom