generated from remarkablegames/kaboom-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aff1fec
commit da60357
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { addCursorKeys, initLevel } from '../helpers' | ||
import { Sprite } from '../types' | ||
|
||
export const level = 9 | ||
export const title = 'Loops' | ||
|
||
const password = Array.from(Array(42).keys()) | ||
.map(() => 'answer') | ||
.join('') | ||
|
||
export function prescript() { | ||
initLevel(level) | ||
loadSprite(Sprite.key, 'sprites/key.png') | ||
|
||
addCursorKeys( | ||
add([sprite(Sprite.player), pos(100, 100), area(), Sprite.player]), | ||
) | ||
|
||
add([sprite(Sprite.key), pos(center()), area(), Sprite.key, { password }]) | ||
|
||
onCollide(Sprite.key, Sprite.player, (key) => { | ||
if (key.password === password) { | ||
key.destroy() | ||
add([sprite(Sprite.exit), pos(500, 500), area(), Sprite.exit]) | ||
} else { | ||
debug.log('Incorrect password') | ||
} | ||
}) | ||
|
||
add([text('Another password?')]) | ||
} | ||
|
||
export const script = ` | ||
/** | ||
* Loops repeat a block of code | ||
*/ | ||
const key = get('key')[0] | ||
// password = 'answer' repeated 42 times | ||
let password = 'answer' + 'answer' | ||
key.password = password | ||
` | ||
|
||
export function postscript() {} |