SlideShare a Scribd company logo
DPP B2 (c)




                                       JOB SHEET

COURSE :               DIPLOMA IN DIGITAL MEDIA DESIGN

SESSION :              JAN - JUN 2012                               SEMESTER :         4

CODE/SUBJECT :         DDM 4323 - GAME DESIGN                       SHEET NO :         JS-8
NO OF STUDENTS :       30                                           WEEK :             8
LECTURER :             AZMI BIN MOHAMED


TOPIC :                8.0     SPACE SHOOTER

                             8.1   Research and create a basics of movie clips and character
                                   movement for space shooter game
SUB-TOPIC :
                             8.2   Add an interactive elements; lives and score for game
                             8.3   Add sound effects using ActionScript.


                       After completing this topic, students should be able to:
LEARNING                     1. Develop their own space shooter games with random enemies.
OUTCOME :                    2. Create an interactive element; lives and score for their games.
                             3. Add a sound effects using ActionScript



TOOLS /                      1. Computer
EQUIPMENTS /                 2. Projector
MATERIALS :                  3. Adobe Flash CS4




INSTRUCTION :

   1. Research the ActionScript for creates a space shooter game, character movement and
      shoot control using keyboard.
   2. Follow step-by-step tutorial below to create a space shooter game.




                                                                                       Page | 1
DPP B2 (c)


PROCEDURE :
STEP                                              KEY POINT

Movie Clip and Movement

1. Open Adobe Flash and create new
   document (ActionScript 2.0)

        Size: 800x600px
        Frame Rate : 24fps
        Background Color: Black


2. Create a Movie Clip by right clicking your
   library tab and selecting "New
   Symbol...", make sure "Movie Clip" is
   selected and choose a name.




3. Flash will create and open the Movie
   Clip for editing, so just paste an image or
   draw a space ship with Flash's drawing
   tools. After drawing your ship, get back
   to the main timeline by click on "Scene
   1":


    At properties panel; put a variable name
    as “ship”.




4. Right click the first frame in your timeline   this.onEnterFrame = function()
   and select "Actions". Type this:               {
                                                        if (Key.isDown(Key.RIGHT))
                                                        {
                                                              Ship._x += 10;
                                                        } else if (Key.isDown(Key.LEFT))
                                                        {
                                                              Ship._x -= 10;
                                                        } else if (Key.isDown(Key.UP))
                                                        {
                                                              Ship._y -= 10;
                                                        } else if (Key.isDown(Key.DOWN))
                                                        {
                                                              Ship._y += 10;
                                                        }
                                                  }




                                                                                  Page | 2
DPP B2 (c)



Shooting

5. This is the second part of the tutorial
   and we are going to enable the ship to
   shoot. Previously we made our ship fly;
   now we are going to make it shoot and
   set limits to where it can go.

   First we need to make our bullets, right
   click the library tab, select "New
   Symbol" and give it the name "Bullet".

   Before clicking OK, click Advanced,
   select "Export for Actionscript" and
   make sure the identifier is "Bullet".



6. We do this because we need to export
   the Bullet Movie Clip during running time
   to create many bullets and we will use
   the name determined in identifier to call
   it later. Draw a small bullet, and position
   it like this:

   This is called registration point, in the
   stage this is the position of the Bullet
   Movie Clip.




7. Now open the actions window of the first      this.onEnterFrame = function()
   frame of the Movie Clip, insert this code:    {
                                                      this._x += 12;
                                                      if (this._x > 800)
                                                      {
                                                            this.removeMovieClip();
                                                      }
                                                 }


8. Now go to the main timeline, select the       var i = 0;
   first frame and open the actions              this.onEnterFrame = function()
                                                 {
   windows. You will see the previous
                                                       .
   codes that we have written. Add this                .
   code to the old one so we can fire our              .
   bullets:                                            else if (Key.isDown(Key.DOWN))
                                                     {
                                                         Ship._y += 5;
                                                       }
                                                       if (Key.isDown(Key.SPACE))



                                                                                  Page | 3
DPP B2 (c)

                                                    {
                                                          i++;
                                                        _root.attachMovie("Bullet",
                                                        "Bullet" + i,
                                                        _root.getNextHighestDepth());
                                                        _root["Bullet" + i]._x =
                                                        Ship._x + 3;
                                                        _root["Bullet" + i]._y =
                                                        Ship._y;
                                                    }
                                               }



9. Before we finish this tutorial, let's put   if (Key.isDown(Key.RIGHT))
   some limits to where our ship can go, we    {
   don't want it to get off the screen. Make         if (Ship.hitTest(800, Ship._y,
   these changes:                                    true))
                                                     {
                                                           Ship._x -= 5;
                                                     }
                                                     Ship._x += 5;
                                               } else if (Key.isDown(Key.LEFT))
                                               {
                                                     if (Ship.hitTest(0, Ship._y,
                                                     true))
                                                     {
                                                           Ship._x += 5;
                                                     }
                                                     Ship._x -= 5;
                                               } else if (Key.isDown(Key.UP))
                                               {
                                                     if (Ship.hitTest(Ship._x - 40, 0,
                                                     true))
                                                     {
                                                           Ship._y += 5;
                                                     }
                                                     Ship._y -= 5;
                                               } else if (Key.isDown(Key.DOWN))
                                               {
                                                     if (Ship.hitTest(Ship._x - 40,
                                                     600, true))
                                                     {
                                                           Ship._y -= 5;
                                                     }
                                                     Ship._y += 5;
                                               }

                                               if (Ship.hitTest(800, Ship._y, true))
                                               {
                                                     Ship._x -= 5;
                                               }




                                                                               Page | 4
DPP B2 (c)



Enemies

10. This is the third tutorial of a series about
    developing a Space Shooter game, in
    this tutorial we are going to make enemy
    ships.

    Create a new Movie Clip and draw your
    enemy ship, don't forget to set the
    identifier to "Enemy" and select "Export
    to Actionscript".




