Everyone likes to play Star War game with Spaceship Shooting. In this article, we will cover how to make a simple space dodger game. Let discuss creating of the game.
Space Dodger Game Play
Once upon a time, in our Space, there is spaceship moving around by a pilot to avoid being hit by space rock.
- Add a Space backdrop and change the backdrop1 background color to be red.
- Next create 3 Sprites character – spaceship, rock and a BOOM.
- Add the following variables – avoided, blaster, gap time, score and warp speed.
Rock sprite code
- In green flag event, set the size to 22% and hide.
- Create clone of myself and waited gap time variable second.
- In the blaster fired event, delete the rock clone.
- In the start clone event, set the size of rock randomly from 20 ~50%
- If the pick random between 1 to 10 is 1,
- Switch the costume of rock to space dog.
- Remember space dog is another costume in the rock.
- Next, go to x:200 and y: random 1 to -240 to 240.
- Turn clockwise 15 degrees and change the x by -1* warp speed.
- If x position < -240, then change avoided by 1 and broadcast update score event.
- Finally, delete the rock clone.
SpaceShip sprite code
- In green flag event, if touching the rock, broadcast gameover event.
- And in another green flag event, we will change the costume (next costume) for every 0.2 seconds.
- When space key pressed event, if blaster value >0 then
- Play laser2 sound
- Change the blaster by -1
- Change the backdrop to red color background
- Wait for 0.05 seconds and change back to space backdrop.
- Finally, broadcast blaster fired event.
- In the main green flag, we will switch the backdrop to space.
- Go to x: -200, y: 0 and set point to 180 directions.
- Next, set the variables default value
- warp speed = 5;
- score and avoided = 0;
- gap time = 2;
- blaster = 3;
- Detect up arrow and down arrow to change the y by 10 and -10.
- When I receive update score.,
- If avoided mod 5 = 0,
- change score to 1
- if gap time > 0.5 seconds
- set gap time to 0.9* gap time.
- If avoided mod 5 = 0,
BOOM explosion
- In the green flag, hide the BOOM.
- Next, in the gamoever event, go to x:0, y:0 and show the sprite.
- Then, stop all script.
Let play our game and here is the link to the code.
Thanks for reading and enjoy your day.