Creating a level - TahliaK/wight-whale GitHub Wiki

Levels are created through XML documents, which are imported by the program.

All levels should be contained within the file "Files/Levels/..." under the program install/run directory.

Levels specify all display objects in 3 categories:

  1. StaticItems - non-moving graphical items such as backgrounds and furniture. These are rendered first and underneath the other objects.
  2. MovingItems - moving graphical items that are not directly under player control. These are rendered second - on top of static items, and under playerControlled items.
  3. PlayerControlledItems - moving graphical items that are controlled by the user directly at run time

Below is an annotated example level:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- Required starting tag -->
<LevelMap> <!-- Required Levelmap Tag -->
    <MapSections> <!-- Each "<item> under MapSections is a graphical area - corresponds to a GameSegment in java -->
        <item>
            <id>Map1Section1</id> <!-- Level name -->
            <mapX>0</mapX> <!-- Position in map on x axis -->
            <mapY>0</mapY> <!-- Position in map on y axis -->
            <playerControlledItems> <!-- Player controlled objects -->
                <entry> 
                    <key>player</key> <!-- Key used to access item in GraphicsController -->
                    <value> 
                        <id>player</id> <!-- Item ID - this should ALWAYS match the key -->
                        <visible>true</visible> <!-- if false, will not render -->
                        <position>
                            <x>125</x>
                            <y>50</y>
                        </position>
                        <width>10</width> <!-- Sprite width - descriptive, not used to scale -->
                        <height>10</height> <!-- Sprite height - descriptive, not used to scale -->
                        <imgFilename>Files/Images/Skeleton.png</imgFilename> <!-- Image file to load -->
                        <moveDistance>2</moveDistance> <!-- Speed when moved -->
                        <ControlScheme> <!-- Pre-set control scheme -->
                            <CurrentControlScheme>ARROW_KEYS</CurrentControlScheme> <!-- Valid: ARROW_KEYS or WASD -->
                        </ControlScheme>
                        <KeepBetweenAreas>false</KeepBetweenAreas> <!-- Not yet implemented - if true, would prevent de-loading between areas -->
                    </value>
                </entry>
            </playerControlledItems>
            <movingItems> <!-- Moving, but not player-controlled, objects -->
                <entry>
                    <key>light</key> <!-- Access ID in GraphicsController -->
                    <value>
                        <id>light</id> <!-- Should match key -->
                        <visible>true</visible>
                        <position>
                            <x>125</x>
                            <y>50</y>
                        </position>
                        <width>24</width> <!-- Descriptive, not used to scale -->
                        <height>30</height>
                        <imgFilename>Files/Images/lightA01.png</imgFilename>
                        <moveDistance>2</moveDistance> <!-- Not yet implemented, but movement distance -->
                    </value>
                </entry>
            </movingItems>
            <staticItems> <!-- Non-moving items -->
                <entry>
                    <key>background</key> <!-- Graphical items -->
                    <value>
                        <id>background</id>
                        <visible>true</visible>
                        <position>
                            <x>0</x>
                            <y>0</y>
                        </position>
                        <width>500</width> <!-- This IS used to scale the image -->
                        <height>500</height>
                        <imgFilename>Files/Images/background.png</imgFilename>
                    </value>
                </entry>
            </staticItems>
        </item>
        <item>
            <id>Map1Section2</id>
            <mapX>0</mapX>
            <mapY>1</mapY>
            <playerControlledItems/>
            <movingItems>
                <entry>
                    <key>skeleton</key>
                    <value>
                        <id>skeleton</id>
                        <visible>true</visible>
                        <position>
                            <x>125</x>
                            <y>50</y>
                        </position>
                        <width>24</width>
                        <height>30</height>
                        <imgFilename>Files/Images/Skeleton.png</imgFilename>
                        <dY>0</dY>
                        <moveDistance>2</moveDistance>
                    </value>
                </entry>
            </movingItems>
            <staticItems>
                <entry>
                    <key>background</key>
                    <value>
                        <id>background</id>
                        <visible>true</visible>
                        <position>
                            <x>0</x>
                            <y>0</y>
                        </position>
                        <width>500</width>
                        <height>500</height>
                        <imgFilename>Files/Images/background2.png</imgFilename>
                    </value>
                </entry>
            </staticItems>
        </item>
    </MapSections>
    <MapSections>
        <item> <!-- Empty items - this format is ignored by the levelController -->
            <id>defaultId</id>
            <mapX>0</mapX>
            <mapY>0</mapY>
            <playerControlledItems/>
            <movingItems/>
            <staticItems/>
        </item>
        <item>
            <id>defaultId</id>
            <mapX>0</mapX>
            <mapY>0</mapY>
            <playerControlledItems/>
            <movingItems/>
            <staticItems/>
        </item>
    </MapSections>
    <maxWidth>2</maxWidth> <!-- map width for level map in entirety -->
    <maxHeight>2</maxHeight> <!-- map height for level map in entirety -->
    <atX>0</atX> <!-- starting position -->
    <atY>0</atY> <!-- starting position -->
    <levelId>Level1</levelId> <!-- Level name / ID -->
</LevelMap>
⚠️ **GitHub.com Fallback** ⚠️