+
+
diff --git a/guiltouf/js/GameClass.js b/guiltouf/js/GameClass.js
index d0110c1..02e6954 100644
--- a/guiltouf/js/GameClass.js
+++ b/guiltouf/js/GameClass.js
@@ -5,7 +5,6 @@ var Level = 1 ;
var Layouts = {} ;
var timers = {} ;
var Game = null ;
-var cos = Math.cos, sin = Math.sin, tan = Math.tan, exp = Math.exp, log = Math.log, pow = Math.pow ;
// -- Init scene prototype
var app = function(opts) {
diff --git a/guiltouf/js/LayoutClass.js b/guiltouf/js/LayoutClass.js
index 1411264..af9bcf8 100644
--- a/guiltouf/js/LayoutClass.js
+++ b/guiltouf/js/LayoutClass.js
@@ -97,6 +97,7 @@ Layout.prototype.createObj = function(opts) {
$.extend(true, settingsObj, optsObj) ;
// -- Store options
+ this.parent = self ;
this.name = settingsObj.name || 'default' ;
this.id = settingsObj.id || 'element_'+Wyrian.uniqId++ ;
this.width = settingsObj.width ? settingsObj.width : self.width ;
@@ -130,18 +131,20 @@ Layout.prototype.createObj = function(opts) {
backgroundPosition: settingsObj.backgroundPosition,
backgroundImage: settingsObj.imageSrc ? 'url('+settingsObj.imageSrc+')' : ''
}
- })
+ }).appendTo(self.dom) ;
}
// -- Apply CSS
this.box.css({
width: this.width,
height: this.height
- }).transform({'translate': this.x+'px, '+this.y+'px'}) ;
+ }) ;
+
+ // -- Move
+ if ( ! this.settings.nomove ) {
+ this.box.transform({'translate': this.x+'px, '+this.y+'px'}) ;
+ }
- // -- Append to scene
- this.box.appendTo(self.dom) ;
-
} ;
// -- Init
@@ -150,6 +153,11 @@ Layout.prototype.createObj = function(opts) {
this.y = this.settings.origin.y ;
} ;
+ // -- Return instance
+ Obj.prototype.getInstance = function() {
+ return this;
+ } ;
+
// -- Draw object into scene
Obj.prototype.draw = function() {
if ( (this.y >= -this.height) && (this.y <= (Wyrian.height+this.height)) && this.x >= -this.width && this.x <= (Wyrian.width+this.width) ) {
@@ -158,16 +166,21 @@ Layout.prototype.createObj = function(opts) {
if ( this.settings.sprites ) {
this.lastSprite = this.lastSprite || 0 ;
this.lastSprite++ ;
- if ( this.lastSprite >= this.settings.sprites.length )
- this.lastSprite = 0 ;
- this.box.css({'backgroundPosition': -1*this.lastSprite*this.settings.width+'px 0'}) ;
+ if ( typeof this.settings.sprites[this.lastSprite] == 'undefined' ) this.lastSprite = 0 ;
+ this.box.css({'backgroundPosition': -1*this.settings.sprites[this.lastSprite]*this.settings.width+'px 0'}) ;
+
+
+ //if ( this.id == 'ship' )
+ // console.log(this.settings.sprites, -1*this.settings.sprites[this.lastSprite]*this.settings.width+'px 0') ;
}
// -- Move div
- if ( this.settings.moveParent ) {
- this.box.parent().transform({'translate': this.x+'px, '+this.y+'px'}) ;
- } else {
- this.box.transform({'translate': this.x+'px, '+this.y+'px'}) ;
+ if ( ! this.settings.nomove ) {
+ if ( this.settings.moveParent ) {
+ this.box.parent().css({'translate': this.x+'px, '+this.y+'px'}) ;
+ } else {
+ this.box.css({'translate': this.x+'px, '+this.y+'px'}) ;
+ }
}
}
@@ -178,10 +191,8 @@ Layout.prototype.createObj = function(opts) {
if ( $.isFunction(this.settings.animate) ) {
this.parent = self ;
this.settings.animate(this) ;
- this.draw(this) ;
- } else {
- this.draw() ;
- }
+ }
+ if ( ! this.nodraw ) this.draw() ;
}
// -- Remove object
diff --git a/guiltouf/js/layouts/BgLayer.js b/guiltouf/js/layouts/BgLayer.js
index 9fef484..365d5b7 100644
--- a/guiltouf/js/layouts/BgLayer.js
+++ b/guiltouf/js/layouts/BgLayer.js
@@ -8,12 +8,14 @@ Layouts.Background = new Layout({
animate: function(obj) {
obj.y -= obj.parent.settings.speed*obj.parent.settings.direction;
obj.parent.settings.dom.css({backgroundPosition: '0 '+obj.y+'px'}) ;
+ obj.nodraw = true ;
}
}],
// -- Define current Speed
speed: 5,
direction: -1,
+ nomove: true,
// -- Define canvas parent
dom: $('div#background')
diff --git a/guiltouf/js/layouts/Ennemies.js b/guiltouf/js/layouts/Ennemies.js
index 7d05adb..ab235c9 100644
--- a/guiltouf/js/layouts/Ennemies.js
+++ b/guiltouf/js/layouts/Ennemies.js
@@ -16,6 +16,7 @@ Layouts.Ennemies = new Layout({
// -- Create a random ennemy
Layouts.Ennemies.createRandom = function(opts) {
+ var self = this ;
var bulletConf = {
name: 'ennemy',
width: 60,
@@ -25,12 +26,12 @@ Layouts.Ennemies.createRandom = function(opts) {
sprites: [0,1,2],
speed: Math.round(Math.max(10, Math.random()*20)),
direction: 1,
- origin: {x:Math.round(Math.random()*this.width), y:0},
+ origin: {x:Math.round(Math.random()*self.width), y:Math.round(-Math.random()*self.height)},
animate: function (obj) {
- if ( obj.deleteAfter ) return false;
obj.y += obj.settings.speed*obj.settings.direction ;
- if ( obj.y > obj.parent.height ) {
- obj.deleteAfter = true ;
+ if ( obj.y > obj.parent.height+obj.height ) {
+ obj.x = Math.round(Math.random()*self.width)
+ obj.y = Math.round(-Math.random()*self.height) ;
}
}
} ;
diff --git a/guiltouf/js/layouts/PlayerLayer.js b/guiltouf/js/layouts/PlayerLayer.js
index 108509a..a7a1bb3 100644
--- a/guiltouf/js/layouts/PlayerLayer.js
+++ b/guiltouf/js/layouts/PlayerLayer.js
@@ -6,18 +6,19 @@ Layouts.Player = new Layout({
el: [{
id: 'ship',
width: 160,
- height: 137,
+ height: 160,
+ sprites: [0,1],
origin: {
x: Wyrian.width/2 - 80,
y: Wyrian.height-220
},
fireInterval: 300,
- //moveParent: true,
animate: function(obj) {
// -- KEY up /down
- if ( Wyrian.input.keyboard.up && obj.y > 0 ) {
- obj.y -= obj.parent.settings.speed ;
+ if ( Wyrian.input.keyboard.up ) {
+ if ( obj.y > 0 ) obj.y -= obj.parent.settings.speed ;
+
}
if ( Wyrian.input.keyboard.down && (obj.y < (Wyrian.height-obj.height) ) ) {
obj.y += obj.parent.settings.speed;
@@ -25,16 +26,11 @@ Layouts.Player = new Layout({
// -- Left/Right move : choose sprite sequence to display
if ( Wyrian.input.keyboard.left && (obj.x > 0)) {
- obj.spriteIndex = 0 ;
obj.x -= obj.parent.settings.speed;
}
- else if ( Wyrian.input.keyboard.right && (obj.x < Wyrian.width-obj.width) ) {
- obj.spriteIndex = 2 ;
+ if ( Wyrian.input.keyboard.right && (obj.x < Wyrian.width-obj.width) ) {
obj.x += obj.parent.settings.speed;
}
- else {
- obj.spriteIndex = 1 ;
- }
// -- Press Space : fire
if ( Wyrian.input.keyboard.space ) {
@@ -42,6 +38,22 @@ Layouts.Player = new Layout({
}
}
+ }, {
+
+ id: 'ship_reactor',
+ width: 44,
+ height: 68,
+ backgroundColor:'red',
+ imageSrc: '/images/sprites/reactor_fire_sprite.png',
+ sprites: [0,1],
+ nomove: true,
+ animate: function(obj) {
+ obj.settings.sprites = [0,1] ;
+ if ( Wyrian.input.keyboard.up ) {
+ obj.getInstance().settings.sprites = [2,3,4] ;
+ }
+ }
+
}],
// -- Define current Speed
@@ -66,24 +78,13 @@ Layouts.Player.bulletLib = function(obj, bulletType) {
} ;
// -- Default Left
- if ( bulletType == 'default_left' ) {
+ if ( bulletType == 'default' ) {
bulletConf.width = 16 ;
bulletConf.height = 64 ;
bulletConf.sprites = false ;
bulletConf.imageSrc = '/images/12px-long-blue.png' ;
bulletConf.name = 'bullet' ;
- bulletConf.origin.x = obj.x+8+obj.width/2 ;
- bulletConf.origin.y = obj.y - bulletConf.height ;
- }
-
- // -- Default Right
- if ( bulletType == 'default_right' ) {
- bulletConf.width = 16 ;
- bulletConf.height = 64 ;
- bulletConf.sprites = false ;
- bulletConf.imageSrc = '/images/12px-long-blue.png' ;
- bulletConf.name = 'bullet' ;
- bulletConf.origin.x = obj.x-8+obj.width/2 ;
+ bulletConf.origin.x = obj.x-6+obj.width/2 ;
bulletConf.origin.y = obj.y - bulletConf.height ;
}
@@ -93,8 +94,8 @@ Layouts.Player.bulletLib = function(obj, bulletType) {
bulletConf.height = 60 ;
bulletConf.speed = 20 ;
bulletConf.name = 'bullet' ;
- bulletConf.origin.x = obj.x+30+obj.width/2 ;
- bulletConf.origin.y = obj.y + 30 - bulletConf.height ;
+ bulletConf.origin.x = obj.x+20+obj.width/2 ;
+ bulletConf.origin.y = obj.y + 50 - bulletConf.height ;
}
// -- Big Left
@@ -103,8 +104,8 @@ Layouts.Player.bulletLib = function(obj, bulletType) {
bulletConf.height = 60 ;
bulletConf.speed = 20 ;
bulletConf.name = 'bullet' ;
- bulletConf.origin.x = obj.x-60+obj.width/2 ;
- bulletConf.origin.y = obj.y + 30 - bulletConf.height ;
+ bulletConf.origin.x = obj.x-75+obj.width/2 ;
+ bulletConf.origin.y = obj.y + 50 - bulletConf.height ;
}
// -- The animate function
@@ -136,8 +137,7 @@ Layouts.Player.fire = function(obj) {
// Create new bullets
var bullets = [] ;
- bullets.push(this.bulletLib(obj, 'default_left')) ;
- bullets.push(this.bulletLib(obj, 'default_right')) ;
+ bullets.push(this.bulletLib(obj, 'default')) ;
bullets.push(this.bulletLib(obj, 'big_left')) ;
bullets.push(this.bulletLib(obj, 'big_right')) ;
for ( var i in bullets ) {
diff --git a/images/.empty b/images/.empty
deleted file mode 100644
index e69de29..0000000
diff --git a/images/wings_eagle_sprite.png b/images/wings_eagle_sprite.png
new file mode 100644
index 0000000..05b0dfe
Binary files /dev/null and b/images/wings_eagle_sprite.png differ