Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Program is detecting green where there shouldn't be any
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
undergroundmonorail




PostPosted: 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)



doublejump.bmp
 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



game 2.t
 Description:
will probably crash if you don't have a file called "doublejump.bmp" in the folder with it

Download
 Filename:  game 2.t
 Filesize:  3.68 KB
 Downloaded:  48 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: