Optimized version

This commit is contained in:
Guillaume DE LA RUE 2011-02-12 23:03:47 +01:00
parent f00413c676
commit a34c32375f
6 changed files with 32 additions and 18 deletions

View file

@ -18,19 +18,14 @@
z-index: 0; z-index: 0;
} }
#ground { #ground { z-index: 30; }
z-index: 30; #game { z-index: 60; }
}
#game {
z-index: 60;
}
/* The Ship */ /* The Ship */
#game #ship { #game #ship {
position: absolute; position: absolute;
display: block; display: none;
top:0; top:0;
left:0; left:0;
background: transparent; background: transparent;
@ -67,6 +62,21 @@
background: transparent url(/images/sprites/weapon_pilot.png) no-repeat 0 0; background: transparent url(/images/sprites/weapon_pilot.png) no-repeat 0 0;
} }
#ship .ship-foray {
position: absolute;
display: block;
top:30px;
left: 117px;
width: 19px;
height: 33px;
background: transparent url(/images/sprites/weapon_foray.png) no-repeat 0 0;
}
#ship .ship-foray.right {
background-position: right 0;
left: 24px;
}
#ship .ship-reactor { #ship .ship-reactor {
position: absolute; position: absolute;
display: block; display: block;
@ -88,17 +98,15 @@
} }
/* Ennemies */ /* Ennemies */
#game .ennemy { border: 1px solid blue; } /*#game .ennemy { border: 1px solid blue; } */
/* The HUD */
#hud { #hud {
z-index: 90; z-index: 90;
display: none; display: none;
} }
#ship {
top: 50%;
left: 50%;
background: white;
}
/* Debug Panel */ /* Debug Panel */
#debug { #debug {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -15,6 +15,8 @@
<div class="ship-canon"></div> <div class="ship-canon"></div>
<div class="ship_reactor_fire" id="ship_reactor"></div> <div class="ship_reactor_fire" id="ship_reactor"></div>
<div class="ship-reactor"></div> <div class="ship-reactor"></div>
<div class="ship-foray left"></div>
<div class ="ship-foray right"></div>
<div class="ship-body"></div> <div class="ship-body"></div>
<div class="wing left"></div> <div class="wing left"></div>
<div class="wing right"></div> <div class="wing right"></div>

View file

@ -1,5 +1,5 @@
// Init Global vars // Init Global vars
var FPS = 30; var FPS = 40;
var Stages = {} ; var Stages = {} ;
var Level = 1 ; var Level = 1 ;
var Layouts = {} ; var Layouts = {} ;
@ -77,6 +77,9 @@ app.prototype.loopAnimation = function() {
// -- Build an active elements list // -- Build an active elements list
this.activeEls = [] ; this.activeEls = [] ;
// -- Detect collisions
// -- Search for elements that have to be updated // -- Search for elements that have to be updated
for ( var i in Layouts ) { for ( var i in Layouts ) {
var _layout = Layouts[i] ; var _layout = Layouts[i] ;
@ -91,10 +94,10 @@ app.prototype.loopAnimation = function() {
var _el = Layouts.Ennemies.els[i] ; var _el = Layouts.Ennemies.els[i] ;
if ( ! _el.deleteAfter ) numEnnemies++ ; if ( ! _el.deleteAfter ) numEnnemies++ ;
} }
$('#debug').html(numEnnemies) ;
for ( var i = numEnnemies-1 ; i < Level + 3 ; i++ ) { for ( var i = numEnnemies-1 ; i < Level + 3 ; i++ ) {
Layouts.Ennemies.createRandom() ; Layouts.Ennemies.createRandom() ;
} }
} }
// -- Bind Inputs // -- Bind Inputs

View file

@ -132,6 +132,8 @@ Layout.prototype.createObj = function(opts) {
backgroundImage: settingsObj.imageSrc ? 'url('+settingsObj.imageSrc+')' : '' backgroundImage: settingsObj.imageSrc ? 'url('+settingsObj.imageSrc+')' : ''
} }
}).appendTo(self.dom) ; }).appendTo(self.dom) ;
} else {
this.box.show(0) ;
} }
// -- Apply CSS // -- Apply CSS

View file

@ -18,7 +18,6 @@ Layouts.Player = new Layout({
// -- KEY up /down // -- KEY up /down
if ( Wyrian.input.keyboard.up ) { if ( Wyrian.input.keyboard.up ) {
if ( obj.y > 0 ) obj.y -= obj.parent.settings.speed ; if ( obj.y > 0 ) obj.y -= obj.parent.settings.speed ;
} }
if ( Wyrian.input.keyboard.down && (obj.y < (Wyrian.height-obj.height) ) ) { if ( Wyrian.input.keyboard.down && (obj.y < (Wyrian.height-obj.height) ) ) {
obj.y += obj.parent.settings.speed; obj.y += obj.parent.settings.speed;
@ -94,7 +93,7 @@ Layouts.Player.bulletLib = function(obj, bulletType) {
bulletConf.height = 60 ; bulletConf.height = 60 ;
bulletConf.speed = 20 ; bulletConf.speed = 20 ;
bulletConf.name = 'bullet' ; bulletConf.name = 'bullet' ;
bulletConf.origin.x = obj.x+20+obj.width/2 ; bulletConf.origin.x = obj.x+18+obj.width/2 ;
bulletConf.origin.y = obj.y + 50 - bulletConf.height ; bulletConf.origin.y = obj.y + 50 - bulletConf.height ;
} }