Stuart Mathews
  • Home

    Latest

    • Functional XML (Game Development) 19-02-2023
    • Midnight in Paris (Blog) 04-01-2023
    • Christmas Run (Running) 26-12-2022
    • So far, it works (Game Development) 25-12-2022
    • Traveling Europe (Blog) 01-11-2022
    • Applying and Evaluating Pattern-Oriented Designs In Improving Code Quality In Complex Software (Code) 01-10-2022
    • Knoydart Peninsula, Scotland (Running) 01-10-2022
    • CppGameLib (Game Development) 12-09-2022
    • Thoughts on Multiplayer Game Co-operation and Distributed Computing (Game Development) 04-07-2022
    • The fading importance of ego and the utility of the checklist (Blog) 18-04-2022

    Most Read This Year

    • Thoughts on Multiplayer Game Co-operation and Distributed Computing (Game Development)
    • The fading importance of ego and the utility of the checklist (Blog)
    • Differential Calculus (Blog)
    • Traveling Europe (Blog)
    • Knoydart Peninsula, Scotland (Running)
    • CppGameLib (Game Development)
    • Applying and Evaluating Pattern-Oriented Designs In Improving Code Quality In Complex Software (Code)
    • So far, it works (Game Development)
    • Christmas Run (Running)
    • Midnight in Paris (Blog)

    Recently Featured

    • Functional XML (Game Development)
    • So far, it works (Game Development)
    • Thoughts on Multiplayer Game Co-operation and Distributed Computing (Game Development)
    • A software engineering process for delivering software (Code)
    • Encrypting strings at rest (Code)
    • ISO27001, Machine-Learning and Game dev (Blog)
    • Implementing a Vignette (Code)
    • Fixing the thunder in my feet (Running)
    • Sufficiently Complex (Blog)
    • Try Monad, Progress and Lockdown Rules (Blog)
    • Downloads
  • Blog

    Recent in Blog

    • Midnight in Paris 04-01-2023
    • Traveling Europe 01-11-2022
    • The fading importance of ego and the utility of the checklist 18-04-2022
    • Differential Calculus 14-04-2022
    • Fading importance and the utility of lists 29-12-2021
    • Abstractions and Patterns 11-10-2021
    • Mind Maps 02-10-2021
    • ISO27001, Machine-Learning and Game dev 23-04-2021
    • Sufficiently Complex 02-12-2020
    • Deadlocks and databases 19-10-2020

    Most Read In Blog This Year

    • The fading importance of ego and the utility of the checklist (Blog)
    • Differential Calculus (Blog)
    • Traveling Europe (Blog)
    • Midnight in Paris (Blog)

    Featured In Blog

    • ISO27001, Machine-Learning and Game dev (Blog)
    • Sufficiently Complex (Blog)
    • Try Monad, Progress and Lockdown Rules (Blog)
    • Rails, Euclid and Generating Mazes (Blog)
    • Set Theory, Ruby and Upgrades (Blog)
    • Time shifting, CS algorithms and Game Architecture (Blog)
    • The Fourier transform, math, malware and decoupling (Blog)
    • Encryption and network protocols (Blog)
    • Mazer Game Design and Network Security (Blog)
    • Changing object states and 3D transformations (Blog)
  • Code

    Recent in Code

    • Applying and Evaluating Pattern-Oriented Designs In Improving Code Quality In Complex Software 01-10-2022
    • Polynomial Calculator 16-03-2022
    • A software engineering process for delivering software 27-02-2022
    • Counting and Permutations 08-02-2022
    • Encrypting strings at rest 10-12-2021
    • Implementing a Vignette 26-01-2021
    • Functional programming paradigms and techniques 19-07-2020
    • Ruby RSpec let and let! diffirences 08-07-2020
    • Convolution, Running and Finite State Machines 08-03-2020
    • LanguageExt tutorial, games and timing 08-08-2019

    Most Read In Code This Year

    • Thoughts on Multiplayer Game Co-operation and Distributed Computing (Game Development)
    • CppGameLib (Game Development)
    • Applying and Evaluating Pattern-Oriented Designs In Improving Code Quality In Complex Software (Code)
    • So far, it works (Game Development)
    • Functional XML (Game Development)

    Featured In Code

    • Functional XML (Game Development)
    • So far, it works (Game Development)
    • Thoughts on Multiplayer Game Co-operation and Distributed Computing (Game Development)
    • A software engineering process for delivering software (Code)
    • Encrypting strings at rest (Code)
    • Implementing a Vignette (Code)
    • Protocols, Packets and Prototypes (Game Development)
    • Animated aliens and alternatives algorithms (Game Development)
    • Retro sounds, Event Manager and some running (Game Development)
    • Basic key frame animations, implicit casts and some other aspect (Game Development)
  • Running

    Recent in Running

    • Christmas Run 26-12-2022
    • Knoydart Peninsula, Scotland 01-10-2022
    • Winter running 09-12-2021
    • Itchy legs and tracksuit bottoms 03-09-2021
    • Heart rate inconsistency 26-04-2021
    • Chequered Leaves and the Yellow Runner 01-01-2021
    • Fixing the thunder in my feet 04-12-2020
    • Faster than usual 17-06-2020
    • The uncomfortable steady-state 03-06-2020
    • Hot weather running 31-05-2020

    Most Read In Running This Year

    • Knoydart Peninsula, Scotland (Running)
    • Christmas Run (Running)

    Featured in Running

    • Smashrun
    • Strava profile
  • Gaming

    Recent in Gaming

    • Functional XML 19-02-2023
    • So far, it works 25-12-2022
    • CppGameLib 12-09-2022
    • Thoughts on Multiplayer Game Co-operation and Distributed Computing 04-07-2022
    • Applying and Evaluating Functional Programming Paradigms and Techniques in Developing Games 19-02-2022
    • Christmas Period Tinkering 29-12-2021
    • Mazer Game Architecture Report 22-11-2020
    • Ruby Mazer 26-05-2020
    • Protocols, Packets and Prototypes 29-11-2019
    • Pleasure And the Execution of Thoughfulness 29-09-2019

    Most Read In Gaming This Year

    • Thoughts on Multiplayer Game Co-operation and Distributed Computing (Game Development)
    • CppGameLib (Game Development)
    • So far, it works (Game Development)
    • Functional XML (Game Development)

    Featured in Gaming

    • Game loop
    • Featured
  • Portfolio

    Featured in Portfolio

    • App-V (Citrix)
    • Citrix Fast Connect SDK
    • AppDNA
    • Cloud Copy and Paste
    • Software Audit Pro
    • Investment Manager
    • Meal tracker
    • Cross platform broker
  • About