11. Now drag the enemy Movie Clip to the           onClipEvent(load)
    stage, give it an instance name of             {
    "Enemy0", right click it and select                   function reset()
    "Actions". Insert this:
                                                          {
                                                              var timer = 12;
                                                              this._y = Math.random() * 300
                                                              this._x = 550
                                                              mySpeed = Math.ceil(Math.
                                                               random() * 6) + 1;
                                                          }
                                                          reset();
                                                   }


                                                   // This part of the code creates a function called
                                                   reset() when the Movie Clip loads for the first
                                                   time. Inside reset() we set this._y to a random
                                                   number between 0 and 600, this._x to 800 and
                                                   the speed of our enemy to a random number
                                                   between 1 and 6.



12. Then, insert this code:                        onClipEvent(enterFrame)
                                                   {

                                                          this._x -= mySpeed;
                                                          if (this._x < -10)
                                                          {
                                                                reset();
                                                          }

                                                          if (timer >= 12)
                                                          {

                                                              Math.ceil(Math.random() * 2)
                                                              timer = 0;



                                                                                            Page | 5
DPP B2 (c)

                                                       }
                                                       if (dir == 1)
                                                       {
                                                             this._y -= 3;
                                                       } else if(dir == 2)
                                                       {
                                                             this._y += 3;
                                                       }
                                                       timer++
                                                }



13. Add this code in the main timeline before   var nrEnemies = 3;
    the rest of the code.                       for (i = 1; i < nrEnemies; i++)
                                                {
                                                      _root.Enemy.duplicateMovieClip
                                                      ("Enemy" + i,
                                                      _root.getNextHighestDepth());
                                                }


Lives and Score

14. This is the forth part of the development
    of a Space Shooter game. In this tutorial
    we will add lives, scores and game over
    to our game.

    Let's start with score.Open the main
    timeline code and add this variable:        var score = 0;


15. Now open the Bullet's code and add this:    this.onEnterFrame = function()
                                                {
                                                      this._x += 9;
                                                      if (this._x > 550)
                                                      {
                                                            this.removeMovieClip();
                                                      }
                                                      for (i = 0; i < _root.nrEnemies;
                                                           i++)
                                                      {
                                                            if (this.hitTest
                                                               (_root["Enemy" + i]))
                                                            {
                                                            _root["Enemy" + i].reset();
                                                            _root.score += 10;

                                                       this.removeMovieClip();
                                                             }
                                                       }
                                                }

                                                // This is the code we used before to know if a
                                                bullet hits an enemy, so we can put the score
                                                for killing an enemy there.




                                                                                        Page | 6
DPP B2 (c)



16. The score is done; we just need to show
    the player his score. To do that, select
    the Text Tool and draw it on the stage.

   Write "Score:"




17. Now draw another Text box on the
    stage. Select this new Text box and
    change these properties:




18. Now let's make our ship have lives. Add     var lives = 3;
    another variable in the main code:

19. And make these changes in the code          if (this.hitTest(_root["Enemy" + i]))
    that checks if the player crashed with an   {
                                                      _root.lives -= 1;
    enemy:
                                                      reset()
                                                      for(k = 0; k < _root.nrEnemies;
                                                          k++)
                                                      {
                                                            _root["Enemy" + k].reset();
                                                      }
                                                }




                                                                                Page | 7
DPP B2 (c)



20. Draw two text boxes again




21. We can see the ship losing lives now,
    but nothing happens when it goes lower
    than zero. To change that we tell the
    player when its game over. Create a new
    movie clip.




22. Write "Game Over" using the text tool
    and go back to the main timeline.




                                              Page | 8
DPP B2 (c)



23. Add this to the Ship's code:               if (this.hitTest(_root["Enemy" + i]))
                                               {
                                                     _root.lives -= 1;
                                                     if (_root.lives <= 0)
                                                     {
                                                     _root.attachMovie("GameOver",
                                                     "GameOver", 100)
                                                     _root.GameOver._x = 275
                                                     _root.GameOver._y = 150
                                                     this.swapDepths(10);
                                                     this.removeMovieClip();
                                                     }
                                                     reset()
                                                     for(k = 0; k < _root.nrEnemies;
                                                         k++)
                                                     {
                                                           _root["Enemy" + k].reset();
                                                     }
                                               }


Timer

24. Before we start with sound we need to
    make some changes. You may have
    noticed that our ship shoots bullets as
    much as the player press the space bar,
    that's not right as it makes the game
    much easier.
    To prevent that, we are going to add a
    timer and the ship will shoot as much as
    we want.

   First add a new variable:                   var timer = 8;

   Then, make this changes:                    this.onEnterFrame = function()
                                               {
                                                     timer++;
                                                     .
                                                     .     .
                                                     if (Key.isDown(Key.SPACE))
                                                     {
                                                           i++;
                                                           if(timer >= 8)
                                                           {
                                                     _root.attachMovie("Bullet",
                                                     "Bullet" + i,
                                                     _root.getNextHighestDepth());
                                                     _root["Bullet" + i]._x =
                                                     Ship._x + 3;
                                                     _root["Bullet" + i]._y = Ship._y;
                                                           timer = 0;
                                                           }
                                                     }
                                               }



                                                                               Page | 9
DPP B2 (c)



The code runs like this:                          Before:

    If timer >= 8 then shoot a bullet and set
     timer to 0
    Now that timer = 0, the bullet wont shoot,
     so the player has to wait all the code to
     run at least 8 timer to shoot again
     (timer++ will increase timer by 1 every
     frame)
    Timer will be bigger than 8 again and the
     player can shoot.




                                                  After:




Sound

 25. We can add the sound now. You need to
     have an mp3 file that's going to be the
     sound played when you fire. Now that
     you have your sound, click File > Import
     > Import to library...Select your mp3 file
     and click open, a new file should appear
     on the library. Right click it and click
     "Linkage..." Check "Export to
     ActionScript..." and set the Identifier to
     "shoot". This is the same thing we did
     previously with the Bullet Movie Clip, we
     need the linkage to call this on the code.




                                                            Page | 10
