Skip to content

Commit

Permalink
Stops going over a level
Browse files Browse the repository at this point in the history
Stops the players trying to access further than the last level
  • Loading branch information
hobnob committed Nov 28, 2012
1 parent 34e74a1 commit 8e20d93
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
13 changes: 12 additions & 1 deletion css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,15 @@ canvas
height:101px;
top:-160px;
margin-left:198px;
}
}

#game_scorecard .disabled
{
opacity:0.5;
}

#game_scorecard .disabled:hover
{
cursor: default;
background-position: 0px 0px;
}
2 changes: 1 addition & 1 deletion js/lib/levels/level_4.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
{"type":"stats","clonePar":2,"timePar":15},
{"type":"stats","clonePar":2,"timePar":15,"lastLevel":true},
{"type":"wall","x":0,"y":680,"repeat-x":2},
{"type":"player","x":150,"y": 550},
{"type":"lever","x":350,"y": 641,"outputs":[
Expand Down
19 changes: 17 additions & 2 deletions js/lib/scorecard.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ function scorecard()

var _timeTaken = 0;

var _lastLevel = false;

if ( !($('#game_scorecard').length) )
{
$('#gameWindow').append('<div id="game_scorecard_bg"></div>');
Expand Down Expand Up @@ -37,12 +39,16 @@ function scorecard()
return this;
}

this.setClonesUsed = function( clones )
{
this.setClonesUsed = function( clones ){
_clones = clones;
return this;
}

this.setLastLevel = function(last){
_lastLevel = last;
return this;
}

this.show = function(){
$('#game_scorecard .clones').text(_clones);
$('#game_scorecard .time').text(_calcTime());
Expand Down Expand Up @@ -77,6 +83,15 @@ function scorecard()
$('#game_scorecard .score').append(star);
}

if ( _lastLevel )
{
$('#game_scorecard .nextLevel').addClass('disabled');
}
else
{
$('#game_scorecard .nextLevel').removeClass('disabled');
}

$('#game_scorecard_bg').fadeIn();
}

Expand Down
5 changes: 5 additions & 0 deletions js/lib/startMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ function startMenu()
event.preventDefault();
}

if ( $('#game_scorecard .nextLevel').hasClass('disabled') )
{
return false;
}

lvlNum++;

resetLevel();
Expand Down
9 changes: 9 additions & 0 deletions js/lib/world.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,15 @@ function world()
{
_scorecard.setParForClones(data[i]['clonePar']);
_scorecard.setParForTime(data[i]['timePar']);

if ( typeof(data[i]['lastLevel']) == 'boolean' )
{
_scorecard.setLastLevel(data[i]['lastLevel']);
}
else
{
_scorecard.setLastLevel(false);
}
}
else
{
Expand Down

0 comments on commit 8e20d93

Please sign in to comment.