The past few class periods we were taught to make a game where we use a rabbit to catch a moving carrot, and each time you touched the carrot you would gain 1 point.
Here is my coding!
score = 0;
onEnterFrame = function() {
carrot._x += 5;
if(carrot._x > 550) {
carrot._x = 0;
}
if(Key.isDown(Key.UP)) {
bunny._y -= 5;
}
if(Key.isDown(Key.DOWN)) {
bunny._y += 5;
}
if(Key.isDown(Key.RIGHT)) {
bunny._x += 5;
}
if(Key.isDown(Key.LEFT)) {
bunny._x -= 5;
}
if(bunny.hitTest(carrot)) {
carrot._x = 0;0
score = score + 1;
scoreDisplay.text = score;
}
}