Design & Development of “That Tank Game – in 3D!!!” Cs 426 Jason Leigh


Download 499 b.
Sana10.01.2019
Hajmi499 b.


Design & Development of “That Tank Game – in 3D!!!”


Main Steps

  • Brainstorm the gameplay using Storyboards.

  • Choose Initial Gameplay Constraints / Rules.

  • Prioritize Development.

  • Design Finite State Machine and Data Structures.

  • Build incremental prototype incorporating each feature in your priority list.

  • Use simple placeholder 3D objects while elaborate objects and art work are being designed.

  • Add sound effects when a simple working game is in place. Ie you have a tank that can shoot an enemy.

  • Play with each prototype and add new features to priority list.

  • Repeat step 2. Sometimes you will need to modify the game rules to improve “fun-ness”/gameplay.



1. Brainstorm the Gameplay Using Storyboards















2. Choose Initial Gameplay Constraints / Rules (these can change as you play-test the game)

  • The World

    • Bounded by a high wall
    • You are dead with 1 hit of the bullet
    • All enemies are dead with 1 hit of the bullet including boss
    • When tanks/enemies/bosses collide with scenary, they glance off
  • Bullets

    • Bullets bounce off all surfaces- all bullets hurt everything including yourself
    • Bullets travel a max distance before fading
    • Bullets increase transparency with distance
    • Bullets do not collide with each other- they simply pass thru
  • Enemy

    • # enemies attacking you is dependent on the level#
    • Formula might be: maxEnemyCount = 1 + level# (ie a min of 2 enemies always)
    • Enemy gets smarter at each level by varying AI characteristics
    • Can drive and shoot only in the direction they are facing.
    • Can shoot multiple bullets.
  • Boss

    • Appears after N enemies killed
    • Can move and drive in any direction
    • Boss gets smarter at each level
    • Boss explodes as a series of destructive bullets firing in all directions
    • # of bullets dependent on the level maybe... have to adjust this during play test
  • Tank

    • Can shoot multiple bullets
    • Start with 5 lives
    • After killing boss you get 1 free life


3. Prioritize Development Develop main core of the game FIRST, then iterate to improve.

  • Create placeholder models

  • Create main game loop

  • Add tank navigation and collision detection with scenery

  • Add bullets and bullet dynamics (bounce off scenery)

  • Add enemies and initial AI

  • Do bullet/enemy/tank collision tests

  • Add initial sound effects

  • Add boss

  • Add evasion AI

  • Add intro/outtro screen and scoreboard

  • Add help screen

  • Improve all aspects of game

    • Improve AI
    • Tweak gameplay constraints- e.g. number of lives, powerups etc.
    • Add improved models
    • Add improved sound effects
    • Add improved special effects


Tip: Define simple sets of autonomous rules and allow FSM to follow them.

  • Result: Creates emergent behavior as enemies respond to the rules of the world, bullets, and tank.



Design Initial Finite State Machine

  • Game FSM

  • INTRO:

  • display intro screen

  • if "START" key selected currentState=INITPLAY

  • if "END" key selected EXIT GAME

  • INITPLAY:

  • init game play

  • currentState=PLAY

  • PLAY:

  • call main game processing function

  • OUTTRO:

  • clean up game states

  • display outtro screen with scores, stats etc.

  • if key pressed currentState=INTRO



Design Initial Finite State Machine

  • Tank FSM

  • INIT:

  • reset position of tank

  • currentState=PLAY

  • PLAY:

  • Do navigation and wall collision

  • If shoot then create bullet object

  • EXPLODE:

  • Play explosion sound

  • Init explosion sequence

  • currentState=EXPLODE_SEQ

  • decrease lives left

  • EXPLODE_SEQ:

  • increment and show 1 timestep of explosion sequence

  • if at last timestep then {

  • cleanup graphics "debris"

  • decrease lives left

  • if lives left = 0 then GameFSM.currentState=OUTTRO

  • otherwise currentState=INIT

  • }



Design Initial Finite State Machine

  • Bullet FSM

  • MOVE:

  • Move in direction of trajectory

  • IF touch wall then bounce

  • If travelled a max distance then currentState = EXIT

  • If touch entity (like tank/enemy) then currentState = EXIT

  • currentState=EXIT

  • EXIT:

  • delete bullet



Design Initial Finite State Machine

  • Enemy FSM

  • INIT:

  • Generate a random position for it in the world

  • PLAY:

  • Do Enemy AI and collision detection on scenary and bullets If detect bullet hit on self then currentState = EXPLODE

  • EXPLODE:

  • Play explosion sound

  • Init explosion sequence

  • currentState=EXPLODE_SEQ

  • increment player score

  • EXPLODE_SEQ:

  • increment and show 1 timestep of explosion sequence

  • if at last timestep then {

  • cleanup graphics "debris"

  • increase enemyCount

  • if enemyCount reaches maxEnemyCount for the game level and bossFlag==0 then spawn boss

  • otherwise currentState=INIT; ie reuse the enemy object

  • }



