Post by vyckstjudas on Dec 15, 2012 1:27:11 GMT -5
Platforms for 2D mods
Intro: It's very common to see platforms in 2D scrolling games, almost all of them has these. Platforms are not only for eye candy but defines gameplay. OpenBoR is capable of supporting 2D mods and is supports platforms too. This tutorial explains how to set platforms for 2D levels.
Before I start, there are 2 ways to set platforms in level. One is with Wall command (for levels) and the other is with platform command (for entities). Both are combinable but the one explained here is the latter.
Procedure: There are 2 steps to set platforms: set the platform entities then declare them in levels.
1. Setting platform entities
Since we are using entities for the platforms, we need to make an entity text and declare it in models.txt.
Example:
Quote
name Plat5
type none
shadow 0
facing 1
antigravity 100
anim idle
delay 100
offset 1 1
platform 1 1 0 0 80 80 16 16
frame data/chars/misc/empty.gif
In models.txt:
Quote
know Plat5 data/chars/misc/platform/plat5.txt
In this example, Plat5 is the platform entity. It's floating and doesn't fall so 'antigravity 100' is set. Plat5 is using empty.gif which is invisible. You can use other graphic to visualize the platform. I use invisible platform cause the platform is already shown by level panels.
'platform' command is the essential command to set platform size, hence its name. The 1st 2 parameters matches its offset meaning the platform starts from the offset to the right. The '0 0 80 80' means that the platform's width is 80 pixels wide. The last parameter (16) means the platform's height is 16 pixels high.
With this set, Plat5 is ready to use.
2. Declaring platforms in level texts
This part can be tough or easy depends on how the platforms look like. If the platform has visual, you can spawn it anywhere and it's easy. However if the platform is invisible and it's meant to 'platformize' background or panel, you need to spawn it in proper place so they matches.
Nonetheless, the platforms must be spawned like this:
Quote
spawn plat5
coords 359 320 161
at 0
359 is the distance of platform from leftmost edge of level.
The z coordinate is set with same value as z command set in levels.txt, in this example it's 320.
161 is the altitude of platform from ground.
If you are 'platformizing', you need to measure the distance and altitude properly. You can use Photoshop or other graphic editor for this.
Repeat these steps until you got all platforms spawned or until all background plaformized.
Issue: There shouldn't be any issue with this but you might encounter some issues like below.
1. Entities aren't blocked properly. About half of their body can pass through platforms
This is because platform only block entities by their offset, that's why half part can pass through. To solve this, simply enlarge platform width until all part can't pass through.
2. Projectiles are blocked platforms while they are supposed to pass through
This is not platform's fault, so to speak. The projectiles aren't set to ignore platforms that's why. Set this in their header to solve it:
Quote
subject_to_platform 0
3. Platforms can be jumped through from below while they aren't supposed to
Again, this is not platform's fault . The entities don't have 'height' set which allows them to jump through from below. To solve this, simply set 'height' in their header like this:
Quote
height 30
Any height value can be used though.
4. Platforms can't be flipped, it will always go right even if platform is facing left
If you notice, there's 'facing 1' set in Plat5's header above. It's set like that so this platform can't be flipped and always face right making it easier to set in levels. It's also to prevent this bug cause the platform is always facing right.
However, if you want to make visible platform which can be flipped, you need to adjust platform settings like this:
Quote
name Plat5
type none
shadow 0
antigravity 100
anim idle
delay 100
offset 40 16
platform 40 16 -40 -40 40 40 16 16
frame data/chars/platform/platform.gif
This one is say using not invisible gif like before but use visible one instead (platform.gif). The platform size is same though i.e 80x16 pixels.
Offset is moved to center of platform and below platform which is 40 pixels from left and 16 pixels from top to 40 16. This makes platform has same length to left and right allowing you to flip it in level.
However, 'platform' settings must be adjusted too. Since the offset is moved 40 pixels to right, the previous settings are shifted 40 pixels to left for balance and it become:
platform 40 16 -40 -40 40 40 16 16
Extra: Although its name is platform, you can make walls with it. Here's an example:
Quote
name Wall5
type none
shadow 0
facing 1
antigravity 100
anim idle
delay 100
offset 1 1
platform 1 1 0 0 16 16 80 80
frame data/chars/misc/empty.gif
It's similar to Plat5 mentioned above except that this one is 16 pixels wide and 80 pixels high.
Combined with platforms, you can make complex room with walls and platforms.
And last but not least, you can combine platforms to make longer platforms. Just spawn them in a row which form long platform.
Intro: It's very common to see platforms in 2D scrolling games, almost all of them has these. Platforms are not only for eye candy but defines gameplay. OpenBoR is capable of supporting 2D mods and is supports platforms too. This tutorial explains how to set platforms for 2D levels.
Before I start, there are 2 ways to set platforms in level. One is with Wall command (for levels) and the other is with platform command (for entities). Both are combinable but the one explained here is the latter.
Procedure: There are 2 steps to set platforms: set the platform entities then declare them in levels.
1. Setting platform entities
Since we are using entities for the platforms, we need to make an entity text and declare it in models.txt.
Example:
Quote
name Plat5
type none
shadow 0
facing 1
antigravity 100
anim idle
delay 100
offset 1 1
platform 1 1 0 0 80 80 16 16
frame data/chars/misc/empty.gif
In models.txt:
Quote
know Plat5 data/chars/misc/platform/plat5.txt
In this example, Plat5 is the platform entity. It's floating and doesn't fall so 'antigravity 100' is set. Plat5 is using empty.gif which is invisible. You can use other graphic to visualize the platform. I use invisible platform cause the platform is already shown by level panels.
'platform' command is the essential command to set platform size, hence its name. The 1st 2 parameters matches its offset meaning the platform starts from the offset to the right. The '0 0 80 80' means that the platform's width is 80 pixels wide. The last parameter (16) means the platform's height is 16 pixels high.
With this set, Plat5 is ready to use.
2. Declaring platforms in level texts
This part can be tough or easy depends on how the platforms look like. If the platform has visual, you can spawn it anywhere and it's easy. However if the platform is invisible and it's meant to 'platformize' background or panel, you need to spawn it in proper place so they matches.
Nonetheless, the platforms must be spawned like this:
Quote
spawn plat5
coords 359 320 161
at 0
359 is the distance of platform from leftmost edge of level.
The z coordinate is set with same value as z command set in levels.txt, in this example it's 320.
161 is the altitude of platform from ground.
If you are 'platformizing', you need to measure the distance and altitude properly. You can use Photoshop or other graphic editor for this.
Repeat these steps until you got all platforms spawned or until all background plaformized.
Issue: There shouldn't be any issue with this but you might encounter some issues like below.
1. Entities aren't blocked properly. About half of their body can pass through platforms
This is because platform only block entities by their offset, that's why half part can pass through. To solve this, simply enlarge platform width until all part can't pass through.
2. Projectiles are blocked platforms while they are supposed to pass through
This is not platform's fault, so to speak. The projectiles aren't set to ignore platforms that's why. Set this in their header to solve it:
Quote
subject_to_platform 0
3. Platforms can be jumped through from below while they aren't supposed to
Again, this is not platform's fault . The entities don't have 'height' set which allows them to jump through from below. To solve this, simply set 'height' in their header like this:
Quote
height 30
Any height value can be used though.
4. Platforms can't be flipped, it will always go right even if platform is facing left
If you notice, there's 'facing 1' set in Plat5's header above. It's set like that so this platform can't be flipped and always face right making it easier to set in levels. It's also to prevent this bug cause the platform is always facing right.
However, if you want to make visible platform which can be flipped, you need to adjust platform settings like this:
Quote
name Plat5
type none
shadow 0
antigravity 100
anim idle
delay 100
offset 40 16
platform 40 16 -40 -40 40 40 16 16
frame data/chars/platform/platform.gif
This one is say using not invisible gif like before but use visible one instead (platform.gif). The platform size is same though i.e 80x16 pixels.
Offset is moved to center of platform and below platform which is 40 pixels from left and 16 pixels from top to 40 16. This makes platform has same length to left and right allowing you to flip it in level.
However, 'platform' settings must be adjusted too. Since the offset is moved 40 pixels to right, the previous settings are shifted 40 pixels to left for balance and it become:
platform 40 16 -40 -40 40 40 16 16
Extra: Although its name is platform, you can make walls with it. Here's an example:
Quote
name Wall5
type none
shadow 0
facing 1
antigravity 100
anim idle
delay 100
offset 1 1
platform 1 1 0 0 16 16 80 80
frame data/chars/misc/empty.gif
It's similar to Plat5 mentioned above except that this one is 16 pixels wide and 80 pixels high.
Combined with platforms, you can make complex room with walls and platforms.
And last but not least, you can combine platforms to make longer platforms. Just spawn them in a row which form long platform.