Difference between revisions of "Code How To's"

From TACWiki
Jump to: navigation, search
(New page: This page provides tutorials for some of the most common actions a programmer may wish to implement. ==Tweak Game Parameters== It is often helpful to adjust variables during runtime. Thi...)
 
Line 27: Line 27:
 
* Set the default value for the variable in the config file
 
* Set the default value for the variable in the config file
 
** The config file is not yet implemented, so for now just the default value in ColonyGameManager
 
** The config file is not yet implemented, so for now just the default value in ColonyGameManager
 +
 +
==Create a New Minigame==
 +
 +
* Declare the class
 +
* Implement Update()
 +
* Implement Draw()
 +
* Create a new game mode
 +
* End the game
 +
 +
==Display a Static Image==
 +
 +
==Create a Game Object==
 +
 +
==Get User Input==
 +
 +
==Play a Sound==
 +
 +
==Display Text==
 +
 +
==Use a Particle Effect==
 +
 +
==Create a New Particle Effect==
 +
 +
==Write to the Experimental Log==
 +
 +
==Output Data Through the Parallel Port==

Revision as of 11:45, 10 October 2007

This page provides tutorials for some of the most common actions a programmer may wish to implement.

Tweak Game Parameters

It is often helpful to adjust variables during runtime. This can be accomplished by adding them to the game's cheat menu, which can be activated in game by pressing ctrl+alt+c.

  • Add the variable to the Game Manager
    • Declare a new member variable in ColonyGameManager next to the other tweakable variables
    • Create a getter and setter for that variable
  • Add the variable to the Control Panel
    • Open ColonyControlPanel.cs[Design]
    • If the minigame using this variable does not yet have a group, do the following
      • Create a new radio button in the upper left corner in the same manner as the other games
      • Create a new group anywhere in the right area (only the left most 250 px or so are visible in the game)
      • Add a new if block to butUpdate_Click(object sender, EventArgs e)
        • Double click on the form to bring up the code
        • If this creates a new empty function, just delete the new function
      • Move the group out of view in hidePanels()
      • Double-click the new radio button to create the radNewminingame_CheckedChanged(...) function
        • Fill this function with code similar to radColony_CheckedChanged(...)
      • Add a new if block in UpdateMode(...)
    • Add a label and text box to the minigame's group in the same manner as the existing games
    • Add the line ColonyBaseApplication.GameManager.NewVariable = ...; to butUpdate_Click(...)
    • Add the line txtNewVariable.Text = "" + ColonyBaseApplication.GameManager.NewVaraible; to ControlPanel_Load(...)
  • Use the variable in the minigame
    • The value can be accessed with ColonyBaseApplication.GameManager.NewVariable
  • Set the default value for the variable in the config file
    • The config file is not yet implemented, so for now just the default value in ColonyGameManager

Create a New Minigame

  • Declare the class
  • Implement Update()
  • Implement Draw()
  • Create a new game mode
  • End the game

Display a Static Image

Create a Game Object

Get User Input

Play a Sound

Display Text

Use a Particle Effect

Create a New Particle Effect

Write to the Experimental Log

Output Data Through the Parallel Port