Programming

By Space Toothpaste

Ben (Technical Lead)
Chandra (Creative Lead)
Cynthia (Artist)
Douglas (Layout Designer)
Mateo (Systems Designer)

From starting this project I (Ben Elwood) wanted to make the components and systems easy to expand. This meant using polymorphism to assist with the coding of new systems or components.

I started with the components. A general component has:

  • A Type (What is it?)
  • A Repair Cost (How long does it take to repair)
  • A boolean to store if it is broken or not
  • A function to damage the component (Some components may not just break if damaged)

The first component that differed from that was the battery component. The battery component has, in addition to the general component things, a charge (The amount of charge remaining in the battery) and also functions to allow you to consume or recharge that charge.

I did the same with systems. A general system has:
  • A list of components that it needs to work
  • A list that stores all the components currently connected
  • A function that checks if it is working and consumes power if it is
  • A function to use a battery if it is connected and needed

I so far have just created the life support systems, and while they each have different required components they don't have any special functions.

The next part of this was to create the code for life support. The main way the game would end is via your atmosphere becoming unsafe (from CO2 being too high, to oxygen being too low, to the pressure being too high or low).
This script actually handled the creation and removal of CO2, Oxygen, and Nitrogen (Checking that each system was working, and acting as the "breathing"). I found online what the safe max and min percentages were, and based the game's system around that. CO2 starts to harm you if it gets above 15% and O2 starts to harm you if it gets below 19%. The pressure starts to harm you if it gets above 6 atmospheres of pressure, and also if it gets below the Armstrong limit (about 0.0617 atmospheres).
The actual speed at which the oxygen/co2 was breathed or generated/scrubbed isn't based on existing science, but more on numbers that would be easily changed for the game. As this is, at the end of the day, a game.


Blog By Ben Elwood.

Comments

Popular posts from this blog

Forming Group 'Space Toothpaste'

Mission Control Manual