2.2.9 Cycle 9 - Twines
Design:
Objectives
Usability Features
Key Variables
Variable Name
Use
Pseudocode
// Twine
const ENEMY_SPEED = 0
const BULLET_SPEED = 800
let twine
On collision with "enemy":
if not colliding from the bottom:
Go to "lose" scene
End on collision
twine = add entity with:
- sprite "Twine"
- position (2688, -60)
- anchor "center"
- initial state "move" with possible states: "idle", "attack", "move"
On entering state "idle":
Wait for 0.5 seconds
Change twine state to "attack"
End on entering state "idle"
On entering state "attack":
if player exists:
Calculate direction as unit vector from twine position to player position
add bullet entity with:
- position twine position
- move in direction with speed BULLET_SPEED
- rectangle shape (12, 12)
- area
- offscreen behavior with destruction
- anchor "center"
- color BLUE
- "bullet" component
Wait for 1 second
Change twine state to "move"
End on entering state "attack"
On entering state "move":
Wait for 2 seconds
Change twine state to "idle"
End on entering state "move"
During state "move":
if player exists:
Calculate direction as unit vector from twine position to player position
Move twine in the direction scaled by ENEMY_SPEED
End during state "move"
On collision with "bullet":
Go to the "lose" scene
End on collisionDevelopment:
Outcome
Challenges
Testing:
Tests
Test
Instructions
What I expect
What actually happens
Pass/Fail
Evidence
Last updated