TWiki home TWiki > Team5 > FilesAndClasses (r1.1 vs. r1.3) TWiki webs:
Main | TWiki | Know | Sandbox
Team5 . { Changes | Index | Search | Go }
 <<O>>  Difference Topic FilesAndClasses (r1.3 - 07 Nov 2004 - BrianYoung)
Changed:
<
<

    • float WORLD_SIZE - how big the world is; in consequence, each grid square is WORLD_SIZE/GRID_RES on a side
>
>

    • int WORLD_SIZE - how big the world is; in consequence, each grid square is WORLD_SIZE/GRID_RES on a side
Added:
>
>

    • float zAt(float x, float y) - find the height of the terrain at a point
Added:
>
>

    • float _terrain[WORLD_SIZE][WORLD_SIZE] - hold the world height map

 <<O>>  Difference Topic FilesAndClasses (r1.2 - 05 Nov 2004 - BrianYoung)
Changed:
<
<

  • main() and all its cousins
>
>

  • main()
Added:
>
>

    • Also, a gridFromPos(Tuple position) function to translate absolute coordinates into a grid location
Added:
>
>

    • void timeStep() - advance the world one time step
    • unsigned whenIsNow() - return the current time step
Changed:
<
<

    • list<Enemy*&gt[GRID_RES][GRID_RES]; _enemy_grids - hold all enemies, filed by the grids they're in. I use list instead of vector, because in almost every time we use it we'll be cycling through every enemy in a grid, either checking collisions, or moving, or whatever.
>
>

    • list<Bullet*> _bullets - hold all bullets in the world
    • list<Enemy*>[GRID_RES][GRID_RES] _enemy_grids - hold all enemies, filed by the grids they're in. I use list instead of vector, because in almost every time we use it we'll be cycling through every enemy in a grid, either checking collisions, or moving, or whatever.
Added:
>
>

    • unsigned _step - how many steps the world has made
    • bool _isPaused - pause state of the world
Changed:
<
<

    • Tuple _heading - which way the player is facing
>
>

    • float _heading - which way the player is driving
    • float _aiming - which way the player is shooting
Added:
>
>

    • float _size - radius for hit detection
Added:
>
>

bullet:

  • the Bullet class, anything that shoots through the world
  • public functions:
    • Constructor, destructor
    • From/to "aimed bullet" constructor
    • target "homing" constructor
    • void move() - update position
    • void setMotion(float _speed, float _turnRate) - set motion characteristics
    • void setDam(int direct, int splash, float size) - set damage characteristics
  • private functions:
  • data:
    • Tuple _position - current position
    • float _speed - bullet's speed
    • float _turnRate - max turning rate, for homing weapons
    • unsigned born - when it was created, for determining death
    • float _heading - which way the bullet is going
    • Enemy* _target - for homing weapons
    • bool _isHoming - behaviour flag
    • bool _isPlayers - friend/foe flag
    • int _directDam - damage on direct hit
    • int _splashDam - damage on hit nearby
    • float _splashSize - range of nearby damage

 <<O>>  Difference Topic FilesAndClasses (r1.1 - 05 Nov 2004 - BrianYoung)
Added:
>
>

%META:TOPICINFO{author="BrianYoung" date="1099625160" format="1.0" version="1.1"}% %META:TOPICPARENT{name="ProjectThree"}% List here the files we have, and what functions are within them. To keep things consistent, let's have all files in pairs, with foo.h having delarations and foo.cpp having definitions, no exceptions. Enclose any .h file with

#ifndef FOO_DEFINED
#define FOO_DEFINED 1

// Contents of file

#endif // FOO_DEFINED
I know it'll be hard to remember, but if we can keep this page updated it'll make our lives easier. -- BrianYoung - 04 Nov 2004

globals:

  • constants
    • int GRID_RES - how many sections each dimension of the world is split into
    • float WORLD_SIZE - how big the world is; in consequence, each grid square is WORLD_SIZE/GRID_RES on a side
    • int PLAYER_MAX_HEALTH - health the player starts with
  • main() and all its cousins
  • define a GridLoc struct for holding x, y pairs of ints, and passing the pairs around easily

geometry:

  • Same as for the golf game, to have the Tuple class. Can stand to be switched out for whatever coordinate system would work with the Windows API and whatever graphics framework we end up in - Mac?

tankworld:

  • the TankWorld? class, written as a singleton
  • public functions:
    • static TankWorld?* instance() - singleton accessor
    • void changeEnemyGrid() - move an enemy from one grid to another
  • private functions:
    • Constructor, copy, assignment
  • data:
    • list<Enemy*&gt[GRID_RES][GRID_RES]; _enemy_grids - hold all enemies, filed by the grids they're in. I use list instead of vector, because in almost every time we use it we'll be cycling through every enemy in a grid, either checking collisions, or moving, or whatever.
    • static TankWorld?* theOneTankWorld - singleton pointer

player:

  • the Player class, written as a singleton
  • public functions:
    • static Player* instance() - singleton accessor
    • Tuple position() - return the player's position in the world
    • int score(int points) - add to the player's score and return it
  • private functions:
    • Constructor, copy, assignment
  • data:
    • Tuple _position - where the player is
    • Tuple _heading - which way the player is facing
    • int _health - how many more hits the player can take
    • int _score - points accumulated
    • static Player* theOnePlayer - singleton pointer

basicenemy:

  • the abstract Enemy class, which is actually anything in the world you can shoot
  • public functions:
    • void draw() - draw to the current buffer; pure virtual function
    • void move() - update the enemy's position; pure virtual function
    • bool hit(int points) - do damage; return true if destroyed
  • private functions:
    • bool checkGrid() - ensure the enemy is still stored in the proper grid; move it if not
  • data:
    • Tuple _position - enemy's position in the world
    • int _hitpoints - number of hitpoints remaining; -1 represents invulnerability
    • int _pointvalue - how much a kill is worth; can be negative for terrain
    • GridLoc _inGrid - which grid square we're int

Topic FilesAndClasses . { View | Diffs | r1.3 | > | r1.2 | > | r1.1 | More }
Revision r1.1 - 05 Nov 2004 - 03:26 GMT - BrianYoung
Revision r1.3 - 07 Nov 2004 - 22:24 GMT - BrianYoung
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback.