Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bug fixes to Resident Raver and tweaks to the weapon class and base p…
…layer.
  • Loading branch information
jessefreeman committed Jul 16, 2012
1 parent d4f8aa1 commit 67c70f4
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 77 deletions.
1 change: 0 additions & 1 deletion impact/lib/bootstrap/bootstrap.js
Expand Up @@ -12,7 +12,6 @@ ig.module(
'bootstrap.bootstrap'
)
.requires(
/* 'bootstrap.plugins.impact.raf',*/
'bootstrap.plugins.impact.menu',
'bootstrap.plugins.impact.tracking',
'bootstrap.plugins.impact.utils',
Expand Down
@@ -0,0 +1,31 @@
/**
* @levelexit.js
* @version: 1.00
* @author: Jesse Freeman
* @date: May 2012
* @copyright (c) 2012 Jesse Freeman, under The MIT License (see LICENSE)
*
*/

ig.module(
'bootstrap.demos.resident-raver.entities.advanced-text'
)
.requires(
'bootstrap.entities.text',
'plugins.imageblender.imageblender'
)
.defines(function ()
{

EntityAdvancedText = EntityText.extend({
init: function(x, y, settings)
{
if(settings.color)
this.font = new ig.Font('media/bootstrap/images/04b03.font.png'+settings.color);
this.parent(x,y,settings);
}

});

});

5 changes: 5 additions & 0 deletions impact/lib/bootstrap/demos/resident-raver/entities/ammo.js
Expand Up @@ -7,6 +7,11 @@ ig.module(
)
.defines(function ()
{
EntityAmmo = EntityBaseWeapons.extend({
_wmIgnore: true
//Empty class so Weltmeister doesn't throw an error
})

EntityBullet = EntityBaseWeapons.extend({
size:{x:5, y:3},
animSheet:new ig.AnimationSheet('media/bootstrap/demos/resident-raver/images/bullet.png', 5, 3),
Expand Down
Expand Up @@ -3,7 +3,8 @@ ig.module(
)
.requires(
'bootstrap.plugins.impact.caption',
'bootstrap.demos.resident-raver.entities.door'
'bootstrap.demos.resident-raver.entities.door',
'bootstrap.demos.resident-raver.plugins.local-storage'
)
.defines(function(){

Expand All @@ -18,15 +19,15 @@ ig.module(
//TODO depends on local storage

// Setup Local Storage
//this.storage = this.storage = new ig.Storage();
//ig.game.storage = ig.game.storage = new ig.Storage();

if (this.level) {
this.levelName = this.level.replace(/^(Level)?(\w)(\w*)/, function(m, l, a, b) {
return a.toUpperCase() + b;
});

var levelScoreID = this.levelName+"Score"
this.hiScore = 0//this.storage.getInt(levelScoreID) ? this.storage.getInt(levelScoreID) : 0;
this.hiScore = ig.game.storage.getInt(levelScoreID) ? ig.game.storage.getInt(levelScoreID) : 0;
}
},
onOpen: function(){
Expand Down
19 changes: 1 addition & 18 deletions impact/lib/bootstrap/demos/resident-raver/entities/player.js
Expand Up @@ -61,20 +61,6 @@ ig.module(
}
this.currentAnim.flip.x = this.flip;
},
update: function()
{

if(this.shotPressed)
{
if( this.fireDelay.delta() > this.fireRate ) {
this.fireWeapon();
this.fireDelay.reset();
}
}

this.parent();

},
draw: function()
{
this.parent();
Expand Down Expand Up @@ -109,14 +95,11 @@ ig.module(
},
shootPressed:function ()
{
//ig.game.shakeScreen();
//this.fireWeapon();
this.onFire();
this.fireWeapon();
},
shootReleased:function ()
{
this.fireWeaponRelease();
this.shotPressed = false;
},
addPowerUp: function(property, value, message)
{
Expand Down
4 changes: 2 additions & 2 deletions impact/lib/bootstrap/demos/resident-raver/levels/dorms.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -22,14 +22,17 @@ ig.module(
//this.parent();

var levelScoreID = this.currentLevelName+"Score";

console.log("levelScoreID", levelScoreID);

var hiScore = this.storage.getInt(levelScoreID) ? this.storage.getInt(levelScoreID) : 0;
if(this.stats.score > hiScore)
{
this.storage.set(levelScoreID, this.stats.score);
displayHiScore = true;
}

//console.log("hi-score", hiScore, this.stats.score, this.storage.getInt(levelScoreID));
console.log("hi-score", hiScore, this.stats.score, this.storage.getInt(levelScoreID));

// Save Stats
this.storage.set("totalScore", this.storage.getInt("totalScore") + this.stats.score);
Expand Down
8 changes: 4 additions & 4 deletions impact/lib/bootstrap/demos/resident-raver/plugins/stats.js
Expand Up @@ -7,7 +7,8 @@ ig.module(
'bootstrap.plugins.impact.menu',
'plugins.impact-storage.impact-storage',
'bootstrap.entities.base-monster',
'bootstrap.demos.resident-raver.entities.door'
'bootstrap.demos.resident-raver.entities.door',
'bootstrap.demos.resident-raver.entities.player'

)

Expand Down Expand Up @@ -47,7 +48,6 @@ ig.module(

//TODO calculate score
var stats = ig.game.stats;
console.log("Display stats", stats);
if(stats)
{
var i;
Expand Down Expand Up @@ -104,7 +104,7 @@ ig.module(
receiveDamage: function(value, from)
{
this.parent(value, from);
if(this.health <= 0)
if(this.health <= 0 && from instanceof EntityBaseWeapons)
{
ig.game.stats.kills ++;
console.log("Add to kills", ig.game.stats.kills)
Expand All @@ -119,7 +119,7 @@ ig.module(
close: function()
{
ig.game.stats.doors ++;
console.log("Add to doors", ig.game.stats.doors)
//console.log("Add to doors", ig.game.stats.doors)
this.parent();
}

Expand Down
7 changes: 6 additions & 1 deletion impact/lib/bootstrap/demos/resident-raver/resident-raver.js
Expand Up @@ -68,10 +68,11 @@ ig.module(
// Reset Default Values
this.defaultInstructions = "none";
this.showStats = true;
var defaultWeapon = 1;
var defaultWeapon = 0;

this.currentLevel = data;

//TODO I need to connect this up correctly
var cameraMinY = 0;//this.showStats ? -16 : 0;

this.parent(data);
Expand Down Expand Up @@ -113,6 +114,10 @@ ig.module(
this.player.equip(defaultWeapon, true);
}

// By default this is set to "none"
if(this.defaultInstructions != "none")
this.displayCaption(this.defaultInstructions, 7);

},
exitLevel: function (data) {
//Kills player and sets exitedLevel value to true
Expand Down
58 changes: 31 additions & 27 deletions impact/lib/bootstrap/entities/base-player.js
Expand Up @@ -32,42 +32,46 @@ ig.module(
// move left or right
if (this.visible)
{
//Reset acceleration X
this.accel.x = 0;
this.accel.y = 0;
this.onVisibleUpdate();
}

// Handle input
if (!this.states)
{
this.states = [
{state:"actions", method:"Down"},
{state:"presses", method:"Pressed"},
{state:"delayedKeyup", method:"Released"}
];
// move!
this.parent();
},
onVisibleUpdate: function()
{
//Reset acceleration X
this.accel.x = 0;
this.accel.y = 0;

this.totalStates = this.states.length;
}
// Handle input
if (!this.states)
{
this.states = [
{state:"actions", method:"Down"},
{state:"presses", method:"Pressed"},
{state:"delayedKeyup", method:"Released"}
];

// Loop through input states and call action handlers
for (var action in ig.input.actions)
this.totalStates = this.states.length;
}

// Loop through input states and call action handlers
for (var action in ig.input.actions)
{
for (var i = 0; i < this.totalStates; i++)
{
for (var i = 0; i < this.totalStates; i++)
{
var state = this.states[i].state;
var stateValue = ig.input[state][action];
var state = this.states[i].state;
var stateValue = ig.input[state][action];

if (stateValue)
{
this.onInputAction(action, this.states[i].method);
}
if (stateValue)
{
this.onInputAction(action, this.states[i].method);
}
}

this.currentAnim.flip.x = this.flip;
}

// move!
this.parent();
this.currentAnim.flip.x = this.flip;
},
updateAnimation:function ()
{
Expand Down

0 comments on commit 67c70f4

Please sign in to comment.