Design Initial Finite State Machine

  • Boss FSM

  • INIT:

  • Initialize Boss position etc...

  • bossFlag=1

  • PLAY:

  • Do Boss AI and collision detection

  • EXPLODE:

  • Play explosion sound

  • Init explosion sequence

  • currentState=EXPLODE_SEQ

  • Spawn a bunch of exploding bullets in all directions

  • EXPLODE_SEQ:

  • increment and show 1 timestep of explosion sequence

  • if at last timestep then {

  • cleanup graphics "debris"

  • increment level/wave counter

  • increase maxEnemyCount commensurate with level

  • set bossFlag to 0

  • }



Data Structures

  • Create 1 data structure for each FSM

  • GameFSMDS, TankFSMDS, EnemyFSMDS, BossFSMDS, BulletFSMDS

  • E.g.

    • TankFSMDS
      • currentState
      • Model
      • explodeSequenceCounter
  • Useful Tip for Blitz3D: you will likely need to declare global variables. If you do, do not declare them individually. Instead declare them as part of a user-defined TYPE in Blitz3D.

  • Reason: BASIC does not require variable declarations before use so if you misspell variable names you will not know. By declaring it as part of a user-defined TYPE, Blitz3D will perform proper name checking since it has to associate the name with a type.



5. Build incremental prototype incorporating each feature in your priority list

  • Create Blitz3D timing loop and integrated stereo library calls

  • Create stubs for FSMs and FSM Data Structures

  • Useful Tip for Blitz3D: Declare States as const in Blitz3D:

    • Const c_INIT=0
    • Const c_PLAY=1
    • Const c_EXPLODE=2
    • Const c_EXPLODE_SEQ=3
    • Const c_MOVE=4
    • Const c_EXIT=5
    • Const c_INTRO=6
    • Const c_OUTTRO=7
  • Useful Tip for Blitz3D: Variables are not case-sensitive. Ie. Foo is the same as fOo



6. Use simple placeholder 3D objects while elaborate objects and art work are being designed. (or just use Cubes and Spheres)



Design Prototype “Gameboard” The world is bounded by a high wall so you can’t drive outside of it



Write code to do tank navigation and collision detection



Add Bullet movement and response of bullets when they collide with the scenery



Added Enemies and Initial AI



Add Collision Checks with Bullets

  • Basically every object checks for collisions on its own and does the right thing by itself

    • If tank registers a bullet collision then tank explodes
    • If bullet detects a tank or enemy collision then it removes itself
    • If enemy registers a bullet collision then enemy explodes


7. Add sound effects when a simple working game is in place

  • Bullet shots

  • Explosion sounds

  • Bullet bounces

  • Blitz3D API: LoadSound, PlaySound



Added Animated Mesh

  • Instead of static enemy models, added animated models- animated 3DS file.

  • Used models from DarkMatter CD.

  • Blitz3D API: LoadAnimMesh

  • Blitz3D Tip: Collision checks don’t seem to work with animated meshes since it can’t correctly find the first child object.

  • Solution: Create a completely transparent cube and add the animated mesh as a child of the cube. Then collision checks are done to the cube.



Added the Boss FSM and Data Structures



Added Evasion AI

  • For each bullet:

    • Check angle subtended by bullet and enemy
    • If angle is very small (5 degrees) then set enemies evasion flag
    • Game level determines how far ahead the bullet can look.
  • Enemies evade by moving backwards and turning in some arbitrary direction.



Added Scoreboard



Added Intro Screen



Intro screen is just a 3D model



Added Game Over / Outtro screen



Again, Outtro is just a 3D object



Instead of spheres as bullets, I tried using Sprites. Blue sprite for my bullets. Green sprite for enemy bullets. Red sprite for boss bullets.



Changed all sounds to 3D Spatialized Sound

  • Blitz3D has the notion of a Listener which is YOU- the tank (use CreateListener).

  • Then Load sounds with: Load3DSound rather than LoadSound

  • Then use EmitSound on all objects that need to make a sound.

  • Ie. Replace PlaySound with EmitSound calls.

  • Added looping hum to Boss (use LoopSound)

  • Added looping background music



Added Explosion Sprite to Enemies (not Bosses or Tank)



Why Should Bosses Have All the Fun?! Added Power Blast to Tank



Added the Help Screen



Enemy Intro Transition

  • When enemies are first created by the game, they do not just POP into view.

  • They grow from tiny to regular size.

  • This gives a less jarring transition for introducing the enemies.



Closing Remarks About Coding Notice that most of the functions have very similar properties

  • Tank Functions:

    • CreateTank
    • TankProcess – call FSM for each tank (there is only 1)
    • TankFSM
    • TankNavigate
    • TankCheckCollisions
  • Enemies Functions:

    • CreateEnemy
    • EnemiesProcess – call FSM once for each enemy
    • EnemyFSM
    • EraseAllEnemies
    • SpawnAllEnemies
    • EraseEnemy
    • EnemyNavigate
    • EnemyCheckCollisions


8. Play with each prototype and add new features to priority list- time permitting

  • Tweak AI

  • Add different Levels

  • Maybe different enemy types? Add Shields?




Do'stlaringiz bilan baham:


Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2017
ma'muriyatiga murojaat qiling