Backgrounds

From Open Surge Engine Wiki
Revision as of 17:41, 25 December 2010 by Kzr (Talk | contribs)

Jump to: navigation, search

WARNING: ARTICLE INCOMPLETE, FORMATTING ERRORS


Backgrounds

.1 definition of background

In open surge of background is composed of two parts: the background script, and the background image.

The background image contains all the visual elements of the background, while the background script contains the definitions of the background such as the height, width, which part of the image to be used.

A background image is nothing without the script, even if you want to have a static background. There is a very simple reason for this. Even though making a static background looks easy as 123, the very same static background can be assembled in hundreds of different ways just by specifying different source points for the image, layering the background parts differently, or even by playing around with the scrolling speeds.

So, to summarize it, the most basic elements of a background are:

The background image (an image in .PNG format contained in the images folder of open surge) the background script (a plain text file with extension .BG contained in the themes folder off open surge)

.2 my first background – Starting a background script

Assuming you have already chosen an image for your background, we will use the one below as reference:

now open your text editor,start a new file, and you may want to add this to the start:

# Open Surge Background
# by User001
# Background theme for My Zone
# OS Version: x.x.x

the # is the symbol that notes a line as a comment, and this means the engine will not read this line, as it is only meant to inform you, "the creator", or other people, "the modders", of important details about the background script.

Having this at the start of the file informs:

line number one tells us this file is an open surge background. Line number two tells us who created this file. line number three tells us what this background file was made for. line number four tells us which version of the game we need.

also, if you are editing someone else's file, you should also add:

# Modified by user002

and this is what we call the header, even though this is a very simple one with only comments and no commands.

.2 .1 – simple background

Now that you are done with the header, you can leave some empty paragraphs, then start the very first layer.

once again the # symbol is useful here to help you identify which layer represents a certain part of the image.

This is an example of a code block for a background layer


# sky 
background
{
   initial_position    0 -64
   scroll_speed        -0.01 0
   behavior            DEFAULT
   repeat_x            TRUE
   repeat_y            FALSE
   zindex		0.2
	
   sprite
   {
       source_file     Images/sunshinesky.png
       source_rect     0 0 768 192
       frame_size      768 192

       animation
       {
           repeat      TRUE
           fps         1
           data        0
       }
   }
}

so you start the first line with the word "background", so the engine knows it will create a background, and it will add the properties below.

the { and } symbols open and close a statement. The statement is a block of commands and parameters, and there can be statements inside statements, like when the Sprite is declared.

Attention: you should always respect the structure shown in the example. Misplaced {} will make your background unable to load.

initial_position Receives two parameters: X position and Y position. both counting from the top left edge of the level. higher X values mean to the right, higher Y values mean downwards.

scroll_speed receives two parameters: X speed and Y speed. positive values mean the background will be moving in the same direction you are, which looks unnatural, but can be used to create a different effect. negative values scroll the background in the opposite direction of movement, which is how things work in real life.

behavior receives one or more parameters. Available behaviors are:

-default
  the default behavior is meant to only scroll the background on player movement.
-linear
  TODO