I have a simple game in scratch due tomorrow for class. I'm trying to have an ant make his way through a maze but I'm stuck with the sensing.
i have When [arrow key] pressed > If not touching colour black (the colour of the maze walls) > point in direction > move ten steps.
[blocks]<when[ ]key pressed> <if><< <not> >><touching color[ <point in direction( <move( )steps>
When i run into the walls of the maze i stop, but then I can't keep going.
is there a better way to make it so that my ant cant hit the walls but still keep going?
help asap would be great!
thanks
Offline
have you seen the little pac man example project that comes with the scratch program? thats a kind of similar to what you're trying to do, i believe
but the way i'd do it is probably just make it if the ant is touching black, have it move -2 or so steps so it goes backwards
and then with the movement
uh
wait
okay so with the normal movement you could just do when up arrow pressed point in direction 0 move 2 steps and the same thing with left and right and down but with different directions and yeah
i think you'll have to use the way where you make a new script for every direction though because the way when it's all in one script doesn't seem to work well for me but i might have just done something wrong
Last edited by rufflebee (2011-02-07 21:27:32)
Offline
okay.
I'm also having trouble with my scoring.
I want to start with a certain number and then go down if the ant hits enemys. How can i make it so that when the score = 0 the game ends and a different background shows
Offline
okay i'm assuming the enemies are the same color
if they're not, then you might want to consider it for sensing purposes
so when the ant is touching the color of the enemy guys you make it so the score goes down by one, then you might want to make it wait a second or something because otherwise you'll lose the game pretty quick
and for the background, you make a script for the stage thats like forever if score=0 switch to backgroundwhatever
but backgroundwhatever is going to be the name of whatever your ending screen is
and you'll have to make a script for the ant so when score=0 it hides
and don't forget to set the stage to the maze background when the green flag's clicked, and to set the score to whatever it's supposed to start as, and to make the ant sprite show when the green flag is clicked too
i would just show you pictures of the exact scripts but you're doing this for a class :p
Offline