So far, it works

Details
Stuart Mathews
Code
Game Development
25 December 2022
Created: 25 December 2022
Last Updated: 25 December 2022
Hits: 302

Since Traveling Europe, I've been focusing mainly on my side project. Specifically, I've been trying to implement a level editor for my prototype game engine:

I found this stuff such a pleasing distraction.

For a while, I've been creating new levels that are automatically generated. That is, the generation and placement of the level pickups have been random, and the level, which is basically a maze, is automatically created & configured each time. What I needed, was to be able to create a way to design levels more explicitly and creatively.

I decided that I'd start creating a level editor project which would read all the game's assets and use them to define the level and place game objects in the level. The idea is then to be able to save the configuration of the level design in the editor out to a file, like a level file, which would then be loaded into the game.

This is what a designed level gets serialized down to:

<?xml version="1.0" encoding="utf-8"?>
<level cols="10" rows="10" autoPopulatePickups="False">
  <room number="0" top="True" right="True" bottom="False" left="True">
    <object name="GoldPickup" type="Pickup" resourceId="19" assetPath="game/assets/coin_gold.png">
      <property name="value" value="5" />
    </object>
  </room>
  <room number="1" top="True" right="False" bottom="False" left="True">
    <object name="GoldPickup" type="Pickup" resourceId="19" assetPath="game/assets/coin_gold.png">
      <property name="value" value="5" />
    </object>
  </room>
...

As I also wanted an editor to place pickups etc, I needed to define the properties of the pickups like how many points each type of pickup would have and which asset should be used to draw the pickup etc. This allows me to configure the maze by simply clicking on the walls to hide/show them. Also, I can add arbitrary game objects (like pickups) and then configure their properties before adding them to the room. These will then be loaded when the level starts up in the game.

The assets that the game uses are defined in a resource file which specifies the metadata about the asset, like its path, the type of asset and other metadata. I use this file, just like the game does and that's how I can load and manipulate the same assets that the game has access to. This is what the resources.xml file looks like: 

<?xml version="1.0" encoding="utf-8"?>

<!-- List of all asset in the game -->
  <Asset uid="4" scene="0" name="medium.wav" type="fx" filename="Assets/medium.wav"></Asset>
  <Asset uid="5" scene="0" name="low.wav" type="fx" filename="Assets/low.wav"></Asset>  
  <Asset uid="9" scene="3" name="p1.png" type="graphic" filename="Assets/Platformer/Base pack/Player/p1_walk/p1_walk.png" width="256" height="512">
    <sprite>
      <animation>
        <keyframes>
          <keyframe x="0" y="0" w="67" h="92"/>
          <keyframe x="66" y="0" w="66" h="93"/>
          <keyframe x="132" y="0" w="67" h="92"/>
          <keyframe x="0" y="93" w="67" h="93"/>
          <keyframe x="67" y="93" w="66" h="93"/>
          <keyframe x="133" y="93" w="71" h="92"/>
          <keyframe x="0" y="186" w="71" h="93"/>
          <keyframe x="71" y="186" w="71" h="93"/>
          <keyframe x="142" y="186" w="70" h="93"/>
          <keyframe x="0" y="279" w="71" h="93"/>
          <keyframe x="71" y="279" w="67" h="92"/>
        </keyframes>
      </animation> 
    </sprite>  
  </Asset>
  <Asset uid="10" scene="3" name="p2.png" type="graphic" filename="Assets/Platformer/Base pack/Player/p2_walk/p2_walk.png" width="256" height="512">
     <sprite>
      <animation>
        <keyframes>
          <keyframe x="0" y="0" w="67" h="92"/>
          <keyframe x="67" y="0" w="66" h="93"/>
          <keyframe x="133" y="0" w="66" h="91"/>
          <keyframe x="0" y="93" w="67" h="91"/>
          <keyframe x="67" y="93" w="66" h="91"/>
          <keyframe x="133" y="93" w="69" h="90"/>
          <keyframe x="0" y="184" w="69" h="91"/>
          <keyframe x="69" y="184" w="69" h="92"/>
          <keyframe x="138" y="184" w="68" h="92"/>
          <keyframe x="0" y="276" w="69" h="93"/>
          <keyframe x="69" y="276" w="67" h="92"/>
        </keyframes>
      </animation> 
    </sprite>  
  </Asset>
 
</Assets>

It's taken me a while to get to this point because for a long time I've not actually been concerned with not having this ability, as my main concern was working on the actual game engine code. The thing that was taking a lot of my time, was getting the framerate to be consistent and to run at a constant framerate.

Also, now that I've got to a point where the game engine is basically functional, I can focus on introducing elements of a primitive game like characters, AI and stuff like that which really depends on the rest of the system is predictable and working well.

Also, one of the other main reasons why I needed a way to create levels explicitly like this, is so that I can get two network games to load the same level instead of both loading two different randomly generated levels!

The levels are XML and I'm enjoying the process of writing the level generation code in C# and then writing the corresponding level loading routines in C++. I used JSON to define the network protocol for the multi-player network functionality because it's a bit less verbose than XML, but as the XML is used to define the game settings and to specify the game's resources, I've just opted to use XML for defining the levels also.

So far, it works OK...

 

 

 

 

 

 

Write comment (0 Comments)

More Articles ...

  1. Thoughts on Multiplayer Game Co-operation and Distributed Computing
  2. A software engineering process for delivering software
  3. Encrypting strings at rest
  4. ISO27001, Machine-Learning and Game dev
  5. Implementing a Vignette
  6. Fixing the thunder in my feet
  7. Sufficiently Complex
  8. Try Monad, Progress and Lockdown Rules
  9. Rails, Euclid and Generating Mazes
  10. Set Theory, Ruby and Upgrades
Page 2 of 65
  • Start
  • Prev
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • Next
  • End

Topics

Running (36) Programming (34) Game development (28) Random (22) Impressions (19) holiday (19) Math (18) C++ (16) Wierd (12) Gym (11) Traveling (10) Functional programming (10) Software Engineering (10) TCP/IP (9) Networking and security (7) Investing (6) Linux kernel (6) DirectX (6) XML (5) Ruby (5)

Twitter

Tweets by @stumathews

Latest

  • Functional XML (Game Development) 19-02-2023
  • Midnight in Paris (Blog) 04-01-2023
  • Christmas Run (Running) 26-12-2022
  • So far, it works (Game Development) 25-12-2022
  • Traveling Europe (Blog) 01-11-2022
  • Applying and Evaluating Pattern-Oriented Designs In Improving Code Quality In Complex Software (Code) 01-10-2022
  • Knoydart Peninsula, Scotland (Running) 01-10-2022
  • CppGameLib (Game Development) 12-09-2022
  • Thoughts on Multiplayer Game Co-operation and Distributed Computing (Game Development) 04-07-2022
  • The fading importance of ego and the utility of the checklist (Blog) 18-04-2022

Recent

  • Functional XML
  • Midnight in Paris
  • Christmas Run
  • So far, it works
  • Current Reading

Share This

Follow Me

Login

  • Login
  • Webmail
  • Admin
  • Downloads
Bootstrap is a front-end framework of Twitter, Inc. Code licensed under MIT License. Font Awesome font licensed under SIL OFL 1.1.