DPP B2 (c)



26. Add this to the shooting code:               if (Key.isDown(Key.SPACE))
                                                 {
                                                       i++;
                                                       if(timer >= 8)
                                                       {
                                                       _root.attachMovie("Bullet",
                                                       "Bullet" + i,
                                                       _root.getNextHighestDepth());
                                                       _root["Bullet" + i]._x = Ship._x
                                                       + 3;
                                                       _root["Bullet" + i]._y = Ship._y;

                                                         var shoot_sound = new Sound();
                                                         shoot_sound.attachSound("shoot");
                                                         shoot_sound.start();
                                                         timer = 0;
                                                         }
                                                 }



27. The game is done! Hope you enjoying
    developing and playing it.




REFERENCES :                         1. Andrew Rollings, Ernest Adams (2003). Andrew Rollings and
                                        Ernest Adams on Game Design. USA: New Riders
                                        Publishing.
                                     2. Andrew Rollings, Dave Morris (2004). Game Architecture and
                                        Design:A New Edition. USA: New Riders Publishing.
                                     3. Patrick O’luanaigh (2006). Game Design Complete. USA:
                                        Paraglyph Press.




                                                                                         Page | 11

More Related Content

What's hot

Vaadin7
Vaadin7Vaadin7
Introduction à dart
Introduction à dartIntroduction à dart
Introduction à dart
yohanbeschi
 
ExtJS framework
ExtJS frameworkExtJS framework
ExtJS framework
Vincenzo Ferrari
 
Vaadin 7
Vaadin 7Vaadin 7
Vaadin 7
Joonas Lehtinen
 
Design pattern - part 1
Design pattern - part 1Design pattern - part 1
Design pattern - part 1
Jieyi Wu
 
[PL] O klasycznej, programistycznej elegancji
[PL] O klasycznej, programistycznej elegancji[PL] O klasycznej, programistycznej elegancji
[PL] O klasycznej, programistycznej elegancji
Jakub Marchwicki
 
Writing a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 CanvasWriting a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 Canvas
Steve Purkis
 
Zend Framework 1 + Doctrine 2
Zend Framework 1 + Doctrine 2Zend Framework 1 + Doctrine 2
Zend Framework 1 + Doctrine 2
Ralph Schindler
 
C++ prgms 4th unit Inheritance
C++ prgms 4th unit InheritanceC++ prgms 4th unit Inheritance
C++ prgms 4th unit Inheritance
Ananda Kumar HN
 
Eclipse Banking Day
Eclipse Banking DayEclipse Banking Day
Eclipse Banking Day
Sven Efftinge
 
enchant js workshop on Calpoly
enchant js workshop  on Calpolyenchant js workshop  on Calpoly
enchant js workshop on Calpoly
Ryo Shimizu
 
OOPS
OOPSOOPS
C++ prgms 5th unit (inheritance ii)
C++ prgms 5th unit (inheritance ii)C++ prgms 5th unit (inheritance ii)
C++ prgms 5th unit (inheritance ii)
Ananda Kumar HN
 
Games 3 dl4-example
Games 3 dl4-exampleGames 3 dl4-example
Games 3 dl4-example
enrique_arguello
 
38 object-concepts (1)
38 object-concepts (1)38 object-concepts (1)
38 object-concepts (1)
Shambhavi Vats
 

What's hot (15)

Vaadin7
Vaadin7Vaadin7
Vaadin7
 
Introduction à dart
Introduction à dartIntroduction à dart
Introduction à dart
 
ExtJS framework
ExtJS frameworkExtJS framework
ExtJS framework
 
Vaadin 7
Vaadin 7Vaadin 7
Vaadin 7
 
Design pattern - part 1
Design pattern - part 1Design pattern - part 1
Design pattern - part 1
 
[PL] O klasycznej, programistycznej elegancji
[PL] O klasycznej, programistycznej elegancji[PL] O klasycznej, programistycznej elegancji
[PL] O klasycznej, programistycznej elegancji
 
Writing a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 CanvasWriting a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 Canvas
 
Zend Framework 1 + Doctrine 2
Zend Framework 1 + Doctrine 2Zend Framework 1 + Doctrine 2
Zend Framework 1 + Doctrine 2
 
C++ prgms 4th unit Inheritance
C++ prgms 4th unit InheritanceC++ prgms 4th unit Inheritance
C++ prgms 4th unit Inheritance
 
Eclipse Banking Day
Eclipse Banking DayEclipse Banking Day
Eclipse Banking Day
 
enchant js workshop on Calpoly
enchant js workshop  on Calpolyenchant js workshop  on Calpoly
enchant js workshop on Calpoly
 
OOPS
OOPSOOPS
OOPS
 
C++ prgms 5th unit (inheritance ii)
C++ prgms 5th unit (inheritance ii)C++ prgms 5th unit (inheritance ii)
C++ prgms 5th unit (inheritance ii)
 
Games 3 dl4-example
Games 3 dl4-exampleGames 3 dl4-example
Games 3 dl4-example
 
38 object-concepts (1)
38 object-concepts (1)38 object-concepts (1)
38 object-concepts (1)
 

Viewers also liked

The Gospel
The GospelThe Gospel
The Gospel
MaximumMatt311
 
20120620「ココナラ×ワールドカフェ」プレゼン資料
20120620「ココナラ×ワールドカフェ」プレゼン資料20120620「ココナラ×ワールドカフェ」プレゼン資料
20120620「ココナラ×ワールドカフェ」プレゼン資料coconala
 
Typo lab
Typo labTypo lab
Typo lab
Zai Lekir
 
20120731プレゼン資料
20120731プレゼン資料 20120731プレゼン資料
20120731プレゼン資料
coconala
 
