Skip to content

Commit

Permalink
Changed the shape of Player to classic triangle
Browse files Browse the repository at this point in the history
  • Loading branch information
tommoor committed Dec 23, 2011
1 parent 153bf00 commit eb4ca89
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 18 deletions.
13 changes: 0 additions & 13 deletions lib/Body.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,6 @@ condor.Body = Container.extend({
this.oldx -= (x || 0);
this.oldy -= (y || 0);
},

initialize: function () {
Container.prototype.initialize.call(this);

// temporary graphic to show particles
this.body = new Shape();
var g = this.body.graphics;
g.clear();
g.beginStroke("#333333");
g.beginFill("#999999");
g.drawCircle(0,0,this.WIDTH);
this.addChild(this.body);
},

checkBounds: function () {

Expand Down
18 changes: 18 additions & 0 deletions lib/Enemy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@ condor.Enemy = condor.Body.extend({
nextx: 0,
nexty: 0,

initialize: function () {
Container.prototype.initialize.call(this);

this.display();
},

display: function () {

// temporary graphic
this.body = new Shape();
var g = this.body.graphics;
g.clear();
g.beginStroke("#333333");
g.beginFill("#999999");
g.drawCircle(0,0,this.WIDTH);
this.addChild(this.body);
},

tick: function () {

this.checkWaypoint();
Expand Down
7 changes: 4 additions & 3 deletions lib/ParticleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ condor.ParticleManager = {
return n;
},

spark: function (x, y, size) {

spark: function (object, size) {
console.log('spark!');

var size = size || 10;

for (var i=0; i< size; i++) {
var p = new condor.Particle();
var angle = Math.random()*57.2957795;
var speed = 5+Math.random()*20;
p.position(x,y);
p.position(object.x,object.y);
p.accelerate(speed*Math.sin(angle),speed*Math.cos(angle));
this.add(p);
condor.interface.stage.addChild(p);
Expand Down
19 changes: 19 additions & 0 deletions lib/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,32 @@ condor.Player = condor.Body.extend({

ACCELERATION: 15,
FRICTION: 0.5,
WIDTH: 12,
HEIGHT: 16,

initialize: function () {
condor.Body.prototype.initialize.call(this);

this.bindEvents();
this.display();
},

display: function () {

// temporary graphic
this.body = new Shape();
var g = this.body.graphics;
g.clear();
g.beginStroke("#333333");
g.beginFill("#aaaaaa");
g.moveTo(0,-this.HEIGHT);
g.lineTo(this.WIDTH,this.HEIGHT);
g.lineTo(-this.WIDTH,this.HEIGHT);
g.closePath();
this.addChild(this.body);
},


bindEvents: function () {
_.bindAll(this, 'moveLeft', 'moveRight', 'moveUp', 'moveDown', 'fire');

Expand Down
9 changes: 7 additions & 2 deletions lib/Projectile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ condor.Projectile = condor.Body.extend({
initialize: function () {
Container.prototype.initialize.call(this);

this.display();
},

display: function () {

this.body = new Shape();
var g = this.body.graphics;
g.clear();
Expand All @@ -19,7 +24,7 @@ condor.Projectile = condor.Body.extend({
g.lineTo(this.WIDTH, -this.HEIGHT);
g.lineTo(0, this.HEIGHT);
this.addChild(this.body);
},
},

fire: function () {
this.accelerate(0, -this.SPEED);
Expand All @@ -28,7 +33,7 @@ condor.Projectile = condor.Body.extend({
tick: function () {

if (!this.checkBounds()) {
condor.ParticleManager.spark(this.x, this.y);
condor.ParticleManager.spark(this);
}

this.update();
Expand Down

0 comments on commit eb4ca89

Please sign in to comment.