-
-
Notifications
You must be signed in to change notification settings - Fork 492
GameObjects
This page is about the class in the source code. For a list of objects available in the game, see Objects.
Template:Outdated GameObject is a base class in the SuperTux source code. It is the most basic class for objects in the game. Nearly everything should inherit from this class, for instance badguys, unstable tiles and trampolines. All GameObjects are stored in a list by the engine. This list will be traversed twice per frame. First the action function is called on each object, and then the draw function of each object is called.
The class also contains a flag that indicates if the object should be removed at the end of the frame. You can call ->remove_me()
to set this flag.
These are objects you can interact with. The objects will have an area in the world. And you can send interaction events to them. Typical interaction events will be activate/push, ~EnterArea/touch, ~LeaveArea, hit with object
This class provides a position and functions for collision detection. All Moving objects are held in a separate list by the engine which is also traveled once (between action and draw calls) for collision detection.
As of 6274.
- GameObject
- AmbientSound
- Background
- BouncyCoin
- BrokenBrick
- Camera
- DisplayEffect
- Electrifier
- EndSequence
- EndSequenceFireworks
- EndSequenceWalkLeft
- EndSequenceWalkRight
- FallingCoin
- Fireworks
- FloatingImage
- FloatingText
- Gradient
- LevelTime
- Light
- PulsingLight
- MovingObject
- Block
- BonusBlock
- Brick
- InfoBlock
- InvisibleBlock
- Bullet
- Flower
- MovingSprite
- BadGuy
- AngryStone
- Bomb
- BouncingSnowball
- Dart
- DartTrap
- Dispenser
- Fish
- Flame
- FlyingSnowBall
- GhostTree
- Jumpy
- KamikazeSnowball
- Kugelblitz
- Mole
- MoleRock
- MrRocket
- Plant
- Root
- SkullyHop
- SpiderMite
- Stalactite
- YetiStalactite
- Toad
- Totem
- TreeWillOWisp
- WalkingBadguy
- CaptainSnowball
- Crystallo
- Igel
- MrBomb
- MrIceBlock
- MrTree
- PoisonIvy
- SmartBall
- Snail
- SnowBall
- Spiky
- SSpiky
- Stumpy
- WalkingLeaf
- WillOWisp
- Yeti
- Zeekling
- BicyclePlatform
- Candle
- Coin
- Decal
- Explosion
- Firefly
- GrowUp
- IceCrusher
- InvisibleWall
- Ispy
- MagicBlock
- OneUp
- Platform
- HurtingPlatform
- PneumaticPlatform
- PowerUp
- PushButton
- Rock
- ScriptedObject
- SkullTile
- Star
- UnstableTile
- WeakBlock
- BadGuy
- Player
- TriggerBase
- Wind
- Block
- Particles
- ParticleSystem
- CloudParticleSystem
- GhostParticleSystem
- SnowParticleSystem
- ParticleSystem_Interactive
- CometParticleSystem
- RainParticleSystem
- RainSplash
- SmokeCloud
- SpecialRiser
- Spotlight
- SpriteParticle
- TextObject
- Thunderstorm
- TileMap
- worldmap::LevelTile
- worldmap::SpecialTile
- worldmap::SpriteChange
- worldmap::Teleporter
- worldmap::Tux
With levels that can vary in size both horizontally and vertically comes the need for background images that have the same property. This however causes problems with images that show, for example, a sky; we don't want it to repeat below the ground.
We have three solutions for this.
The first is to divide images into three rows. All of these are tilable horizontally (like the milestone 1 backgrounds). Additionally, the top and bottom rows are also tilable vertically. Thus, the middle part of the image has a fixed vertical size while the top and bottom are variable.
Second, we create background images out of tilemaps. These can scroll at different rates than the main frame, but the level author can ensure that the tilemaps are big enough.
Finally, we can anchor images to a portion of the screen so that vertical movement doesn't affect the image.
Bonus blocks are blocks that Tux can hit with his head to get coins or powerups.
The editor differentiates which powerups are given:
![](images/Bonus Block.jpeg "Bonus Block.jpeg")
A common bonus block giving Tux 1 coin.
![](images/Bonus Block - Crate.jpeg "Bonus_Block_-_Crate.jpeg")
A wooden crate, yielding six coins, one per hit.
![](images/Bonus Block - Snowy_Crate.jpeg "Bonus_Block_-_Snowy_Crate.jpeg")
The same as the normal crate, but is used when the area is more snowy.
![](images/Bonus Block - Powerup.jpeg "Bonus_Block_-_Powerup.jpeg")
Standard powerup, meaning an egg, a fireflower, or an iceflower depending on whether Tux is big.
![](images/Bonus Block - Invinsible.jpeg "Bonus_Block_-_Invinsible.jpeg")
Invincibility star. Collisions which would kill Tux instead kill the badguy, if he is killable.
![](images/Bonus Block - Invisible.jpeg "Bonus_Block_-_Invisible.jpeg")
This is invisible until you hit it with your head. It then appears as an empty bonus block. These are often used to produce paths to secret areas.
![](images/Bonus Block - 100 coins.jpeg "Bonus_Block_-_100_coins.jpeg")
This block releases a tiny penguin when hit. It goes up slightly at an angle away from the side Tux hits it on, then curves and goes down, to be lost forever unless Tux can catch it before it goes into the ground. He currently gets 100 coins. This could be changed as he only loses about 25 when he dies.
![](images/Bonus Block - Empty.jpeg "Bonus_Block_-_Empty.jpeg")
All bonus blocks look like this once used, but there are also some which begin like this. They act exactly like a normal, solid block.
Template:NeedCode Template:NeedSound A bubble dispenser is a device that, when activated, creates bubbles that slowly float upward. Tux can jump into one of these bubbles to get upward movement; he is also able to control floating speed and movement to the sides a bit. Bubbles are destroyed on contact with solid tiles or objects, whereupon Tux is released. The following sketch shows such a bubble dispenser as it could appear in the forest world, in form of a fossilized dragon that starts spitting bubbles as soon as Tux “wakes” him by jumping on his nose.
![](images/Bubble sketch.jpg "Bubble_sketch.jpg")
Buttons and switches could be used a lot.
- To open doors/switchable blocks
- To change direction of conveyor belts or pipes with multiple directions (when water is inside and pushing Tux)
- To turn lights on/off
Template:NeedCode The camera blocker is a trigger-tile that prevents the camera from scrolling into a certain direction (i.e. the camera will stop scrolling if it would bring a camera blocker tile into sight). Also, it will instantly kill Tux on contact. It will be used to create gaps in vertical-scrolling levels and to hide certain places from the player. Of course, like all trigger tiles, this must be used with care!
Level are typically a lot bigger than the actual screen, so we need to scroll the currently visible part around. This page collects some rules to do this in a nice way.
Analysis of some Cameras in Super Mario
Basically these are the same rules as for Yoshi's Island. Maybe we will tweak it later or add special exceptions for new abilities.
- Keep the middle point of Tux at 1/3rd of the screen width. If Tux moves/looks into the other direction, then slowly move the camera so that tux stands in the 1/3rd of the other side of the screen. This movement has to get faster if Tux moves into that direction. When Tux gets pushed into the other direction (but still looks forward) we don't change camera mode but just scroll when he gets pushed nearer than 1/3rd of the other side.
- We might experiment about changing the camera when Tux is running to 1/4th or so. We should test if this is desirable because then you see more stuff that's before you. On the other side a too dynamic camera movement can confuse and making it harder to control Tux exactly.
- Basically keep Tux in the middle of the screen.
- When Tux does a normal jump we don't scroll vertically until he stands on ground again or falls deeper than the hight where he started the jump. An exception to this rule are trampolines.
The camera might scroll automatically so that Tux can't wait but has to hurry to not get squished by the moving camera somewhere. Ideally you can specify a path of vectors (together with speed) that the camera follows.
This was used in the 0.1.1 release. It might be still used to not forget our history ;-)
I worked a bit on the code and put all parameters that influence the camera in a configuration file. You can now open data/camera.cfg and play with the parameters yourself. This way you can test/try out fixed camera, Yoshi Island and Kirby Camera and their parameters easily. You can make the game reparse the Camera by typing “sector.Camera.reload_config()” on the console. Put camera.cfg in ~/.supertux2/ .
Template:Milestone 2 Tux can enter doors to be teleported to a different part of the level, even in a different sector.
An Infoblock is a game object which is used to provide non-obvious information for the player. It is displayed as a green block with a white exclamation mark. When jumping against the block from below, a message is displayed.
The message is formatted line-wise. The first character of each line determines how the line is formatted. The first character is not printed. The parsing is done in three functions defined in src/supertux/info_box_line.cpp. The colors are defined in src/supertux/colorscheme.cpp.
Character Type Font size Color
\t
(tab) Normal Normal Normal color (white)
␣
(space) Small Small Small color (white)
-
(dash) Heading Big Heading color (yellow)
*
(asterisk) Reference Normal Reference color (blue)
#
(hash) Normal (left) Normal Normal color (white)
!
(exclamation mark) Image n/a n/a
An area Tux can climb up in. Needs (background) graphics for visualization.
Magic Blocks are tile-like game objects that are sensitive to Lighting conditions. They are rendered in a primary color and will only be solid as long as light of the same color shines on the block.
Illustration of Magic Block behaviour:
![](images/Flying platform-0.png "fig:Flying_platform-0.png") A moving platform is a MovingObject that can be used by level designers to let Tux reach high places. It can be scripted to start moving as a response to some action and follows a predefined path.
: ''This page lists the available objects in the game. For a description of the implementation see Game object.''
object is anything that can contain sector and it has its position. Tiles aren't Objects!
The following objects are available in the 0.3.x release or have been committed to the SVN repository.
- Various badguys
- Ambient sound
- Background Images
- Bicycle platform
- Brick / Broken Brick
- Bullet
- Buttons and switches
- Camera
- Candle
- Coin
- Decal
- Display effect
- Door
- Electrifier
- End sequence
- Explosion
- Falling coin
- Fireworks
- Floating image / Floating text
- Flower
- Gradient
- Growup
- Hurting platform
- Invisible block / Invisible wall
- Lantern
- Level time
- Light
- Ladder
- Moving platform
- Oneup
- Particle system
- Reset point (“Firefly” for some reason)
- Rock
- Scripted object
- Script trigger
- Secret Area
- Skull tile
- Smoke cloud
- Spawn point
- Special riser
- Spotlight
- Star
- Teleport
- Text object
- Thunderstorm
- Tilemap
- Trampoline
- Unstable tile
- Wind
- Special Block Types
The following objects can actually be generated with ObjectFactory, i.e. from within a level:
- ambient_sound
- angrystone
- background
- bicycle-platform
- bonusblock
- bouncingsnowball
- candle
- captainsnowball
- coin
- climbale
- crystallo
- decal
- door
- dispenser
- explosion
- fish
- firefly
- flame
- flyingsnowball
- ghosttree
- gradient
- haywire
- hurting_platform
- icecrusher
- igel
- infoblock
- invisible_wall
- ispy
- jumpy
- kamikazesnowball
- kugelblitz
- lantern
- leveltime
- magicblock
- mole
- mrbomb
- mriceblosk
- mrtree
- plant
- platform
- pneumatic-platform
- poisonivi
- powerup
- pushbutton
- rock
- scriptedobject
- scripttrigger
- secretarea
- sequencetrigger
- skullyhop
- skydive
- smartball
- snail
- snowball
- snowman
- spidermite
- spiky
- spotlight
- stalactite
- switch
- thunderstorm
- tilemap
- toad
- totem
- trampoline
- unstable_tile
- valkingleaf
- weak_block
- willowisp
- wind
- yeti
- zeekling
The following objects are ideas that have not yet been implemented.
Note: General consensus was to avoid pipes in SuperTux. It's really a Mario thing and doesn't fit a penguin. Instead, different objects can be used to transfer Tux between sectors, such as doors.
Uses for pipes:
- Pipes that take Tux to sublevels
- Pipes that don't do anything (already in some levels.)
- Pipes Tux can walk thru, but you can't see him.
- Pipes that have water flowing thru them. These could have switches and take Tux different directions.
- Pipes that release water geysers or bubbles that take Tux to a different place.
A rock is a small object that Tux can pick up and move around. Tux can walk on rocks, so they are useful to reach high places. Both Tux and enemies are hurt if a rock falls on their head.
For a sample, see the level world2/builder.stl (in 0.3.0 and up).
Script triggers are areas that trigger a script when Tux enters them. Script triggers are commonly used to activate moving platforms or air currents.
The Secret Area Trigger is used to mark secret areas, at the moment it fades a tilemap, writes a message to the screen, and adds to the number of secrets the player has found in a level, as well as marking the total number of secrets.
It is specified something like the following:
(secretarea
(width
)
(height
)
(x
<top left corner's x coordinate>)
(y
<top left corner's x coordinate>)
(fade-tilemap
“”)
)
Upon entering the secret area, the specified tilemap will be faded, “You found a secret area!” will be displayed, and the user will have one more found secret added to his statistics. Nothing is currently done when leaving a secret area.
Spawn points are the places where Tux appears when entering a level or a sector. Every sector has a main spawn point, the one where Tux begins the level, but there may be as many spawn points as the level designer wishes, usable to spawn Tux when he enters a door or touches a script trigger.
You can use the global Level object to spawn Tux at a specific spawn point. The syntax is as follows:
Level.spawn (
“SecretArea
”,
“main
”);
Where “SecretArea” is the name of the sector and “main” is the name of the spawn point.
: This page is about the worldmap object. For teleportation in levels see Door and Level (Scripting).
A teleport is an object on worldmaps that teleports the player to another part of the map. Teleporters are used primarily to hide secret levels or to link between islands. Bonus world 1 uses them extensively; navigation is not possible without the use of teleporters. There are currently two teleporters in Icy Island (World 1);one is an automatic one to go to Forest (World 2), and the other is used to access the bonus level. In the Forest world there currently is only one automatic teleporter to go back to Icy Island.
When the Thunderstorm goes off, you will hear distant thunder. Shortly afterwards a lightning strikes, making the screen flash. All water in the level is electrified when the lightning hits and reverts to normal afterwards.
The Thunderstorm can be configured to go off at regular intervals or alternatively be scripted. See ScriptingThunderstorm for a quick reference.
Tilemaps consist of all of the ground, spikes, lava, clouds, etc. that do not move and do not interact actively with the player. Each tilemap consists of one or more tiles, which each contain several attributes specified in the tileset.
Tilemaps can be either solid or non-solid. The player can only interact with solid tilemaps (i.e. they are used for collision detection) but not with non-solid tilemaps. Non-solid tilemaps are usually used as foreground and background layers.
Multiple tilemaps of each kind may be specified. You can think of a tilemap as a layer of “blocks”. Each layer has an associated z-position where smaller values mean further back, larger values mean further in front.
:{| border=“1” ! z-position ! Use |- | -100 | Default background layer
|- | 0 | Default interactive layer |- | 50 | LAYER_OBJECTS
(default
object layer) |- | 51 |
Tux, bonus blocks |- | 100 | Default foreground layer
|}
Tilemaps are also scriptable if given a (unique) name, see ScriptingTilemap.
Tilemaps may also be given a path, which they will follow once scripted to do so.
Note that infoblocks, unstable tiles, bonus blocks, invisible blocks that can be activated, coins, and wooden bricks are not actually part of the tilemap; after the level is parsed, the tiles with the ID's or attributes representing those objects are replaced with the objects themselves and the tiles changed to empty.
The trampoline is a small object that Tux can pick up and move around. When Tux jumps on the trampoline the springs compress and then Tux is launched into the air. Trampolines will allow Tux to bounce up to areas he could not normally jump to.
(trampoline
(x 320)
(y 1056)
(portable #f)
)
x and y are the coordinates as usual. portable is a optional flag which defaults to true. Set it to false to prevent the player from carrying that trampoline around.
Unstable tiles are a special kind of tile on which Tux can stand only for a limited time. After that, the block starts to dissolve and / or to fall down.
The sprites for unstable tiles may have four actions:
normal : Displayed until Tux steps on the tile.
shake : The tile shakes but is still solid.
dissolve : The tile is dissolving. After the animation for this action is done, the tile will be set non-solid.
fall-down : Gravity is enabled for this tile and it will begin to fall down.
Each of the actions shake, dissolve and fall-down is optional. If a sprite doesn't have the dissolve action, the till will still be solid when the fall-down action is executed (Donut Tile style). If the tile doesn't have a fall-down action, it will be removed after the dissolve animation is done (Giana Sisters style).
![](images/Weak block.png "fig:Weak_block.png") This is a special kind of block that can be destroyed by shooting it with a fireflower or when something explodes nearby, Mr. Bomb for example.
Generally speaking, Wind is a region in a level that influences Tux' speed while he's not standing on solid ground. Wind can be scripted to create e.g. air gushes coming out of pipes or water streams that can be switched on and off. See ScriptingWind for a detailed description about how to manipulate a Wind object with Squirrel scripts.
Home
Guidelines
Game Mechanics
Tools
Engine
- Cameras in other games
- Collision
- Configuration File
- Console
- Cutscenes
- Game_Engine
- Lighting
- Map_transformer
- Portables
- SceneGraph
- Scripting
Specifications
Milestones
- Milestone 1 Analysis
- Milestone 2 Design Document
- Milestone 2 Design Document Old
- Milestone 3 Design Document
Building (mostly outdated)
- INSTALL.md
- Building
- Building on macOS
- Building SuperTux
- Building on Windows
- Building with MXE (cross-compile)
Meetings