Board::Run()

Board::Run() is one of the two main procedures/functions in our game (the other is Draw()). Due to its importance let's organize and lay down its structure here so that we can debug / code it easier.

void Board::Run() {

  1. catch Esc
    • pause or resume game
  2. if game is paused, check if mouse is within the pause menu, if we have one
    • let another function, let's call it F1() here, handle the mouse for the menu
    • don't return control to this function (meaning don't update anything at all)
  3. update level timer
  4. update cash
  5. read off mouse coordinates
  6. if mouse is within user interface area
    • let another function, let's call it F2(), handle it
    • then return control to the rest of this function
  7. else if mouse is within the board area
    • let another function, let's call it F3(), handle it
    • then return control to the rest of this function
  8. update Sprite objects by doing either one of the two methods:
    • for each tile
      • get its Sprite object and call its Run()
      • update its drawing coordinates based on current scrolling parameters
      • somehow get its new position for moving Sprite objects like Pest and update the board by moving the object to a different tile
    • for each 'alive' Sprite object
      • call its Run()
      • update its drawing coordinates based on current scrolling parameters
      • get its new position and update the board
  9. spawns new pests if necessary
  10. prepare for the drawing of danger indicators

Note: wall/defense creations should be handled by F2() & F3(); F2() handles the mode changes when the player clicks buttons (e.g. from build wall mode to build defense mode) while F3() handles the actual building of walls and defenses (this includes the drag-and-build action etc)

}

Feel free to modify the structure or add new items that you think appropriate

page_revision: 1, last_edited: 1160073689|%e %b %Y, %H:%M %Z (%O ago)
Unless stated otherwise Content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.