Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed flicker , powerups moving faster

  • Loading branch information...
commit 03e48589fcdcaebe923d9bbc754c8fcd6f99afb6 1 parent 2c5423e
@BlackScorp authored
View
6 assets/js/audio.js
@@ -112,9 +112,9 @@ Crafty.extend({
};
},
stop:function(id){
- if(!Crafty.support.audio || !this.sounds[id]) return;
- var s = this.sounds[id];
- if(!s.obj.paused) s.obj.pause();
+ if(!Crafty.support.audio || !this.sounds[id]) return;
+ var s = this.sounds[id];
+ if(!s.obj.paused) s.obj.pause();
},
mute:function(){
var s;
View
17 assets/js/effects.js
@@ -23,17 +23,22 @@ Crafty.c("Damage",{
}
});
Crafty.c("Flicker",{
+ flicker:true,
init:function(){
+ this.flicker = true;
+
this.bind("EnterFrame",function(frame){
- if(frame.frame % 5 == 0 && this.has("Flicker")){
- if(this.alpha == 0.5){
+ if(frame.frame % 5 == 0 && this.flicker){
+ if(this.alpha == 0.0){
this.alpha = 1.0;
}else{
- this.alpha = 0.5;
+ this.alpha = 0.0;
}
}
- }).bind("RemoveComponent",function(){
- this.alpha = 1.0;
+ if(!this.flicker){
+ this.alpha = 1.0;
+ }
});
- }
+ }
+
});
View
2  assets/js/enemys.js
@@ -54,7 +54,7 @@ Crafty.c("Enemy",{
Crafty(this.playerID).trigger("Killed",this.points);
//Destroy the asteroid
this.destroy();
- if(Crafty.math.randomInt(0, 100) > 80){
+ if(Crafty.math.randomInt(0, 100) > 70){
var powerUp = powerUps[Crafty.math.randomInt(0, powerUps.length-1)];
Crafty.e(powerUp).attr({
x:this.x,
View
2  assets/js/levels.js
@@ -72,7 +72,7 @@ Crafty.scene("Level1",function(){
var spotEnemys = function(frame){
//Spot each 50th Fram one Asteroid
- if(frame % 50 == 0 && Crafty("Asteroid").length < 4 && Crafty("SmallAsteroid").length < 10){
+ if(frame % 50 == 0 && Crafty("Asteroid").length < 2 && Crafty("SmallAsteroid").length < 8){
Crafty.e("Asteroid");
}
View
25 assets/js/player.js
@@ -47,7 +47,7 @@ Crafty.c("Player",{
var keyDown = false; //Player didnt pressed a key
this
- .addComponent("2D","Canvas",this.ship,"Multiway","Keyboard","Collision") /*Add needed Components*/
+ .requires("2D,Canvas,"+this.ship+",Multiway,Keyboard,Collision,Flicker") /*Add needed Components*/
.multiway(this.movementSpeed, { /*Enable Movement Control*/
UP_ARROW: -90,
DOWN_ARROW: 90,
@@ -59,12 +59,13 @@ Crafty.c("Player",{
if(this.x+this.w > Crafty.viewport.width ||
this.x+this.w < this.w ||
this.y+this.h-35 < this.h ||
- this.y+this.h+35 > Crafty.viewport.height){
+ this.y+this.h+35 > Crafty.viewport.height || this.preparing){
this.attr({
x:from.x,
y:from.y
});
}
+
})
.bind("KeyDown", function(e) {
if(e.keyCode === Crafty.keys.SPACE){
@@ -95,10 +96,10 @@ Crafty.c("Player",{
}
if(this.preparing){
- this.y-=1;
- if(this.y < Crafty.viewport.height-this.h-100){
+ this.y--;
+ if(this.y < Crafty.viewport.height-this.h-Crafty.viewport.height/4){
this.preparing = false;
- this.removeComponent("Flicker");
+ this.flicker=false;
}
}
@@ -109,7 +110,7 @@ Crafty.c("Player",{
this.updateScore();
})
.bind("Hurt",function(dmg){
- if(this.has("Flicker")) return;
+ if(this.flicker) return;
Crafty.e("Damage").attr({
x:this.x,
y:this.y
@@ -136,7 +137,7 @@ Crafty.c("Player",{
}
})
.bind("RestoreShield",function(val){
- if(this.shield.current < this.shield.max){
+ if(this.shield.current < this.shield.max){
this.shield.current += val;
this.updateShield();
}
@@ -167,12 +168,13 @@ Crafty.c("Player",{
this.updateScore();
//Init position
this.x = Crafty.viewport.width/2-this.w/2;
- this.y = Crafty.viewport.height-this.h;
+ this.y = Crafty.viewport.height-this.h-36;
- this.addComponent("Flicker");
+ this.flicker = true;
this.preparing = true;
},
shoot:function(){
+ if(this.preparing) return;
var bullet = Crafty.e(this.weapon.name,"PlayerBullet");
bullet.attr({
playerID:this[0],
@@ -203,11 +205,12 @@ Crafty.c("Player",{
this.destroy();
this.infos.alert.show().text('Game Over!').effect('pulsate',500);
Crafty.audio.stop("space");
- Crafty.audio.play("gameover",-1);
+ Crafty.audio.play("gameover",-1);
gameHooks.endGame(this.score);
- // Crafty.pause();
+ // Crafty.pause();
}else{
+
this.reset();
}
View
2  assets/js/powerups.js
@@ -10,7 +10,7 @@ Crafty.c("PowerUp",{
this.destroy();
})
.bind("EnterFrame",function(){
- this.y+=1;
+ this.y+=2;
});
}
});
View
2  cron.webapp
@@ -16,7 +16,7 @@
"url": "https://twitter.com/#!/xBlackScorpx"
},
"installs_allowed_from": [
- "http://cron.cruel-online.de" ,"http://blackscorp.github.com/cron/","https://marketplace.mozilla.org/"
+ "http://cron.cruel-online.de" ,"https://marketplace.mozilla.org/"
],
"locales": {
"de": {
Please sign in to comment.
Something went wrong with that request. Please try again.