Skip to content

Commit

Permalink
change in level
Browse files Browse the repository at this point in the history
  • Loading branch information
FRANCIS LOPEZ authored and FRANCIS LOPEZ committed Oct 24, 2015
2 parents 017125d + a85871d commit ba491e9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
8 changes: 8 additions & 0 deletions assets/data/levels.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"title": "Cave",
"tileset": "tilemap_cave",
"rockId": 1214,
<<<<<<< HEAD
"data":[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
Expand All @@ -13,11 +14,15 @@
[0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]

=======
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 1214, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>>>>>> a85871d8422cc93d715a1de95d9ae54cc9bd37a9
},
{
"title": "Ice Cave",
"tileset": "tilemap_cave",
"rockId": 974,
<<<<<<< HEAD
"data":[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 974, 974, 974, 974, 974, 974, 0, 974, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 974, 974, 974, 0, 974, 974, 974, 974, 0],
Expand All @@ -27,6 +32,9 @@
[0, 0, 0, 0, 974, 0, 974, 974, 974, 974, 974, 974, 0, 0, 0],
[0, 0, 974, 974, 974, 0, 974, 0, 0, 974, 0, 0, 0, 974, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 974, 0, 0, 0, 974, 0]]
=======
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 974, 974, 974, 974, 974, 974, 0, 974, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 974, 974, 974, 0, 974, 974, 974, 974, 0, 0, 0, 974, 974, 974, 0, 974, 0, 974, 0, 0, 0, 0, 974, 0, 0, 0, 0, 0, 974, 0, 974, 0, 974, 0, 0, 0, 0, 0, 0, 0, 974, 974, 0, 974, 0, 0, 0, 0, 0, 974, 0, 0, 974, 0, 0, 0, 0, 0, 974, 0, 974, 974, 974, 974, 974, 974, 0, 0, 0, 0, 0, 974, 974, 974, 0, 974, 0, 0, 974, 0, 0, 0, 974, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 974, 0, 0, 0, 974, 0]
>>>>>>> a85871d8422cc93d715a1de95d9ae54cc9bd37a9
},
{
"title": "Grass",
Expand Down
8 changes: 4 additions & 4 deletions scripts/objects/enemy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Enemy.prototype.handleArificialMovement = function(rocks,rocksColliding,moveChoo
//TODO:USE rocksColliding to create a fancy movement "IA"
if (moveChooser == 1)
{
if(rocksColliding.left!=false)
if(rocksColliding.left!=false && this.x-this.speed>0)
{ if(this.alive )
{
this.body.velocity.x = -this.speed;
Expand All @@ -46,7 +46,7 @@ Enemy.prototype.handleArificialMovement = function(rocks,rocksColliding,moveChoo
}
else if (moveChooser == 2)
{
if (rocksColliding.right!=false)
if (rocksColliding.right!=false && this.x+this.width+this.speed<this.game.world.bounds.right)
{
if(this.alive)
{
Expand All @@ -58,7 +58,7 @@ Enemy.prototype.handleArificialMovement = function(rocks,rocksColliding,moveChoo
}
else if (moveChooser == 3)
{
if(rocksColliding.up != false)
if(rocksColliding.up != false && this.y+this.height+this.speed<this.game.world.bounds.top )
{
if (this.alive)
{
Expand All @@ -71,7 +71,7 @@ Enemy.prototype.handleArificialMovement = function(rocks,rocksColliding,moveChoo
}
else if (moveChooser == 4 )
{
if(rocksColliding.down != false)
if(rocksColliding.down != false && this.y-this.speed>0)
{
if (this.alive)
{
Expand Down
38 changes: 24 additions & 14 deletions scripts/states/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,30 +111,40 @@ Game.prototype = {
this.createBomb(this.player.x + this.player.width / 2, this.player.y + this.player.height / 2, this.keyBomb, 0);
}

this.enemyDropBomb();
//this.enemyDropBomb();

},

enemyDropBomb: function(){
var enemyRandom = getRandomInt(0,this.enemyPool.children.length-1);
if (this.enemyPool.children[enemyRandom].canDropBombs(this.bombsPool)
&& this.time.now > this.nextBomb
&& this.enemyPool.children[enemyRandom].alive) {
this.createBomb(this.enemyPool.children[enemyRandom].x + this.enemyPool.children[enemyRandom].width / 2, this.enemyPool.children[enemyRandom].y + this.enemyPool.children[enemyRandom].height / 2, this.keyBomb, 0);
enemyDropBomb: function(enemy){
//var enemyRandom = getRandomInt(0,this.enemyPool.children.length-1);
//if (this.enemyPool.children[enemyRandom].canDropBombs(this.bombsPool)
//&& this.time.now > this.nextBomb
//&& this.enemyPool.children[enemyRandom].alive) {
// this.createBomb(this.enemyPool.children[enemyRandom].x + this.enemyPool.children[enemyRandom].width / 2, this.enemyPool.children[enemyRandom].y + this.enemyPool.children[enemyRandom].height / 2, this.keyBomb, 0);
//}
var range = 32;
console.log("EnemigoX: " +enemy.x);
console.log("EnemigoY: " +enemy.y);
console.log("PlayerX: " +this.player.x);
console.log("PlayerY: " +this.player.y);
if(enemy.alive && enemy.canDropBombs(this.bombsPool) && this.time.now > this.nextBomb)
{
if((enemy.x<=this.player.x && enemy.x+range>=this.player.x )|| (enemy.x>=this.player.x && enemy.x-range<=this.player.x ))
if((enemy.y<=this.player.y && enemy.y+range>=this.player.y )|| (enemy.y>=this.player.y && enemy.y-range<=this.player.y ))
this.createBomb(enemy.x + enemy.width / 2, enemy.y + enemy.height / 2, this.keyBomb, 0);
}
},
handleEnemyMovement: function(){
for (var i = 0, len = this.enemyPool.children.length; i < len; i++) {
//var rocksColliding = this.getRocksColliding(this.enemyPool.children[i].x, this.enemyPool.children[i].y);
// this.enemyPool.children[i].handleArificialMovement(this.rocks,rocksColliding,null);
console.log(this.enemyPool.children[i].y);

// this.easystar.findPath(this.enemyPool.children[i].x, this.enemyPool.children[i].y, this.player.x, this.player.y,null);
for (var i = 0, len = this.enemyPool.children.length; i < len; i++) {
var rocksColliding = this.getRocksColliding(this.enemyPool.children[i].x, this.enemyPool.children[i].y);
this.enemyPool.children[i].handleArificialMovement(this.rocks,rocksColliding,null);
var enemy = this.enemyPool.children[i];
this.enemyDropBomb(enemy);
this.easystar.findPath(this.enemyPool.children[i].x, 1,
100, 100,function(){
console.log("hola");
});
this.easystar.calculate();

}

},
Expand Down

0 comments on commit ba491e9

Please sign in to comment.