PDA

View Full Version : Problem with scoring system


everlong
04-27-2005, 05:38 PM
I have a street fighter style game in the works for a school project. My scoring system for it seems to be messing up for some reason. After one punch, which is supposed to add one point to the score, the game jumps to the winners screen. The winning score is supposed to be 20 points. Any help would be greatly appreciated. Here is the code.


Stop();
var Score1 = Number(0);
var Score2 = Number(0);
var Convert1 = String(Score1);
var Convert2 = String(Score2);
var winningScore = Number(20);


_root.jacobs_mc.onEnterFrame = function() {
if (key.isDown(65)) {
_root.jacobs_mc._x = jacobs_mc._x - 10;
_root.jacobs_mc.gotoAndPlay(2);
}
if (key.isDown(68)) {
_root.jacobs_mc._x = jacobs_mc._x + 10;
_root.jacobs_mc.gotoAndPlay(2);
}
if (key.isDown(83)) {
_root.jacobs_mc.gotoAndPlay(3);
if(_root.jacobs_mc.hitTest(_root.plourde_mc))
{
_root.Score2 = _root.Score2 + 1;
_root.Convert2 = _root.Score2;

if (_root.Score1 = _root.winningScore) {
_root.gotoAndPlay(3);
}
updateAfterEvent;
}
}
}


_root.plourde_mc.onEnterFrame = function () {
if(key.isDown(76)) {
_root.plourde_mc.gotoAndPlay(2);
_root.plourde_mc._x = plourde_mc._x + 10;
}
if(key.isDown(74)) {
_root.plourde_mc.gotoAndPlay(2);
_root.plourde_mc._x = plourde_mc._x - 10;

}
if(key.isDown(75)) {
_root.plourde_mc.gotoAndPlay(3);
if(_root.plourde_mc.hitTest(_root.jacobs_mc))
{
_root.Score1 = _root.Score1 + 1;
_root.Convert1 = _root.Score1;

if (_root.Score2 = _root.winningScore) {
_root.gotoAndPlay(4);
updateAfterEvent;
}
}
}
}

Barn
04-27-2005, 05:47 PM
Not quite sure why you are converting numbers to numbers--seems unncessary to me, but the crux of your problem is the conditional:

if (_root.Score1 = _root.winningScore) {
That conditional is assigning the winning score value to the score1 variable; it is NOT doing a comparison.

The equality comparison operator is ==, not =.

everlong
04-28-2005, 04:50 PM
Thanks for the reply. This helped slightly but now the game will not finish when the winning score is reached.

everlong
04-28-2005, 05:12 PM
Nevermind. Thanks though. I fixed the last problem with the scoring system. When i removed the winning score calculation from the nested if statements it seemed to work fine. Thanks. now onto my lag problems...gah

Barn
04-28-2005, 05:37 PM
You're welcome.

Lag problems should probably be a different thread.