Skip to content

Platforms

Adrian K edited this page Oct 2, 2024 · 15 revisions

Description

Platforms are used to either stand on or in the case of sand invert the behavior of the vanilla sand block

Location

Platforms are located inside the platforms folder which contains additional folders to further differentiate the type of platform that is being defined

These subfolders are:

  • auto
  • basic
  • countdown
  • jump
  • sand

Inside each of these folders one further folder called textures exists.

E.g.: switchBlocksMod\platforms\basic\textures

Defining Platforms

Platforms are defined by a platforms{screennumber}.xml file, as the name implies platforms are defined by what screen they appear on, counting starts from one.

File structure

The file may begin with an xml header, but it is not needed. The Platforms tag however has to be the last element in the xml file.

You may then add any amount of Platform tags inside of it.

A non-sand type Platform tag then requires three more tags

  • Texture
  • Position
  • StartState

The Positiontag then contains X and Y

Not required but you may also add an Animation tag, read about animations here

For the sand block the Texture tag is split up into three different ones:

  • Background
  • Scrolling
  • Foreground

Background or Foreground is required, Scrolling is optional.

For the group block the StartState is no longer relevant (if someone complains i can change that). However a new tag exists, Link. This tag helps with linking a texture to a block. That is, normally, a texture that is perfectly aligning with a platforms top left corner will be automatically figure out the group it belongs to. Should the texture be disconnected this tag contains the position of a block (in screen coordinates, not in hitbox coordinates). The Link tag then contains X, Y and Screen.

Example

Path to file switchBlocksMod\platforms\basic

File platforms3.xml

<?xml version="1.0"?>
<Platforms xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Platform>
        <Texture>platform_blue_square</Texture>
        <Position>
            <X>312</X>
            <Y>192</Y>
        </Position>
        <Animation>
            <Style>top</Style>
            <Curve>linear</Curve>
        </Animation>
        <StartState>on</StartState>
    </Platform>
    <Platform>
        <Texture>platform_blue_square</Texture>
        <Position>
            <X>416</X>
            <Y>192</Y>
        </Position>
        <StartState>on</StartState>
    </Platform>
    <Platform>
        <Texture>platform_blue_square</Texture>
        <Position>
            <X>312</X>
            <Y>296</Y>
        </Position>
        <StartState>on</StartState>
    </Platform>
    <Platform>
        <Texture>platform_blue_square</Texture>
        <Position>
            <X>416</X>
            <Y>296</Y>
        </Position>
        <StartState>on</StartState>
    </Platform>
</Platforms>

This would define four basic platforms in screen 3 at those positions with platform_blue_square textures.

Example Sand

Path to file switchBlocksMod\platforms\sand

File platforms2.xml

<?xml version="1.0"?>
<Platforms xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Platform>
        <Background>background</Background>
        <Scrolling>scrolling</Scrolling>
        <Foreground>foreground</Foreground>
        <Position>
            <X>368</X>
            <Y>104</Y>
        </Position>
        <StartState>off</StartState>
    </Platform>
    <Platform>
        <Background>background</Background>
        <Scrolling>scrolling</Scrolling>
        <Foreground>foreground</Foreground>
        <Position>
            <X>432</X>
            <Y>104</Y>
        </Position>
        <StartState>on</StartState>
    </Platform>
</Platforms>

This would define two sand platforms at those positions with background, scrolling, and foreground textures.

Be aware of

Make sure you are not creating softlocks

Placing a platform on the ground and standing inside of it as it becomes solid will make you glitch into solid platforms, therefore it is recommended to keep a players height worth of free space around platforms that could cause the player to be inside while state switching. (Unless its wanted behaviour)