Prezentace qt filemanager
Prezentace qt filemanagerPrezentace qt filemanager
Prezentace qt filemanager
tomaslucovic
 
Prepositions of time
Prepositions of timePrepositions of time
Prepositions of time
CJessica
 
Video Audio Lab
Video Audio LabVideo Audio Lab
Video Audio Lab
Zai Lekir
 
Time sheet
Time sheetTime sheet
Time sheet
tomaslucovic
 
What Photography Experts Said About Photography : Photography quotes
What Photography Experts Said About Photography : Photography quotesWhat Photography Experts Said About Photography : Photography quotes
What Photography Experts Said About Photography : Photography quotes
PicBackMan
 
Action and Adventure Games
Action and Adventure GamesAction and Adventure Games
Action and Adventure Games
Zai Lekir
 
Did You Know These Photography Facts?
Did You Know These Photography Facts?Did You Know These Photography Facts?
Did You Know These Photography Facts?
PicBackMan
 
Audio video
Audio videoAudio video
Audio video
Zai Lekir
 
Introduction to the Digital Typography
Introduction to the Digital TypographyIntroduction to the Digital Typography
Introduction to the Digital Typography
Zai Lekir
 
Redmineをつかったスクラム開発のはじめの一歩
Redmineをつかったスクラム開発のはじめの一歩Redmineをつかったスクラム開発のはじめの一歩
Redmineをつかったスクラム開発のはじめの一歩kiita312
 

Viewers also liked (16)

The Gospel
The GospelThe Gospel
The Gospel
 
20120620「ココナラ×ワールドカフェ」プレゼン資料
20120620「ココナラ×ワールドカフェ」プレゼン資料20120620「ココナラ×ワールドカフェ」プレゼン資料
20120620「ココナラ×ワールドカフェ」プレゼン資料
 
Typo lab
Typo labTypo lab
Typo lab
 
20120731プレゼン資料
20120731プレゼン資料 20120731プレゼン資料
20120731プレゼン資料
 
Prezentace qt filemanager
Prezentace qt filemanagerPrezentace qt filemanager
Prezentace qt filemanager
 
Prepositions of time
Prepositions of timePrepositions of time
Prepositions of time
 
Video Audio Lab
Video Audio LabVideo Audio Lab
Video Audio Lab
 
คำคมอารมปราชน์
คำคมอารมปราชน์คำคมอารมปราชน์
คำคมอารมปราชน์
 
Time sheet
Time sheetTime sheet
Time sheet
 
Tour de suisse
Tour de suisseTour de suisse
Tour de suisse
 
What Photography Experts Said About Photography : Photography quotes
What Photography Experts Said About Photography : Photography quotesWhat Photography Experts Said About Photography : Photography quotes
What Photography Experts Said About Photography : Photography quotes
 
Action and Adventure Games
Action and Adventure GamesAction and Adventure Games
Action and Adventure Games
 
Did You Know These Photography Facts?
Did You Know These Photography Facts?Did You Know These Photography Facts?
Did You Know These Photography Facts?
 
Audio video
Audio videoAudio video
Audio video
 
Introduction to the Digital Typography
Introduction to the Digital TypographyIntroduction to the Digital Typography
Introduction to the Digital Typography
 
Redmineをつかったスクラム開発のはじめの一歩
Redmineをつかったスクラム開発のはじめの一歩Redmineをつかったスクラム開発のはじめの一歩
Redmineをつかったスクラム開発のはじめの一歩
 

Similar to Game Lab

Testing a 2D Platformer with Spock
Testing a 2D Platformer with SpockTesting a 2D Platformer with Spock
Testing a 2D Platformer with Spock
Alexander Tarlinder
 
Constructor and destructor
Constructor and destructorConstructor and destructor
Constructor and destructor
Selvin Josy Bai Somu
 
Writing Maintainable JavaScript
Writing Maintainable JavaScriptWriting Maintainable JavaScript
Writing Maintainable JavaScript
Andrew Dupont
 
662305 11
662305 11662305 11
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
C++ Homework Help
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
Remy Sharp
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconf
tutorialsruby
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconf
tutorialsruby
 
Cbse question-paper-computer-science-2009
Cbse question-paper-computer-science-2009Cbse question-paper-computer-science-2009
Cbse question-paper-computer-science-2009
Deepak Singh
 
Of class1
Of class1Of class1
Of class1
Janet Huang
 
C++ game development with oxygine
C++ game development with oxygineC++ game development with oxygine
C++ game development with oxygine
corehard_by
 
C++totural file
C++totural fileC++totural file
C++totural file
halaisumit
 
662305 LAB13
662305 LAB13662305 LAB13
662305 LAB13
Nitigan Nakjuatong
 
C++ tutorial
C++ tutorialC++ tutorial
0_ML lab programs updated123 (3).1687933796093.doc
0_ML lab programs updated123 (3).1687933796093.doc0_ML lab programs updated123 (3).1687933796093.doc
0_ML lab programs updated123 (3).1687933796093.doc
RohanS38
 
Animations in Flutter
Animations in FlutterAnimations in Flutter
Animations in Flutter
Bartosz Kosarzycki
 
Object Oriented Programming using C++: Ch06 Objects and Classes.pptx
Object Oriented Programming using C++: Ch06 Objects and Classes.pptxObject Oriented Programming using C++: Ch06 Objects and Classes.pptx
Object Oriented Programming using C++: Ch06 Objects and Classes.pptx
RashidFaridChishti
 
Oojs 1.1
Oojs 1.1Oojs 1.1
Oojs 1.1
Rodica Dada
 
I am sorry but my major does not cover programming in depth (ICT) an.pdf
I am sorry but my major does not cover programming in depth (ICT) an.pdfI am sorry but my major does not cover programming in depth (ICT) an.pdf
I am sorry but my major does not cover programming in depth (ICT) an.pdf
seamusschwaabl99557
 
