Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var balloon = createSprite(200,200);
- balloon.setAnimation("balloon");
- balloon.debug = true;
- var tack = createSprite(350, 50);
- tack.setAnimation("tack");
- tack.debug = true;
- function draw() {
- background("gray");
- // check if tack is touching balloon
- if (balloon.isTouching(tack)) {
- // replace balloon image
- balloon.setAnimation("popped");
- }
- // make tack move with arrow keys
- if (keyDown("up")) {
- tack.y = tack.y - 1;
- }
- if (keyDown("down")) {
- tack.y = tack.y + 1;
- }
- if (keyDown("left")) {
- tack.x = tack.x - 1;
- }
- if (keyDown("right")) {
- tack.x = tack.x + 1;
- }
- drawSprites();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement