Skip to content

Sprites

Raluca D. Gaina edited this page Feb 12, 2018 · 2 revisions

Sprites are the main game elements. They are defined in the SpriteSet section of the game description file. In the SpriteSet section, sprites have a name and a type and some parameter values. The following is a harsh outline how the section should look like:

SpriteSet
    sprite_1 > type_1 parameters
    sprite_2 > type_2 parameters
    sprite_3 > type_3 parameters

sprite_1, sprite_2, and sprite_3 are just names that can define the sprites. type_1, type_2, and type_3 are their types which can be either Avatar type or Other types. parameters is a group of assigned value that can be specific for the type or a common sprite property.

Sprites are defined in the form of tree structure like XML files but using indentation (like python). User can group similar sprites under a certain name. For example:

SpriteSet
    sprite_1 >
        sprite_2 > type_1 parameters
        sprite_3 > type_2 parameters

sprite_2 and sprite_3 can be referred as sprite_1 at any place in the script. This is useful to reduce the number of redundant Interaction rules. For example:

InteractionSet
    sprite_1 sprite_6 > interaction

The above means when sprite_2 or sprite_3 (as sprite_1 is defined as sprite_2 and sprite_3 from the previous definition) collides with sprite_6 perform certain interaction. Also using this tree structure extends the functionality of the Termination Conditions. For example:

 TerminationSet
     SpriteCounter stype=sprite_1 limit=0 win=True

The above conditions says if number of sprite_1 in the current level is less than or equal to 0 then level is won. Since sprite_1 can be sprite_2 or sprite_3 so this means if the number of both sprites not just a single one. One last thing about the tree structure that user can give the group certain parameter or type, for example sprite_5 and sprite_6 can be called sprite_4 and both of them of type type_3.

SpriteSet
    sprite_4 > type_3
        sprite_5 > parameters
        sprite_6 > parameters

Examples:

SpriteSet
    door   > Door img=exit
    wall   > Immovable img=wall
    water  > Immovable img=water
    box    > Passive img=box
    avatar > MovingAvatar img=avatar

This is a simple set from WaterGame. There is only five game sprites each with different type and image for it.

SpriteSet
    base    > Immovable    color=WHITE img=base
    avatar  > FlakAvatar   stype=sam 
    missile > Missile
        sam  > orientation=UP    color=BLUE singleton=True img=spaceship
        bomb > orientation=DOWN  color=RED  speed=0.5 img=bomb
    alien   > Bomber       stype=bomb   prob=0.01  cooldown=3 speed=0.8 img=alien
    portal  > SpawnPoint
    	portalSlow  > stype=alien  cooldown=16   total=20 img=portal
    	portalFast  > stype=alien  cooldown=12   total=20 img=portal

This the SpriteSet of Aliens game (a simplified version of Space Invaders). This set utilize the tree structure like sam and bomb sprites are of type Missile and they are tagged as missile. Also portalSlow and portalFast sprites are of type SpawnPoint and they are tagged as portal.

Table of Contents:

Clone this wiki locally