YesNoOk
avatar

Background controllers (Stages) (Read 2913 times)

Started by Just No Point, November 03, 2015, 05:09:47 pm
Share this topic:
Background controllers (Stages)
#1  November 03, 2015, 05:09:47 pm
  • ******
    • www.justnopoint.com/
Background controllers operate on an internal timer that starts at 0 when the round starts, and increases by 1 for every game tick. When the timer reaches the controller's start time, then the controller becomes active. When the timer reaches the controller's end time, then the controller deactivates. If a positive looptime is specified for the controller, then the controller's internal timer will reset to 0 when the looptime is reached.

Background controllers must be grouped under a parent BGCtrlDef. You can use multiple BGCtrlDefs to separate the controllers into several groups. Each block of BGCtrlDef and background controllers may be placed anywhere within the [BGDef] section of the DEF file. The general format for these blocks is as follows.

Code:
[BGCtrlDef my_controller_name]
looptime = GLOBAL_LOOPTIME
ctrlID = DEFAULTID_1, DEFAULTID_2, ...

[BGCtrl my_controller_1]
type = CONTROLLER_TYPE
time = START_TIME, END_TIME, LOOPTIME
ctrlID = ID_1, ID_2, ...
(controller-specific parameters here)

[BGCtrl my_controller_2]
(etc.)
GLOBAL_LOOPTIME specifies the number of ticks after which the BGCtrlDef should reset its internal timer, as well as the internal timers of all BGCtrls it contains. To disable the looptime, set it to -1 or omit the parameter.

DEFAULTID_1, DEFAULTID_2, etc., specify the IDs of background elements to be affected by any BGCtrl that doesn't specify its own list of ctrlIDs. You can list up to 10 ID numbers for this parameter. If the line is omitted, then the default will be to affect all background elements.

START_TIME, END_TIME, and LOOPTIME are the times at which the background controller should start acting, stop acting, and reset its internal timer, respectively. If LOOPTIME is omitted or set to -1, then the background controller will not reset its own timer. (Its timer can still be reset by its parent BGCtrlDef if a GLOBAL_LOOPTIME is specified.) The background controller will be continuously active between START_TIME and END_TIME. START_TIME is required, but if END_TIME is omitted then it will default to the same value as START_TIME (so the controller will be active for 1 tick only).

ID_1, ID_2, etc., specify the IDs of background elements for this controller to act on. This list, if specified, overrides the default list specified in the BGCtrlDef. The maximum number of IDs specifiable is 10.

Below is the list of BGCtrl types and their associated parameters.

Null
As the name implies, this controller does nothing. It is useful mainly for debugging, when you want to quickly disable a controller without commenting the whole thing out. Simply change the type to null and comment out the old type. This controller has no additional parameters.

Visible
value = visible_flag Sets the visibility status of the elements.
While active, this controller sets the affected background elements to be invisible (0) or visible (1). Time will still pass for invisible elements (meaning, in the case of animated elements, that the animation will continue to progress even though it can't be seen).

Enable
value = enable_flag Sets the enabled status of the elements.
This controller either disables (0) or enables (1) the affected background elements. When an element is disabled, it is invisible and time does not pass for it (so, in the case of animated elements, any animation is paused when it's disabled).

VelSet
x = vel_x Sets the x-velocity of the elements.
y = vel_y Sets the y-velocity of the elements.
This controller will set the x/y velocity of the affected background elements to the specified values. Velocities are measured in pixels per game tick. You can specify either or both of the x and y parameters. If either is omitted, the element's velocity in that direction will not change.

VelAdd
x = vel_incr_x Changes the x-velocity of the elements by vel_incr_x.
y = vel_incr_y Changes the y-velocity of the elements by vel_incr_y.
This controller will add the specified values to the x/y velocity of the affected background elements. You can specify either or both of the x and y parameters. If either is omitted, the element's velocity in that direction will not change.

PosSet
x = pos_x Sets the x-position of the elements.
y = pos_y Sets the y-position of the elements.
This controller will set the x/y coordinate of the affected background elements to the specified values. You can specify either or both of the x and y parameters. If either is omitted, the element's coordinate on that axis will not change.

PosAdd
x = x_displacement Displaces the x-coordinate of the elements.
y = y_displacement Displaces the y-coordinate of the elements.
This controller will displace the x/y coordinate of the affected background elements by the specified values. You can specify either or both of the x and y parameters. If either is omitted, the element's coordinate on that axis will not change.

Anim
value = action_no Changes the animation displayed by the affected elements to the specified animation number.

SinX
value = amplitude, period, offset Changes the amplitude, period, and phase offset for the affected elements' sinusoidal motions in the x-direction.
These values have the same effect as they do for the sin.x background element parameters.

SinY
value = amplitude, period, offset Changes the amplitude, period, and phase offset for the affected elements' sinusoidal motions in the y-direction.
These values have the same effect as they do for the sin.y background element parameters.

Notes: Without the ID Placed in the BG, the BGctrl cannot reference the normal, parallax, or anim items.
If PosSet and PosAdd, or VelSet and VelAdd, time= overlap they will be overwriten by the most current, active BGCtrl.
You do not need a BGCtrlDef to add individual BGCtrl items.

Example:  None (yet)
Last Edit: May 14, 2017, 12:12:24 am by Odb718
Re: Background controllers (Stages)
#2  February 19, 2017, 11:09:54 pm
  • *****
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
    • xgargoyle.mgbr.net
Quote
Enabled
Enable

value = enabled_flag
Sets the enabled status of the elements.

Elecbyte made a typo on their documents
XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!
Re: Background controllers (Stages)
#3  February 20, 2017, 02:14:59 am
  • avatar
  • **
    • USA
Is there a way I can use these without actually using a particular bgctrl?

I just need that global loop time implemented and I'm good to go, I don't really need any VelSets or anything along those lines.
Re: Background controllers (Stages)
#4  February 20, 2017, 05:23:36 am
  • ******
  • 0% Hawaii
  • We wuz diktators
    • Guatemala
If you only need to turn elements on and off you could do so exclusively with animation loops. But if you have several different elements with different loop times it'll be a pian in the ass.
Re: Background controllers (Stages)
#5  May 14, 2017, 12:16:40 am
  • *****
  • Shame on you!
    • USA
Edited the first post. Changed the layout for readability and added notes. I was thinking of adding examples for all of them in a nested spoiler.
If someone could verify my notes for winmugen, that'd be great. Especially the last one. I have over 90 BGCtrls in my stage with no BGCtrlDef and it works fine.
vVv Wheat Stage Released vVv