Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
Towerman
========

Pacman
A game like Pac-man, made with the Quintus HTML5 Game Framework

![Towerman](https://s3.amazonaws.com/uploads.hipchat.com/12722/130235/7iublw3zkzq8zkj/upload.png)

[Play a live version here](http://towermancoderdojo.azurewebsites.net/final/)
9 changes: 9 additions & 0 deletions Web.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>

<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>
28 changes: 14 additions & 14 deletions final/data/level.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[
[ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[ 1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1],
[ 1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1],
[ 1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1],
[ 1,0,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1],
[ 1,0,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,1],
[ 1,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1],
[ 1,0,0,0,1,1,1,0,1,1,0,1,1,0,1,1,1,1,0,1],
[ 1,1,1,0,1,1,1,0,1,1,0,1,1,0,0,0,0,1,0,1],
[ 1,0,0,0,1,1,1,0,1,1,0,1,1,0,1,1,0,1,0,1],
[ 1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1],
[ 1,0,1,0,1,1,1,0,1,1,1,1,1,0,1,1,0,1,0,1],
[ 1,2,0,0,0,0,0,0,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ary file modified final/images/sprites.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added final/images/sprites2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 94 additions & 8 deletions final/tower_man.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@

//Not sure if it worked
// 1. Wait for the onload even
window.addEventListener("load",function() {

// Set up a basic Quintus object
// with the necessary modules and controls
var Q = window.Q = Quintus({ development: true })
.include("Sprites, Scenes, Input, 2D")
.include("Sprites, Scenes, Input, 2D, UI")
.setup({ width: 640, height: 480 })
.controls(true)

// Add in the default keyboard controls
// along with joypad controls for touch
Q.input.keyboardControls();
Q.input.joypadControls();
Q.state.reset({ score: 0, lives: 2, stage: 1});
console.log(Q.state.get("score"));

Q.gravityX = 0;
Q.gravityY = 0;
Expand Down Expand Up @@ -73,7 +75,19 @@
}
});


Q.UI.Text.extend("Score", {
init: function(p) {
this._super({
label: "Score: 0",
x:100,
y:20
});
Q.state.on("change.score",this,"scoreChange");
},
scoreChange: function(score) {
this.p.label = "Score: " + score;
}
});
Q.Sprite.extend("Player", {
init: function(p) {

Expand All @@ -84,7 +98,7 @@
});

this.add("2d, towerManControls");
}
}
});


Expand All @@ -109,9 +123,10 @@
// Destroy it and keep track of how many dots are left
this.destroy();
this.stage.dotCount--;
Q.state.inc("score",100);
// If there are no more dots left, just restart the game
if(this.stage.dotCount == 0) {
Q.stageScene("level1");
Q.stageScene("level2");
}
},

Expand Down Expand Up @@ -141,8 +156,8 @@
}

Q.TileLayer.extend("TowerManMap",{
init: function(p) {
this._super(p,{
init: function() {
this._super({
type: SPRITE_TILES,
dataAsset: 'level.json',
sheet: 'tiles',
Expand All @@ -169,7 +184,35 @@
}

});
Q.TileLayer.extend("TowerManMap2",{
init: function() {
this._super({
type: SPRITE_TILES,
dataAsset: 'level2.json',
sheet: 'tiles',
});

},

setup: function() {
// Clone the top level arriw
var tiles = this.p.tiles = this.p.tiles.concat();
var size = this.p.tileW;
for(var y=0;y<tiles.length;y++) {
var row = tiles[y] = tiles[y].concat();
for(var x =0;x<row.length;x++) {
var tile = row[x];

if(tile == 0 || tile == 2) {
var className = tile == 0 ? 'Dot' : 'Tower'
this.stage.insert(new Q[className](Q.tilePos(x,y)));
row[x] = 0;
}
}
}
}

});
Q.component("enemyControls", {
defaults: { speed: 100, direction: 'left', switchPercent: 2 },

Expand Down Expand Up @@ -235,6 +278,7 @@

hit: function(col) {
if(col.obj.isA("Player")) {
Q.state.reset({ score: 0, lives: 2, stage: 1});
Q.stageScene("level1");
}
}
Expand All @@ -243,20 +287,62 @@
Q.scene("level1",function(stage) {
var map = stage.collisionLayer(new Q.TowerManMap());
map.setup();
/**
var container = stage.insert(new Q.UI.Container({

y: 48,
x: Q.width/2
}));

stage.insert(new Q.UI.Text({
label: "Score: " + Q.state.get("score"),
color: "white",
x: -207,
y: -30
}),container);
container.fit(2,2);
**/
stage.insert(new Q.Score());
stage.insert(new Q.Player(Q.tilePos(10,7)));

stage.insert(new Q.Enemy(Q.tilePos(10,4)));
stage.insert(new Q.Enemy(Q.tilePos(15,10)));
stage.insert(new Q.Enemy(Q.tilePos(5,10)));
});
Q.scene("level2",function(stage) {
var map = stage.collisionLayer(new Q.TowerManMap2());
map.setup();
/**
var container = stage.insert(new Q.UI.Container({

y: 48,
x: Q.width/2
}));

Q.state.on("change.score",this,"score");
stage.insert(new Q.UI.Text({

label: "Score: " + Q.state.get("score"),
color: "white",
x: -207,
y: -30
}),container);
container.fit(2,2);**/
stage.insert(new Q.Score());
stage.insert(new Q.Player(Q.tilePos(10,7)));

stage.insert(new Q.Enemy(Q.tilePos(10,4)));
stage.insert(new Q.Enemy(Q.tilePos(15,10)));
stage.insert(new Q.Enemy(Q.tilePos(5,10)));
});

Q.load("sprites.png, sprites.json, level.json, tiles.png", function() {
Q.load("sprites.png, sprites.json, level.json, level2.json, tiles.png", function() {
Q.sheet("tiles","tiles.png", { tileW: 32, tileH: 32 });

Q.compileSheets("sprites.png","sprites.json");

Q.stageScene("level1");

});

});