Desenvolva um game para android ou iPhone
Desenvolva um game para android ou iPhoneDesenvolva um game para android ou iPhone
Desenvolva um game para android ou iPhone
Tiago Oliveira
 

Similar to Game Lab (20)

Testing a 2D Platformer with Spock
Testing a 2D Platformer with SpockTesting a 2D Platformer with Spock
Testing a 2D Platformer with Spock
 
Constructor and destructor
Constructor and destructorConstructor and destructor
Constructor and destructor
 
Writing Maintainable JavaScript
Writing Maintainable JavaScriptWriting Maintainable JavaScript
Writing Maintainable JavaScript
 
662305 11
662305 11662305 11
662305 11
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconf
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconf
 
Cbse question-paper-computer-science-2009
Cbse question-paper-computer-science-2009Cbse question-paper-computer-science-2009
Cbse question-paper-computer-science-2009
 
Of class1
Of class1Of class1
Of class1
 
C++ game development with oxygine
C++ game development with oxygineC++ game development with oxygine
C++ game development with oxygine
 
C++totural file
C++totural fileC++totural file
C++totural file
 
662305 LAB13
662305 LAB13662305 LAB13
662305 LAB13
 
C++ tutorial
C++ tutorialC++ tutorial
C++ tutorial
 
0_ML lab programs updated123 (3).1687933796093.doc
0_ML lab programs updated123 (3).1687933796093.doc0_ML lab programs updated123 (3).1687933796093.doc
0_ML lab programs updated123 (3).1687933796093.doc
 
Animations in Flutter
Animations in FlutterAnimations in Flutter
Animations in Flutter
 
Object Oriented Programming using C++: Ch06 Objects and Classes.pptx
Object Oriented Programming using C++: Ch06 Objects and Classes.pptxObject Oriented Programming using C++: Ch06 Objects and Classes.pptx
Object Oriented Programming using C++: Ch06 Objects and Classes.pptx
 
Oojs 1.1
Oojs 1.1Oojs 1.1
Oojs 1.1
 
I am sorry but my major does not cover programming in depth (ICT) an.pdf
I am sorry but my major does not cover programming in depth (ICT) an.pdfI am sorry but my major does not cover programming in depth (ICT) an.pdf
I am sorry but my major does not cover programming in depth (ICT) an.pdf
 
Desenvolva um game para android ou iPhone
Desenvolva um game para android ou iPhoneDesenvolva um game para android ou iPhone
Desenvolva um game para android ou iPhone
 

Recently uploaded

Leonardo DiCaprio House: A Journey Through His Extravagant Real Estate Portfolio
Leonardo DiCaprio House: A Journey Through His Extravagant Real Estate PortfolioLeonardo DiCaprio House: A Journey Through His Extravagant Real Estate Portfolio
Leonardo DiCaprio House: A Journey Through His Extravagant Real Estate Portfolio
greendigital
 
From Swing Music to Big Band Fame_ 5 Iconic Artists.pptx
From Swing Music to Big Band Fame_ 5 Iconic Artists.pptxFrom Swing Music to Big Band Fame_ 5 Iconic Artists.pptx
From Swing Music to Big Band Fame_ 5 Iconic Artists.pptx
Swing Street Radio
 
原版制作(Mercer毕业证书)摩斯大学毕业证在读证明一模一样
原版制作(Mercer毕业证书)摩斯大学毕业证在读证明一模一样原版制作(Mercer毕业证书)摩斯大学毕业证在读证明一模一样
原版制作(Mercer毕业证书)摩斯大学毕业证在读证明一模一样
mul1kv5w
 
Modern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
Modern Radio Frequency Access Control Systems: The Key to Efficiency and SafetyModern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
Modern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
AITIX LLC
 
Authenticity in Motion Pictures: How Steve Greisen Retains Real Stories
Authenticity in Motion Pictures: How Steve Greisen Retains Real StoriesAuthenticity in Motion Pictures: How Steve Greisen Retains Real Stories
Authenticity in Motion Pictures: How Steve Greisen Retains Real Stories
Steve Greisen
 
Divertidamente SLIDE muito lindo e criativo, pptx
Divertidamente SLIDE muito lindo e criativo, pptxDivertidamente SLIDE muito lindo e criativo, pptx
Divertidamente SLIDE muito lindo e criativo, pptx
lunaemel03
 
From Teacher to OnlyFans: Brianna Coppage's Story at 28
From Teacher to OnlyFans: Brianna Coppage's Story at 28From Teacher to OnlyFans: Brianna Coppage's Story at 28
From Teacher to OnlyFans: Brianna Coppage's Story at 28
get joys
 
Top IPTV UK Providers of A Comprehensive Review.pdf
Top IPTV UK Providers of A Comprehensive Review.pdfTop IPTV UK Providers of A Comprehensive Review.pdf
Top IPTV UK Providers of A Comprehensive Review.pdf
Xtreame HDTV
 
Snoopy boards the big bow wow musical __
Snoopy boards the big bow wow musical __Snoopy boards the big bow wow musical __
Snoopy boards the big bow wow musical __
catcabrera
 
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
9u08k0x
 
The Unbelievable Tale of Dwayne Johnson Kidnapping: A Riveting Saga
The Unbelievable Tale of Dwayne Johnson Kidnapping: A Riveting SagaThe Unbelievable Tale of Dwayne Johnson Kidnapping: A Riveting Saga
The Unbelievable Tale of Dwayne Johnson Kidnapping: A Riveting Saga
greendigital
 
The Evolution of the Leonardo DiCaprio Haircut: A Journey Through Style and C...
The Evolution of the Leonardo DiCaprio Haircut: A Journey Through Style and C...The Evolution of the Leonardo DiCaprio Haircut: A Journey Through Style and C...
The Evolution of the Leonardo DiCaprio Haircut: A Journey Through Style and C...
greendigital
 
Everything You Need to Know About IPTV Ireland.pdf
Everything You Need to Know About IPTV Ireland.pdfEverything You Need to Know About IPTV Ireland.pdf
Everything You Need to Know About IPTV Ireland.pdf
Xtreame HDTV
 
Unveiling Paul Haggis Shaping Cinema Through Diversity. .pdf
Unveiling Paul Haggis Shaping Cinema Through Diversity. .pdfUnveiling Paul Haggis Shaping Cinema Through Diversity. .pdf
Unveiling Paul Haggis Shaping Cinema Through Diversity. .pdf
kenid14983
 
Emcee Profile_ Subbu from Bangalore .pdf
Emcee Profile_ Subbu from Bangalore .pdfEmcee Profile_ Subbu from Bangalore .pdf
Emcee Profile_ Subbu from Bangalore .pdf
subran
 
Barbie Movie Review - The Astras.pdfffff
Barbie Movie Review - The Astras.pdfffffBarbie Movie Review - The Astras.pdfffff
Barbie Movie Review - The Astras.pdfffff
theastras43
 
Orpah Winfrey Dwayne Johnson: Titans of Influence and Inspiration
Orpah Winfrey Dwayne Johnson: Titans of Influence and InspirationOrpah Winfrey Dwayne Johnson: Titans of Influence and Inspiration
Orpah Winfrey Dwayne Johnson: Titans of Influence and Inspiration
greendigital
 
The Enigmatic Portrait, In the heart of a sleepy town
The Enigmatic Portrait, In the heart of a sleepy townThe Enigmatic Portrait, In the heart of a sleepy town
The Enigmatic Portrait, In the heart of a sleepy town
John Emmett
 
定制(uow毕业证书)卧龙岗大学毕业证文凭学位证书原版一模一样
定制(uow毕业证书)卧龙岗大学毕业证文凭学位证书原版一模一样定制(uow毕业证书)卧龙岗大学毕业证文凭学位证书原版一模一样
定制(uow毕业证书)卧龙岗大学毕业证文凭学位证书原版一模一样
0md20cgg
 
Christian Louboutin: Innovating with Red Soles
Christian Louboutin: Innovating with Red SolesChristian Louboutin: Innovating with Red Soles
Christian Louboutin: Innovating with Red Soles
get joys
 

Recently uploaded (20)

Leonardo DiCaprio House: A Journey Through His Extravagant Real Estate Portfolio
Leonardo DiCaprio House: A Journey Through His Extravagant Real Estate PortfolioLeonardo DiCaprio House: A Journey Through His Extravagant Real Estate Portfolio
Leonardo DiCaprio House: A Journey Through His Extravagant Real Estate Portfolio
 
From Swing Music to Big Band Fame_ 5 Iconic Artists.pptx
From Swing Music to Big Band Fame_ 5 Iconic Artists.pptxFrom Swing Music to Big Band Fame_ 5 Iconic Artists.pptx
From Swing Music to Big Band Fame_ 5 Iconic Artists.pptx
 
原版制作(Mercer毕业证书)摩斯大学毕业证在读证明一模一样
原版制作(Mercer毕业证书)摩斯大学毕业证在读证明一模一样原版制作(Mercer毕业证书)摩斯大学毕业证在读证明一模一样
原版制作(Mercer毕业证书)摩斯大学毕业证在读证明一模一样
 
Modern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
Modern Radio Frequency Access Control Systems: The Key to Efficiency and SafetyModern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
Modern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
 
Authenticity in Motion Pictures: How Steve Greisen Retains Real Stories
Authenticity in Motion Pictures: How Steve Greisen Retains Real StoriesAuthenticity in Motion Pictures: How Steve Greisen Retains Real Stories
Authenticity in Motion Pictures: How Steve Greisen Retains Real Stories
 
Divertidamente SLIDE muito lindo e criativo, pptx
Divertidamente SLIDE muito lindo e criativo, pptxDivertidamente SLIDE muito lindo e criativo, pptx
Divertidamente SLIDE muito lindo e criativo, pptx
 
From Teacher to OnlyFans: Brianna Coppage's Story at 28
From Teacher to OnlyFans: Brianna Coppage's Story at 28From Teacher to OnlyFans: Brianna Coppage's Story at 28
From Teacher to OnlyFans: Brianna Coppage's Story at 28
 
Top IPTV UK Providers of A Comprehensive Review.pdf
Top IPTV UK Providers of A Comprehensive Review.pdfTop IPTV UK Providers of A Comprehensive Review.pdf
Top IPTV UK Providers of A Comprehensive Review.pdf
 
Snoopy boards the big bow wow musical __
Snoopy boards the big bow wow musical __Snoopy boards the big bow wow musical __
Snoopy boards the big bow wow musical __
 
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
 
The Unbelievable Tale of Dwayne Johnson Kidnapping: A Riveting Saga
The Unbelievable Tale of Dwayne Johnson Kidnapping: A Riveting SagaThe Unbelievable Tale of Dwayne Johnson Kidnapping: A Riveting Saga
The Unbelievable Tale of Dwayne Johnson Kidnapping: A Riveting Saga
 
The Evolution of the Leonardo DiCaprio Haircut: A Journey Through Style and C...
The Evolution of the Leonardo DiCaprio Haircut: A Journey Through Style and C...The Evolution of the Leonardo DiCaprio Haircut: A Journey Through Style and C...
The Evolution of the Leonardo DiCaprio Haircut: A Journey Through Style and C...
 
Everything You Need to Know About IPTV Ireland.pdf
Everything You Need to Know About IPTV Ireland.pdfEverything You Need to Know About IPTV Ireland.pdf
Everything You Need to Know About IPTV Ireland.pdf
 
Unveiling Paul Haggis Shaping Cinema Through Diversity. .pdf
Unveiling Paul Haggis Shaping Cinema Through Diversity. .pdfUnveiling Paul Haggis Shaping Cinema Through Diversity. .pdf
Unveiling Paul Haggis Shaping Cinema Through Diversity. .pdf
 
