2.2.4 Cycle 4 Firing Bullets
Design
Objectives
Usability features
Key variables
Variable Name
Use
Pseudocode
Import the "multiplayer.js" module
Import the "kaboom" module
Import the "kaboom/global" module
Set WIDTH to 1920
Set HEIGHT to 1080
Set GRAVITY to 450
Initialize kaboom with the specified width and height
Set the gravity of the game environment to GRAVITY
Load the "bullet" sprite and assign it the name "bullet"
Define a function named "newBullet" that takes a position and an angle as arguments:
Create a new bullet object with the following properties:
- sprite: "bullet"
- position: the given position
- scale: (1, 1)
- offscreen behavior: destroy when offscreen
- area()
- anchor: "center"
- body()
- rotation: the given angle
- move in the direction of the angle with a speed calculated based on (bean.power + 20) * 8.3
- tag: "bullet"
When the space key is pressed:
If there are no bullets currently in the game:
Calculate the position of the end of the barrel
Create a new bullet at the calculated position with the bean's angleDevelopment
Outcome
Challenges
Testing
Tests
Test
Instructions
What I expect
What actually happens
Pass/Fail
Evidence
Last updated