How to use whatdotcolor in my program? and should i?
Author |
Message |
vagyb
|
Posted: Mon May 24, 2004 6:54 pm Post subject: How to use whatdotcolor in my program? and should i? |
|
|
um.. here is my program and i was wondering i should use whatdotcolor for colision detection, and if yes, how exactly :S cuz i real the tutorial and can't imagine how i would use it here
[/code]
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
LiquidDragon
|
Posted: Mon May 24, 2004 7:03 pm Post subject: (No subject) |
|
|
Yes you could use whatdotcolor
You just need to have the whatdotcolor at the front of the ship. If it doesn't equal black than it crashes.
if whatdotcolor (shipX + 2, shipY div 2) not= 7 then
%CRASH
end if
Just make something like that. I think that should work
|
|
|
|
|
|
guruguru
|
Posted: Mon May 24, 2004 7:04 pm Post subject: (No subject) |
|
|
code: |
if whatdotcolor (x value just before front of ship, y value of ship) == black then
change position of all asteroids
else
exit
end if
|
THat's a quick way. Make your code better... its really messy... look at my post in your old topic.
|
|
|
|
|
|
vagyb
|
Posted: Mon May 24, 2004 7:42 pm Post subject: (No subject) |
|
|
ah damnit it doesn't work :S. so far i just painted the front of the ship red so its easier, and the front of the rocks yellow. and this is the code i used
code: |
if whatdotcolor (boulder1X, boulder1Y) = red then
elsif whatdotcolor (boulder1X, boulder1Y) = red then
elsif whatdotcolor (boulder2X, boulder2Y) = red then
elsif whatdotcolor (boulder3X, boulder3Y) = red then
elsif whatdotcolor (boulder4X, boulder4Y) = red then
cls
locate (20, 10)
color (white)
put "crash"
end if
|
and so far its not working :S could someone tell me how i can change it plz.
|
|
|
|
|
|
guruguru
|
Posted: Mon May 24, 2004 8:07 pm Post subject: (No subject) |
|
|
code: |
if whatdotcolor (boulder1X, boulder1Y) = red or whatdotcolor (boulder1X - 1, boulder1Y) = red or whatdotcolor (boulder2X - 1, boulder2Y) = red or whatdotcolor (boulder3X - 1, boulder3Y) = red or whatdotcolor (boulder4X - 1, boulder4Y) = red then
cls
locate (20, 10)
color (white)
put "crash"
end if
|
Make it into one big if statement because the screen would only clear when the fourth boulder was colliding. And you want the pixel just in front of the boulder. Otherwise, you would always be testing to see if the color of the actual boulder = red, which it never theoretically should be.
|
|
|
|
|
|
vagyb
|
Posted: Mon May 24, 2004 8:14 pm Post subject: (No subject) |
|
|
i did that but it doesn't work :S, all i did was paint the front of the ship red is that rite? but it doesn't stop...
i think the problem is that i added the red color in paint in front of the ship but the color red in paint doesn't match up wit the color of red in the turing code. or i am wrong.
Description: |
|
Download |
Filename: |
abc.zip |
Filesize: |
35.64 KB |
Downloaded: |
224 Time(s) |
|
|
|
|
|
|
|
|