Emcee Profile_ Subbu from Bangalore .pdf
Emcee Profile_ Subbu from Bangalore .pdfEmcee Profile_ Subbu from Bangalore .pdf
Emcee Profile_ Subbu from Bangalore .pdf
 
Barbie Movie Review - The Astras.pdfffff
Barbie Movie Review - The Astras.pdfffffBarbie Movie Review - The Astras.pdfffff
Barbie Movie Review - The Astras.pdfffff
 
Orpah Winfrey Dwayne Johnson: Titans of Influence and Inspiration
Orpah Winfrey Dwayne Johnson: Titans of Influence and InspirationOrpah Winfrey Dwayne Johnson: Titans of Influence and Inspiration
Orpah Winfrey Dwayne Johnson: Titans of Influence and Inspiration
 
The Enigmatic Portrait, In the heart of a sleepy town
The Enigmatic Portrait, In the heart of a sleepy townThe Enigmatic Portrait, In the heart of a sleepy town
The Enigmatic Portrait, In the heart of a sleepy town
 
定制(uow毕业证书)卧龙岗大学毕业证文凭学位证书原版一模一样
定制(uow毕业证书)卧龙岗大学毕业证文凭学位证书原版一模一样定制(uow毕业证书)卧龙岗大学毕业证文凭学位证书原版一模一样
定制(uow毕业证书)卧龙岗大学毕业证文凭学位证书原版一模一样
 
Christian Louboutin: Innovating with Red Soles
Christian Louboutin: Innovating with Red SolesChristian Louboutin: Innovating with Red Soles
Christian Louboutin: Innovating with Red Soles
 

