help with walking restrictions
Author |
Message |
shoobyman
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Fri Oct 13, 2006 5:37 pm Post subject: (No subject) |
|
|
without looking at all of that code, the most common problem is that your object moves further then where the check happens. For example, if you check for the colour one step ahead, but your unit is moving fast and travels 2 steps at a time, there's a chance to _jump_ over the barrier and get stuck
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
neufelni
|
Posted: Fri Oct 13, 2006 5:40 pm Post subject: (No subject) |
|
|
The program is doing exactly what you programmed it to do, to get stuck when it gets into black. You need to make it so that your character can go rigth up to the black, but not actually go into the black. You do this by simply adding a bit to your whatdotcolors.
code: | if key (KEY_LEFT_ARROW) and x > 10 and whatdotcolor (x - 5, y) = yellow then
x -= 1
elsif key (KEY_RIGHT_ARROW) and x > 10 and whatdotcolor (x + 5, y) = yellow then
x += 1
elsif key (KEY_DOWN_ARROW) and x > 10 and whatdotcolor (x, y - 5) = yellow then
y -= 1
elsif key (KEY_UP_ARROW) and x > 10 and whatdotcolor (x, y + 5) = yellow then
y += 1
end if |
|
|
|
|
|
|
|
|