# Help urgently needed to correct the loss of points

**URL:** <https://forum.kirupa.com/t/help-urgently-needed-to-correct-the-loss-of-points/302625>\
**Category:** flash\
**Created:** [January 4, 2010, 3:34pm UTC](https://forum.kirupa.com/t/help-urgently-needed-to-correct-the-loss-of-points/302625 "2010-01-04T15:34:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mushi206](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@mushi206](https://forum.kirupa.com/u/mushi206)\
**Post date:** [January 4, 2010, 3:34pm UTC](https://forum.kirupa.com/t/help-urgently-needed-to-correct-the-loss-of-points/302625/1 "2010-01-04T15:34:13Z")

</div>

Have most of the game working correctly

Only problem is when person\_mc interacts with items\_mc and items\_mc2 instead of 1 point being lost the points keep being lost which makes the game to hard

Have included the coding to help

Thanks

//The code below is to set the score to 0 to begin with  
var scoreCount:Number = 0;  
score.text = scoreCount;  
//code to allow person\_mc to move randomely  
function getdistance(x, y, x1, y1) {  
var run, rise;  
run = x1-x;  
rise = y1-y;  
return (\_root.hyp(run, rise));  
}  
function hyp(a, b) {  
return (Math.sqrt(a_a+b_b));  
}  
MovieClip.prototype.reset = function() {  
//Width and height of the movie  
width = 500;  
height = 350;  
//distance and speed  
var dist, norm;  
this.x = this.\_x;  
this.y = this.\_y;  
this.speed = Math.random()\*4+2;  
this.targx = Math.random()\*width;  
this.targy = Math.random()\*height;  
dist = \_root.getdistance(this.x, this.y, this.targx, this.targy);  
norm = this.speed/dist;  
this.diffx = (this.targx-this.x)\*norm;  
this.diffy = (this.targy-this.y)\*norm;  
};  
//moves movie clip  
MovieClip.prototype.move = function() {  
if (\_root.getdistance(this.x, this.y, this.targx, this.targy)\>this.speed) {  
this.x += this.diffx;  
this.y += this.diffy;  
} else {  
this.x = this.targx;  
this.y = this.targy;  
if (!this.t) {  
this.t = getTimer();  
}  
if (getTimer()-this.t\>1000) {  
this.reset();  
this.t = 0;  
}  
}  
this.\_x = this.x;  
this.\_y = this.y;  
};  
//This code is to allow the items\_mc and items\_mc2 to appear randomely  
randomX = Math.floor(Math.random() \* 500)  
randomY = Math.floor(Math.random() \* 350)  
items\_mc.\_x = randomX;  
items\_mc.\_y = randomY;  
randomX = Math.floor(Math.random() \* 550)  
randomY = Math.floor(Math.random() \* 400)  
items\_mc2.\_x = randomX;  
items\_mc2.\_y = randomY;

//The code below is for moving the grinder using the arrow keys  
var KeyListener:Object = new Object();  
KeyListener.onKeyDown = function():Void {  
//Allows grinder to move left  
if (Key.isDown(Key.LEFT)) {  
if (grinder\_mc.\_x\>29) {  
grinder\_mc.\_x -= 5;  
}  
}  
//Allows grinder to move right  
if (Key.isDown(Key.RIGHT)) {  
if (grinder\_mc.\_x\<499) {  
grinder\_mc.\_x += 5;  
}  
}  
//Allows grinder to move up  
if (Key.isDown(Key.UP)) {  
if (grinder\_mc.\_y\>-58.2) {  
grinder\_mc.\_y -= 5;  
}  
}  
//Allows grinder to move down  
if (Key.isDown(Key.DOWN)) {  
if (grinder\_mc.\_y\<490) {  
grinder\_mc.\_y += 5;  
}  
}

//This causes the spacebar button to remove items\_mc on press  
if (Key.isDown(Key.SPACE)) {  
hitRemove(grinder\_mc,items\_mc);  
hitRemove(grinder\_mc,items\_mc2);  
}  
};  
Key.addListener(KeyListener);  
//This function detects whether the objects have collided.  
function hitRemove(moveObject:MovieClip, hitObject:MovieClip) {  
if (moveObject.hitTest(hitObject)) {

```
    //displayscore +

```

if(hitObject.\_visible == true) {  
scoreCount++;  
score.text = scoreCount;  
}

hitObject.\_visible = false;  
}  
}  
//displayscore -  
if(hitObject.\_visible == true) {  
scoreCount–;  
score.text = scoreCount;  
}  
onEnterFrame = function () {

if(person\_mc.hitTest(items\_mc)) {

scoreCount–;  
score.text = scoreCount;

}

/\*  
if(items\_mc2.hitTest(person\_mc)) {

items\_mc2.visible = false;

}

\*/  
}
