Program is detecting green where there shouldn't be any
Author |
Message |
undergroundmonorail
|
Posted: Sat May 19, 2012 7:30 pm Post subject: Program is detecting green where there shouldn't be any |
|
|
I'm a moron who forgot to change his "exit when" condition when he copypasted code.
What is it you are trying to achieve?
A simple platformer game.
What is the problem you are having?
Whenever I jump or go up a slope, the part of my (simple, colour-based) collision detection that detects if the player is inside a wall above them goes into an infinite loop.
Describe what you have tried to solve this problem
I tried changing exactly where it looks for the colour, but it didn't seem to change anything. I also told it to draw a white dot wherever it's finding green (which should have let it continue after one loop) but it still breaks.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Here's the part of it that goes into an infinite loop, but I'll attach the full code as well because I'm not sure what would be relevant.
Turing: |
loop % if the player is in a wall on their left and right at the top, move them down
for i : - 20 .. 20
if whatdotcolor (playerx - i, playery + 41) = green and whatdotcolor (playerx + i, playery + 41) = green then
yvelocity - = 5
playery - = 1
end if
end for
exit when whatdotcolor (playerx - 21, playery ) not= green and whatdotcolor (playerx + 21, playery ) not= green
end loop
|
Please specify what version of Turing you are using
OpenTuring 1.0.1 (based on Turing 4.1)
Description: |
keep this in the folder with the program. doesn't actually do anything yet |
|
Filesize: |
6.03 KB |
Viewed: |
720 Time(s) |
![doublejump.bmp doublejump.bmp](uploads/attachments/doublejump_151.bmp)
|
Description: |
will probably crash if you don't have a file called "doublejump.bmp" in the folder with it |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
game 2.t |
Filesize: |
3.68 KB |
Downloaded: |
48 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|
|