# Help with adding points and \< \>

**URL:** <https://forum.code.org/t/help-with-adding-points-and/21238>\
**Category:** Unit and Lesson Discussion\
**Tags:** csd-unit-3, csd-unit-3-lesson-22\
**Created:** [October 23, 2018, 1:37pm UTC](https://forum.code.org/t/help-with-adding-points-and/21238 "2018-10-23T13:37:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarah.dudley](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@sarah.dudley](https://forum.code.org/u/sarah.dudley)\
**Post date:** [October 23, 2018, 1:37pm UTC](https://forum.code.org/t/help-with-adding-points-and/21238/1 "2018-10-23T13:37:03Z")

</div>

I have a student that is trying to add points when her bee flys through two rocks. She has an if statements set up and tried doing it with if fly.x=210 then score = score + 1. This would not work. We changed it to fly.x \> 210 then score = score + 1. This worked somewhat, but the score kept increasing. It is almost like we need to say something like fly.x \>209 but \< 211. Is there a way to do this?

Hope this makes sense.

Thank you!

---

<div class="post-metadata">

**Author:** ![edavis](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/edavis/32/4927_2.png) [@edavis](https://forum.code.org/u/edavis)\
**Post date:** [October 24, 2018, 11:13pm UTC](https://forum.code.org/t/help-with-adding-points-and/21238/2 "2018-10-24T23:13:57Z")

</div>

Could you post the code so we can look at it?

---

<div class="post-metadata">

**Author:** ![sarah.dudley](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@sarah.dudley](https://forum.code.org/u/sarah.dudley)\
**Post date:** [October 24, 2018, 11:33pm UTC](https://forum.code.org/t/help-with-adding-points-and/21238/3 "2018-10-24T23:33:57Z")

</div>

Here is a copy of the code. Looks like she tried adding somethings today, while she was home as well.

// Variables  
var score = 0;  
var mtn = createSprite(200, 200);  
mtn.setAnimation(“mtn”);  
mtn.scale = 2;

// Create your sprites here  
var fly = createSprite(20, 140);  
fly.setAnimation(“fly1”);  
fly.scale = .5;  
var rock1 = createSprite(200, 20);  
rock1.setAnimation(“rock1”);  
rock1.scale = .9;  
var rock = createSprite(200, 299);  
rock.setAnimation(“rock”);  
rock.scale = .9;  
rock1.setAnimation(“rock1”);  
rock1.scale = .9;  
var rock = createSprite(190, 375);  
rock.setAnimation(“rock”);  
rock.scale = .9;  
var rock1 = createSprite(245, 45);  
rock1.setAnimation(“rock1”);  
rock1.scale = .9;  
var rock = createSprite(190, 390);  
rock.setAnimation(“rock”);  
rock.scale = .9;  
var rock1 = createSprite(282, 55);  
rock1.setAnimation(“rock1”);  
rock1.scale = .9;  
var rock = createSprite(270, 360);  
rock.setAnimation(“rock”);  
rock.scale = .9;  
var rock1 = createSprite(112, 39);  
rock1.setAnimation(“rock1”);  
rock1.scale = .9;  
var rock = createSprite(95, 299);  
rock.setAnimation(“rock”);  
rock.scale = .9;  
var rock1 = createSprite(360, 85);  
rock1.setAnimation(“rock1”);  
rock1.scale = .9;  
var rock = createSprite(3, 300);  
rock.setAnimation(“rock”);  
rock.scale = .9;  
var rock = createSprite(370, 370);  
rock.setAnimation(“rock”);  
rock.scale = .9;  
drawSprites();  
function draw() {  
showScore();  
myFunction();  
movePlayer();  
// draw background  
addPoints();  
points();  
isToching();  
//createSprites

}

// Create your functions here  
function isToching() {  
if (fly.isTouching(rock)) {  
fly = fly.collide(rock);  
}  
if (fly.isTouching(rock1)) {  
fly = fly.collide(rock1);  
}  
}  
function points() {  
if (rock.isTouching(fly)) {  
score = score - 1;  
}  
if (rock1.isTouching(fly)) {  
score = score - 1;  
}  
}  
function myFunction() {  
if (score == 30) {  
var golden = createSprite(200, 200);  
golden.setAnimation(“golden”);  
golden.scale = 2;  
}  
}  
function addPoints() {  
if (fly != 370) {  
fly = score + 30;  
}  
}  
function showScore() {  
fill(“white”);  
textSize(20);  
text(“Score”,20,20,200,100);  
text(score,20,40,200,100);  
}  
function movePlayer(){  
if (keyDown(“right”)) {  
fly.x = fly.x + 3;  
}  
if (keyDown(“left”)) {  
fly.x = fly.x - 3;  
}  
if (keyDown(“up”)) {  
fly.y = fly.y + -3;  
}  
if (keyDown(“down”)) {  
fly.y = fly.y + 3;  
}

---

<div class="post-metadata">

**Author:** ![bradleywellsashley](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/bradleywellsashley/32/522_2.png) [@bradleywellsashley](https://forum.code.org/u/bradleywellsashley)\
**Post date:** [October 28, 2018, 3:15pm UTC](https://forum.code.org/t/help-with-adding-points-and/21238/4 "2018-10-28T15:15:59Z")

</div>

Sarah,

Sorry to ask more of you, but could you click on the “share” button and share the code that way? I tried copying it into an empty GameLab and the student uses so many animations that its giving me a lot of warnings/errors, once I worked through adding the animations I’m getting this error `Error: overlap can only be checked between sprites or groups` but my code still doesn’t work. Does the game work just with the exception of the points?

Looking forward to figuring this out!  
Brad
