how to make a game like space invaders. what is space invaders? a shmup (shoot-em-up) player has one...
TRANSCRIPT
![Page 1: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/1.jpg)
How to Make a Game Like
Space Invaders
![Page 2: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/2.jpg)
What IS Space Invaders?
• a SHMUP (shoot-em-up)
• Player has one ship, enemy has many
• Player and enemies interact by shooting at each other
• Top-down 2D (usually)
![Page 3: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/3.jpg)
Concepts
![Page 4: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/4.jpg)
Video Frames/Ticks
• A film is made of 24 still pictures per second
• Motion is achieved by small changes to each picture, but 24 fps is still fast
![Page 5: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/5.jpg)
Video Frames/Ticks 2
• Video games are usually 30 or 60-80 fps
• Video games achieve movement by moving each screen object a little bit every frame
![Page 6: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/6.jpg)
Shmups are very object-oriented
• Ships are objects
• Bullets are objects
• The player is an object
• Explosions are objects
• Levels can be objects (certainly made of objects)
![Page 7: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/7.jpg)
Question
• How many bullets can be on the screen at once?
• Space Invaders = 1 for player, 2 for enemies
• Modern = completely arbitrary
![Page 8: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/8.jpg)
Lists
• A great way to store and organize objects
• Most beginners get hung up here
• Conceptually harder than arrays
• C and C++ use linked lists (with pointers)
• BlitzBasic has list:TList
![Page 9: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/9.jpg)
What is a ship?
• Is-dead flag• Health value• X and Y positions• Path logic and data• Reference to the art• Animation state• Bullet/missile launch state• Bullets and Explosions are very similar to
ships!
![Page 10: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/10.jpg)
What is a player ship?
• Not as much, surprisingly
• Path logic is in your fingers, not in code
• So keyboard state checks (for avatar control) go here
![Page 11: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/11.jpg)
What is a bullet/missile?
• Like a ship, but (usually) simpler movement• Erased when it goes off screen, not when it
reaches the end of its path• State: Player shot or Enemy shot• Each Player-bullet collides against every
enemy• Each Enemy-bullet collides against player
![Page 12: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/12.jpg)
So, to make space invaders…
• Make a player• Make a bunch of enemies• Move them every frame, have them create
bullets• Move the bullets every frame• Check for enemy-bullet collision every frame• Keep going, even if all the enemies or the
player is dead
![Page 13: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/13.jpg)
Programming
![Page 14: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/14.jpg)
Main loop in PseudocodeMain(){
SetupEverything();
CreatePlayer();CreateAllEnemies();
done = false;while (done == false){
TickPlayer();TickEnemyList();TickBulletList();
DrawPlayer();DrawEnemyList();DrawBulletList();
if (EscapeKeyPressed() == TRUE)done = TRUE;
WaitForNextFrame();}
ShutDownEverything();}
![Page 15: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/15.jpg)
Timer callback versionTimerFunction()
{
TickPlayer();
TickEnemyList();
TickBulletList();
// some systems, like Flash and Torque, do the drawing for you
DrawPlayer();
DrawEnemyList();
DrawBulletList();
if (EscapeKeyPressed() == TRUE)
done = TRUE;
}
![Page 16: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/16.jpg)
TickBulletList()TickBulletList(){
ForEach( bullet){
x = x + dx;y = y + dy;
if (BulletOffScreen()){
isDead = TRUE;}ForEach(enemy){
if (Collides(enemy, bullet)){
isDead = TRUE;DamageEnemy(enemy);
}}
}
RemoveDeadBulletsFromList();}
![Page 17: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/17.jpg)
Basic Math
![Page 18: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/18.jpg)
Vectors and Offsets
• Where is your Ship? X and Y
![Page 19: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/19.jpg)
Vectors and Offsets 2
• Where is your bullet? Also X and Y• Where is your bullet in relation to your ship?
bulletX – shipX and bulletY – shipY
![Page 20: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/20.jpg)
Vectors and Offsets 3• How far apart are they? Pythagorean
theorem (sqr(a) + sqr(b) = sqr(c))
• This requires a slow square root function
![Page 21: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/21.jpg)
Vectors and Offsets 2
• What direction from the ship to the bullet? Arctangent
• Atan2(bulletX – shipX, bulletY – shipY)
![Page 22: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/22.jpg)
Arctangent• Usually gives a direction in radians, from 0-(2*PI)• PI is 3.1415927 (= 180 degrees)• Radian to degrees = dir / (PI*2) * 360
![Page 23: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/23.jpg)
Vectors and Offsets 3
• So you can describe the relationship between two objects on the screen in two different ways
![Page 24: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/24.jpg)
Offsets
• Offset = x and y coordinates (or differences)
![Page 25: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/25.jpg)
Vectors
• Vector = direction and distance
![Page 26: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/26.jpg)
Translate Offsets to Vectors
• Get distance with Pythagoras
• Get direction with Atan2 (Arctangent)
![Page 27: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/27.jpg)
Translate Vectors to Offsets
• X = sin(direction) * distance
• Y = cos(direction) * distance
![Page 28: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/28.jpg)
Vectors & Offsets = important
• Shooting bullet directly at the player
• Homing missiles
• Collision detection (is bullet close enough?)
• Enemy follows path
![Page 29: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/29.jpg)
What is TurnTowardsPoint()
• If you want the homing missile to turn slowly towards the enemy (instead of instantly) what do you do?
• The answer is the TurnTowardPoint() algorithm.
![Page 30: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/30.jpg)
Designing Your Game
![Page 31: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/31.jpg)
Bosses
• Traditional part of shmups
• Each one is a love letter to the player
• Multiple weapons• Multiple parts• Multiple Modes• It’s a boss, not just an
extended enemy
![Page 32: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/32.jpg)
Powerups
• Functionally just like Bullets
• Give expanded powers to the player
• Key to one of the basic metagames
![Page 33: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/33.jpg)
The Game Modes
• Play mode
• Start mode
• Results mode (you are dead, how’d you do)
• Pause mode
• Credits mode
• Options mode
![Page 34: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/34.jpg)
Game Modes 2
• Recognize that game modes are just states
• Completely different states than game states
![Page 35: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/35.jpg)
Scrolling Background
• Space Invaders background was black
• Galaga and others had winking, scrolling stars
• Zaxxon and others started making the background complex and interactive
• Treasure games are famous for complex, puzzle-like environments
![Page 36: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/36.jpg)
What are Shmup levels?
• Hand-crafted definitions of when each enemy shows up
• The things that happen before a boss shows up
• Divisions of art
• Scoring opportunities
![Page 37: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/37.jpg)
How are levels made?
• Make the editors yourself, for yourself
• Ship path editor (mirror-able)
• Level editor• Place art tiles• Place ship spawn
points• Place camera path• Boss editor
![Page 38: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/38.jpg)
![Page 39: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/39.jpg)
![Page 40: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/40.jpg)
![Page 41: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/41.jpg)
![Page 42: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/42.jpg)
![Page 43: How to Make a Game Like Space Invaders. What IS Space Invaders? a SHMUP (shoot-em-up) Player has one ship, enemy has many Player and enemies interact](https://reader033.vdocuments.site/reader033/viewer/2022061305/5513e4c655034646298b5a69/html5/thumbnails/43.jpg)