Created
March 28, 2013 11:08
-
-
Save niklaskorz/5262397 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Q = Quintus() | |
.include("Sprites, Scenes, Input, 2D, Touch, UI") | |
.setup(maximize: true) | |
.controls().touch() | |
Q.Sprite.extend "Player", | |
init: (p) -> | |
@_super p, sheet: "player", x: 410, y: 90 | |
@add "2d, platformerControls" | |
@on "hit.sprite", (collision) -> | |
if collision.obj.isA "Tower" | |
Q.stageScene "endGame", 1, label: "You Won!" | |
@destroy() | |
Q.Sprite.extend "Tower", | |
init: (p) -> | |
@_super p, sheet: "tower" | |
Q.Sprite.extend "Enemy", | |
init: (p) -> | |
@_super p, sheet: "enemy", vx: 100 | |
@add "2d, aiBounce" | |
@on "bump.left,bump.right,bump.bottom", (collision) -> | |
if collision.obj.isA "Player" | |
Q.stageScene "endGame", 1, label: "You Died!" | |
collision.obj.destroy() | |
@on "bump.top", (collision) -> | |
if collision.obj.isA "Player" | |
@destroy() | |
collision.obj.p.vy = -300 | |
Q.scene "level1", (stage) -> | |
stage.collisionLayer new Q.TileLayer dataAsset: "level.json", sheet: "tiles" | |
player = stage.insert new Q.Player() | |
stage.add("viewport").follow player | |
stage.insert new Q.Enemy x: 700, y: 0 | |
stage.insert new Q.Enemy x: 800, y: 0 | |
stage.insert new Q.Tower x: 180, y: 50 | |
Q.scene "endGame", (stage) -> | |
box = stage.insert new Q.UI.Container | |
x: Q.width / 2, y: Q.height / 2, fill: "rgba(0,0,0,0.5)" | |
button = box.insert new Q.UI.Button x: 0, y: 0, fill: "#ccc", label: "Play Again" | |
label = box.insert new Q.UI.Text x: 10, y: -10 - button.p.h, label: stage.options.label | |
button.on "click", -> | |
Q.clearStages() | |
Q.stageScene "level1" | |
box.fit 20 | |
Q.load "sprites.png, sprites.json, level.json, tiles.png", -> | |
Q.sheet "tiles", "tiles.png", tilew: 32, tileh: 32 | |
Q.compileSheets "sprites.png", "sprites.json" | |
Q.stageScene "level1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment