Last version :)
This commit is contained in:
parent
a34c32375f
commit
2c46de5ffc
5 changed files with 71 additions and 11 deletions
|
@ -1,3 +1,16 @@
|
||||||
|
/* BASICS */
|
||||||
|
.orbitron {
|
||||||
|
font-family: 'Orbitron', serif;
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
text-shadow: none;
|
||||||
|
text-decoration: none;
|
||||||
|
text-transform: none;
|
||||||
|
letter-spacing: 0em;
|
||||||
|
word-spacing: 0em;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
@ -104,9 +117,19 @@
|
||||||
/* The HUD */
|
/* The HUD */
|
||||||
#hud {
|
#hud {
|
||||||
z-index: 90;
|
z-index: 90;
|
||||||
display: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#hud .score {
|
||||||
|
font-size:36px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color:#fff;
|
||||||
|
font-weight: bold;
|
||||||
|
text-shadow: 0 0 5px rgba(115, 171, 255, 0.4) ;
|
||||||
|
position: absolute;
|
||||||
|
display: block;
|
||||||
|
top:20px;
|
||||||
|
right: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
/* Debug Panel */
|
/* Debug Panel */
|
||||||
#debug {
|
#debug {
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" media="all" href="css/style.css" />
|
<link rel="stylesheet" media="all" href="css/style.css" />
|
||||||
|
<link href="http://fonts.googleapis.com/css?family=Orbitron:400,500,700,900" rel="stylesheet" type="text/css" >
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="debug">
|
<div id="debug">
|
||||||
yep
|
|
||||||
</div>
|
</div>
|
||||||
<div class="container" id="GameContainer">
|
<div class="container" id="GameContainer">
|
||||||
<div id="background" class="layout"></div>
|
<div id="background" class="layout"></div>
|
||||||
|
@ -22,7 +22,9 @@
|
||||||
<div class="wing right"></div>
|
<div class="wing right"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="hud" class="layout"></div>
|
<div id="hud" class="layout">
|
||||||
|
<div class="score orbitron">Score : <span>0</span></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Init Global vars
|
// Init Global vars
|
||||||
var FPS = 40;
|
var FPS = 30;
|
||||||
var Stages = {} ;
|
var Stages = {} ;
|
||||||
var Level = 1 ;
|
var Level = 1 ;
|
||||||
var Layouts = {} ;
|
var Layouts = {} ;
|
||||||
|
@ -78,6 +78,42 @@ app.prototype.loopAnimation = function() {
|
||||||
this.activeEls = [] ;
|
this.activeEls = [] ;
|
||||||
|
|
||||||
// -- Detect collisions
|
// -- Detect collisions
|
||||||
|
console.log('-------------------' ) ;
|
||||||
|
for ( var i in Layouts ) {
|
||||||
|
var _layout = Layouts[i] ;
|
||||||
|
if ( _layout && _layout.running ) {
|
||||||
|
for ( var j in _layout.els ) {
|
||||||
|
var el = _layout.els[j],
|
||||||
|
type = el.name ;
|
||||||
|
|
||||||
|
// -- Make some clean
|
||||||
|
if (el.deleteAfter ) {
|
||||||
|
delete Layouts[i].els[j] ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- Detect only defined types
|
||||||
|
else {
|
||||||
|
if ( type == 'ennemy' || type == 'bullet' || type == 'ship' || type == 'ship' ) {
|
||||||
|
|
||||||
|
var pos = {
|
||||||
|
x: el.x,
|
||||||
|
y: el.y,
|
||||||
|
xX: el.x + el.with,
|
||||||
|
yY: el.x + el.with
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- Test if in viewport
|
||||||
|
//if ( pos )
|
||||||
|
//console.log(type, coords) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// -- Search for elements that have to be updated
|
// -- Search for elements that have to be updated
|
||||||
|
|
|
@ -162,7 +162,7 @@ Layout.prototype.createObj = function(opts) {
|
||||||
|
|
||||||
// -- Draw object into scene
|
// -- Draw object into scene
|
||||||
Obj.prototype.draw = function() {
|
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) ) {
|
if ( (this.y >= -2*this.height) && (this.y <= (Wyrian.height+this.height)) && this.x >= -this.width && this.x <= (Wyrian.width+this.width) ) {
|
||||||
|
|
||||||
// -- Set sprite to display
|
// -- Set sprite to display
|
||||||
if ( this.settings.sprites ) {
|
if ( this.settings.sprites ) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ Layouts.Player = new Layout({
|
||||||
// -- Define elements to draw with options
|
// -- Define elements to draw with options
|
||||||
el: [{
|
el: [{
|
||||||
id: 'ship',
|
id: 'ship',
|
||||||
|
name: 'ship',
|
||||||
width: 160,
|
width: 160,
|
||||||
height: 160,
|
height: 160,
|
||||||
sprites: [0,1],
|
sprites: [0,1],
|
||||||
|
@ -73,16 +74,16 @@ Layouts.Player.bulletLib = function(obj, bulletType) {
|
||||||
sprites: [0,1,2],
|
sprites: [0,1,2],
|
||||||
speed: 40,
|
speed: 40,
|
||||||
direction: -1,
|
direction: -1,
|
||||||
|
name: 'bullet',
|
||||||
origin: {x:0, y:0}
|
origin: {x:0, y:0}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
// -- Default Left
|
// -- Default Left
|
||||||
if ( bulletType == 'default' ) {
|
if ( bulletType == 'weapon_pilot' ) {
|
||||||
bulletConf.width = 16 ;
|
bulletConf.width = 16 ;
|
||||||
bulletConf.height = 64 ;
|
bulletConf.height = 64 ;
|
||||||
bulletConf.sprites = false ;
|
bulletConf.sprites = false ;
|
||||||
bulletConf.imageSrc = '/images/12px-long-blue.png' ;
|
bulletConf.imageSrc = '/images/12px-long-blue.png' ;
|
||||||
bulletConf.name = 'bullet' ;
|
|
||||||
bulletConf.origin.x = obj.x-6+obj.width/2 ;
|
bulletConf.origin.x = obj.x-6+obj.width/2 ;
|
||||||
bulletConf.origin.y = obj.y - bulletConf.height ;
|
bulletConf.origin.y = obj.y - bulletConf.height ;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +93,6 @@ Layouts.Player.bulletLib = function(obj, bulletType) {
|
||||||
bulletConf.width = 60 ;
|
bulletConf.width = 60 ;
|
||||||
bulletConf.height = 60 ;
|
bulletConf.height = 60 ;
|
||||||
bulletConf.speed = 20 ;
|
bulletConf.speed = 20 ;
|
||||||
bulletConf.name = 'bullet' ;
|
|
||||||
bulletConf.origin.x = obj.x+18+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 ;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,6 @@ Layouts.Player.bulletLib = function(obj, bulletType) {
|
||||||
bulletConf.width = 60 ;
|
bulletConf.width = 60 ;
|
||||||
bulletConf.height = 60 ;
|
bulletConf.height = 60 ;
|
||||||
bulletConf.speed = 20 ;
|
bulletConf.speed = 20 ;
|
||||||
bulletConf.name = 'bullet' ;
|
|
||||||
bulletConf.origin.x = obj.x-75+obj.width/2 ;
|
bulletConf.origin.x = obj.x-75+obj.width/2 ;
|
||||||
bulletConf.origin.y = obj.y + 50 - bulletConf.height ;
|
bulletConf.origin.y = obj.y + 50 - bulletConf.height ;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +110,7 @@ Layouts.Player.bulletLib = function(obj, bulletType) {
|
||||||
bulletConf.animate = function(obj) {
|
bulletConf.animate = function(obj) {
|
||||||
if ( obj.deleteAfter ) return false;
|
if ( obj.deleteAfter ) return false;
|
||||||
obj.y += obj.settings.speed*obj.settings.direction ;
|
obj.y += obj.settings.speed*obj.settings.direction ;
|
||||||
if ( obj.y < -obj.height ) {
|
if ( obj.y < -(obj.height+300) ) {
|
||||||
obj.deleteObj() ;
|
obj.deleteObj() ;
|
||||||
}
|
}
|
||||||
} ;
|
} ;
|
||||||
|
@ -136,7 +135,7 @@ Layouts.Player.fire = function(obj) {
|
||||||
|
|
||||||
// Create new bullets
|
// Create new bullets
|
||||||
var bullets = [] ;
|
var bullets = [] ;
|
||||||
bullets.push(this.bulletLib(obj, 'default')) ;
|
bullets.push(this.bulletLib(obj, 'weapon_pilot')) ;
|
||||||
bullets.push(this.bulletLib(obj, 'big_left')) ;
|
bullets.push(this.bulletLib(obj, 'big_left')) ;
|
||||||
bullets.push(this.bulletLib(obj, 'big_right')) ;
|
bullets.push(this.bulletLib(obj, 'big_right')) ;
|
||||||
for ( var i in bullets ) {
|
for ( var i in bullets ) {
|
||||||
|
|
Loading…
Reference in a new issue