Game Lab

  • 1. DPP B2 (c) JOB SHEET COURSE : DIPLOMA IN DIGITAL MEDIA DESIGN SESSION : JAN - JUN 2012 SEMESTER : 4 CODE/SUBJECT : DDM 4323 - GAME DESIGN SHEET NO : JS-8 NO OF STUDENTS : 30 WEEK : 8 LECTURER : AZMI BIN MOHAMED TOPIC : 8.0 SPACE SHOOTER 8.1 Research and create a basics of movie clips and character movement for space shooter game SUB-TOPIC : 8.2 Add an interactive elements; lives and score for game 8.3 Add sound effects using ActionScript. After completing this topic, students should be able to: LEARNING 1. Develop their own space shooter games with random enemies. OUTCOME : 2. Create an interactive element; lives and score for their games. 3. Add a sound effects using ActionScript TOOLS / 1. Computer EQUIPMENTS / 2. Projector MATERIALS : 3. Adobe Flash CS4 INSTRUCTION : 1. Research the ActionScript for creates a space shooter game, character movement and shoot control using keyboard. 2. Follow step-by-step tutorial below to create a space shooter game. Page | 1
  • 2. DPP B2 (c) PROCEDURE : STEP KEY POINT Movie Clip and Movement 1. Open Adobe Flash and create new document (ActionScript 2.0)  Size: 800x600px  Frame Rate : 24fps  Background Color: Black 2. Create a Movie Clip by right clicking your library tab and selecting "New Symbol...", make sure "Movie Clip" is selected and choose a name. 3. Flash will create and open the Movie Clip for editing, so just paste an image or draw a space ship with Flash's drawing tools. After drawing your ship, get back to the main timeline by click on "Scene 1": At properties panel; put a variable name as “ship”. 4. Right click the first frame in your timeline this.onEnterFrame = function() and select "Actions". Type this: { if (Key.isDown(Key.RIGHT)) { Ship._x += 10; } else if (Key.isDown(Key.LEFT)) { Ship._x -= 10; } else if (Key.isDown(Key.UP)) { Ship._y -= 10; } else if (Key.isDown(Key.DOWN)) { Ship._y += 10; } } Page | 2
  • 3. DPP B2 (c) Shooting 5. This is the second part of the tutorial and we are going to enable the ship to shoot. Previously we made our ship fly; now we are going to make it shoot and set limits to where it can go. First we need to make our bullets, right click the library tab, select "New Symbol" and give it the name "Bullet". Before clicking OK, click Advanced, select "Export for Actionscript" and make sure the identifier is "Bullet". 6. We do this because we need to export the Bullet Movie Clip during running time to create many bullets and we will use the name determined in identifier to call it later. Draw a small bullet, and position it like this: This is called registration point, in the stage this is the position of the Bullet Movie Clip. 7. Now open the actions window of the first this.onEnterFrame = function() frame of the Movie Clip, insert this code: { this._x += 12; if (this._x > 800) { this.removeMovieClip(); } } 8. Now go to the main timeline, select the var i = 0; first frame and open the actions this.onEnterFrame = function() { windows. You will see the previous . codes that we have written. Add this . code to the old one so we can fire our . bullets: else if (Key.isDown(Key.DOWN)) { Ship._y += 5; } if (Key.isDown(Key.SPACE)) Page | 3
  • 4. DPP B2 (c) { i++; _root.attachMovie("Bullet", "Bullet" + i, _root.getNextHighestDepth()); _root["Bullet" + i]._x = Ship._x + 3; _root["Bullet" + i]._y = Ship._y; } } 9. Before we finish this tutorial, let's put if (Key.isDown(Key.RIGHT)) some limits to where our ship can go, we { don't want it to get off the screen. Make if (Ship.hitTest(800, Ship._y, these changes: true)) { Ship._x -= 5; } Ship._x += 5; } else if (Key.isDown(Key.LEFT)) { if (Ship.hitTest(0, Ship._y, true)) { Ship._x += 5; } Ship._x -= 5; } else if (Key.isDown(Key.UP)) { if (Ship.hitTest(Ship._x - 40, 0, true)) { Ship._y += 5; } Ship._y -= 5; } else if (Key.isDown(Key.DOWN)) { if (Ship.hitTest(Ship._x - 40, 600, true)) { Ship._y -= 5; } Ship._y += 5; } if (Ship.hitTest(800, Ship._y, true)) { Ship._x -= 5; } Page | 4
  • 5. DPP B2 (c) Enemies 10. This is the third tutorial of a series about developing a Space Shooter game, in this tutorial we are going to make enemy ships. Create a new Movie Clip and draw your enemy ship, don't forget to set the identifier to "Enemy" and select "Export to Actionscript". 11. Now drag the enemy Movie Clip to the onClipEvent(load) stage, give it an instance name of { "Enemy0", right click it and select function reset() "Actions". Insert this: { var timer = 12; this._y = Math.random() * 300 this._x = 550 mySpeed = Math.ceil(Math. random() * 6) + 1; } reset(); } // This part of the code creates a function called reset() when the Movie Clip loads for the first time. Inside reset() we set this._y to a random number between 0 and 600, this._x to 800 and the speed of our enemy to a random number between 1 and 6. 12. Then, insert this code: onClipEvent(enterFrame) { this._x -= mySpeed; if (this._x < -10) { reset(); } if (timer >= 12) { Math.ceil(Math.random() * 2) timer = 0; Page | 5
  • 6. DPP B2 (c) } if (dir == 1) { this._y -= 3; } else if(dir == 2) { this._y += 3; } timer++ } 13. Add this code in the main timeline before var nrEnemies = 3; the rest of the code. for (i = 1; i < nrEnemies; i++) { _root.Enemy.duplicateMovieClip ("Enemy" + i, _root.getNextHighestDepth()); } Lives and Score 14. This is the forth part of the development of a Space Shooter game. In this tutorial we will add lives, scores and game over to our game. Let's start with score.Open the main timeline code and add this variable: var score = 0; 15. Now open the Bullet's code and add this: this.onEnterFrame = function() { this._x += 9; if (this._x > 550) { this.removeMovieClip(); } for (i = 0; i < _root.nrEnemies; i++) { if (this.hitTest (_root["Enemy" + i])) { _root["Enemy" + i].reset(); _root.score += 10; this.removeMovieClip(); } } } // This is the code we used before to know if a bullet hits an enemy, so we can put the score for killing an enemy there. Page | 6
  • 7. DPP B2 (c) 16. The score is done; we just need to show the player his score. To do that, select the Text Tool and draw it on the stage. Write "Score:" 17. Now draw another Text box on the stage. Select this new Text box and change these properties: 18. Now let's make our ship have lives. Add var lives = 3; another variable in the main code: 19. And make these changes in the code if (this.hitTest(_root["Enemy" + i])) that checks if the player crashed with an { _root.lives -= 1; enemy: reset() for(k = 0; k < _root.nrEnemies; k++) { _root["Enemy" + k].reset(); } } Page | 7
  • 8. DPP B2 (c) 20. Draw two text boxes again 21. We can see the ship losing lives now, but nothing happens when it goes lower than zero. To change that we tell the player when its game over. Create a new movie clip. 22. Write "Game Over" using the text tool and go back to the main timeline. Page | 8
  • 9. DPP B2 (c) 23. Add this to the Ship's code: if (this.hitTest(_root["Enemy" + i])) { _root.lives -= 1; if (_root.lives <= 0) { _root.attachMovie("GameOver", "GameOver", 100) _root.GameOver._x = 275 _root.GameOver._y = 150 this.swapDepths(10); this.removeMovieClip(); } reset() for(k = 0; k < _root.nrEnemies; k++) { _root["Enemy" + k].reset(); } } Timer 24. Before we start with sound we need to make some changes. You may have noticed that our ship shoots bullets as much as the player press the space bar, that's not right as it makes the game much easier. To prevent that, we are going to add a timer and the ship will shoot as much as we want. First add a new variable: var timer = 8; Then, make this changes: this.onEnterFrame = function() { timer++; . . . if (Key.isDown(Key.SPACE)) { i++; if(timer >= 8) { _root.attachMovie("Bullet", "Bullet" + i, _root.getNextHighestDepth()); _root["Bullet" + i]._x = Ship._x + 3; _root["Bullet" + i]._y = Ship._y; timer = 0; } } } Page | 9
  • 10. DPP B2 (c) The code runs like this: Before:  If timer >= 8 then shoot a bullet and set timer to 0  Now that timer = 0, the bullet wont shoot, so the player has to wait all the code to run at least 8 timer to shoot again (timer++ will increase timer by 1 every frame)  Timer will be bigger than 8 again and the player can shoot. After: Sound 25. We can add the sound now. You need to have an mp3 file that's going to be the sound played when you fire. Now that you have your sound, click File > Import > Import to library...Select your mp3 file and click open, a new file should appear on the library. Right click it and click "Linkage..." Check "Export to ActionScript..." and set the Identifier to "shoot". This is the same thing we did previously with the Bullet Movie Clip, we need the linkage to call this on the code. Page | 10
  • 11. DPP B2 (c) 26. Add this to the shooting code: if (Key.isDown(Key.SPACE)) { i++; if(timer >= 8) { _root.attachMovie("Bullet", "Bullet" + i, _root.getNextHighestDepth()); _root["Bullet" + i]._x = Ship._x + 3; _root["Bullet" + i]._y = Ship._y; var shoot_sound = new Sound(); shoot_sound.attachSound("shoot"); shoot_sound.start(); timer = 0; } } 27. The game is done! Hope you enjoying developing and playing it. REFERENCES : 1. Andrew Rollings, Ernest Adams (2003). Andrew Rollings and Ernest Adams on Game Design. USA: New Riders Publishing. 2. Andrew Rollings, Dave Morris (2004). Game Architecture and Design:A New Edition. USA: New Riders Publishing. 3. Patrick O’luanaigh (2006). Game Design Complete. USA: Paraglyph Press. Page | 11