Last version :)

This commit is contained in:
Guillaume DE LA RUE 2011-02-13 00:15:01 +01:00
parent a34c32375f
commit 2c46de5ffc
5 changed files with 71 additions and 11 deletions

View file

@ -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 {
width: 100%;
height: 100%;
@ -104,9 +117,19 @@
/* The HUD */
#hud {
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 {

View file

@ -2,10 +2,10 @@
<html>
<head>
<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>
<body>
<div id="debug">
yep
</div>
<div class="container" id="GameContainer">
<div id="background" class="layout"></div>
@ -22,7 +22,9 @@
<div class="wing right"></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>

View file

@ -1,5 +1,5 @@
// Init Global vars
var FPS = 40;
var FPS = 30;
var Stages = {} ;
var Level = 1 ;
var Layouts = {} ;
@ -78,6 +78,42 @@ app.prototype.loopAnimation = function() {
this.activeEls = [] ;
// -- 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

View file

@ -162,7 +162,7 @@ Layout.prototype.createObj = function(opts) {
// -- 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) ) {
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
if ( this.settings.sprites ) {

View file

@ -5,6 +5,7 @@ Layouts.Player = new Layout({
// -- Define elements to draw with options
el: [{
id: 'ship',
name: 'ship',
width: 160,
height: 160,
sprites: [0,1],
@ -73,16 +74,16 @@ Layouts.Player.bulletLib = function(obj, bulletType) {
sprites: [0,1,2],
speed: 40,
direction: -1,
name: 'bullet',
origin: {x:0, y:0}
} ;
// -- Default Left
if ( bulletType == 'default' ) {
if ( bulletType == 'weapon_pilot' ) {
bulletConf.width = 16 ;
bulletConf.height = 64 ;
bulletConf.sprites = false ;
bulletConf.imageSrc = '/images/12px-long-blue.png' ;
bulletConf.name = 'bullet' ;
bulletConf.origin.x = obj.x-6+obj.width/2 ;
bulletConf.origin.y = obj.y - bulletConf.height ;
}
@ -92,7 +93,6 @@ Layouts.Player.bulletLib = function(obj, bulletType) {
bulletConf.width = 60 ;
bulletConf.height = 60 ;
bulletConf.speed = 20 ;
bulletConf.name = 'bullet' ;
bulletConf.origin.x = obj.x+18+obj.width/2 ;
bulletConf.origin.y = obj.y + 50 - bulletConf.height ;
}
@ -102,7 +102,6 @@ Layouts.Player.bulletLib = function(obj, bulletType) {
bulletConf.width = 60 ;
bulletConf.height = 60 ;
bulletConf.speed = 20 ;
bulletConf.name = 'bullet' ;
bulletConf.origin.x = obj.x-75+obj.width/2 ;
bulletConf.origin.y = obj.y + 50 - bulletConf.height ;
}
@ -111,7 +110,7 @@ Layouts.Player.bulletLib = function(obj, bulletType) {
bulletConf.animate = function(obj) {
if ( obj.deleteAfter ) return false;
obj.y += obj.settings.speed*obj.settings.direction ;
if ( obj.y < -obj.height ) {
if ( obj.y < -(obj.height+300) ) {
obj.deleteObj() ;
}
} ;
@ -136,7 +135,7 @@ Layouts.Player.fire = function(obj) {
// Create new 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_right')) ;
for ( var i in bullets ) {