Sign in with
Sign up | Sign in
Your question

Problems with Microworlds Code

Tags:
  • Microworlds
  • Code
  • Crash
  • Help
  • Collision
  • Cars
  • Glitch
  • Player
  • Games
  • Glitches
September 19, 2014 5:53:47 AM

Ok, so if you've used this program, you will know that it is about one of the most glitch programs out there, and just by saying that you can probably guess what my question is going to be related to...

I want my turtle to announce "You've crashed" and stop the game, when it comes within 10 blocks of another turtle. Here is the code I have:

to start.game
cc
instructions
reset.screen
animate.player
game.rule
start.cars
end

to stop.game
stopall
end

to reset.screen
player,
pu
seth 000
setpos [-12 -161]

car1,
pu
seth 90
setpos [-305 -42]

car2,
pu
seth 90
setpos [-19 -42]

car3,
pu
seth 90
setpos [235 -42]
end

to instructions
announce [Your objective is to get the bus to the yellow at the top as many times as you can while not hitting the side of the road or any vehicles. Use the arrow keys to move up and down.]
end

to animate.player
player,
forever [steer]
end

to steer
let [key readchar]
if (ascii :key) = 38 [seth 000]
if (ascii :key) = 40 [seth 180]
end

to game.rule
forever
[
player,
fd 2
wait 0.1
]

player,
if colorunder = 7
[announce [You crashed]
stopall
]
car1,
if (distance "player) < 10
[announce [You crashed]
stopall
]

car2,
if (distance "player) < 10
[announce [You crashed]
stopall
]

car3,
if (distance "player) < 10
[announce [You crashed]
stopall
]
end

to start.cars
forever [

car1,
fd 3
wait 0.1

car2,
fd 3
wait 0.1

car3,
fd 3
wait 0.1
]
end

All the turtles are numbered correctly, and the only thing that isn't working for me is the collision, where it registers that one turtle has hit the other. I have copied and pasted it into another project, and it still doesn't work. I have changed it from the cars hitting the player, to the player hitting the cars, and none of it works.

Thanks,
wertie8297

More about : problems microworlds code

!