whatdotcolour
Author |
Message |
Mr. T
|
Posted: Sat May 28, 2005 8:18 pm Post subject: whatdotcolour |
|
|
in my program i have a process (yes, yes the evilness, shhhh). within the process, i have an "exit point" that opens up. this exit point is a white block, that if touched, will bring you to the next level. right after the fork, i have a whatdotcolour hit detection to check if the snake's head has touched the white exit point. for some reason the detection does not work code: |
fork mainLevelUp %exit point process (processes are evil >:@)
if whatdotcolour (snake (1).x, snake (1).y) = white %if the snake reaches the exit
then
scoreLevelUp %score chart procedure
end if
|
am i doing something wrong in my collision detection or is it the process's fault |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Delos
|
Posted: Sat May 28, 2005 8:22 pm Post subject: (No subject) |
|
|
Well....
If you whatdotcolour(snake.x, snake.y), all that you'll ever return is the colour of the snake's head! You need to whatdotcolour a point outside of the breeches of the snake, or at least make a transparent whole inside the snake's head to whatdotcolour() through!
Curious, why do you need a process for collision detection? Couldn't you just use a procedure that's called once a loop? |
|
|
|
|
|
Mr. T
|
Posted: Sat May 28, 2005 8:32 pm Post subject: (No subject) |
|
|
Delos wrote: Well....
If you whatdotcolour(snake.x, snake.y), all that you'll ever return is the colour of the snake's head!
1. what do u mean? if (snake (1).x,snake (1).y)=white doesnt that mean ur checking to see if the snakes head is within a white colour?!?!
2. the collision detection isnt in the process...its just there to create the exit point in a specific condition |
|
|
|
|
|
Delos
|
Posted: Sat May 28, 2005 8:38 pm Post subject: (No subject) |
|
|
@1)
Yes, that's what it means...but keep in mind that if you've drawn your white dot first, and then your snake head over that, it will return the colour of that pixel. If, however, your snake is drawn under the dot, then you should be good to go and should just check your process priorities. |
|
|
|
|
|
Mr. T
|
Posted: Sat May 28, 2005 8:40 pm Post subject: Alex's Opinion |
|
|
its not a white dot, its a white box |
|
|
|
|
|
Mr. T
|
Posted: Sat May 28, 2005 8:54 pm Post subject: Alex's Opinion |
|
|
BAH, i still cant figure out whats wrong...here lemme give a little more code, to aid you in assisting me.
code: |
%%%%%%%%%%
process mainLevelUp
drawfillbox ((maxx div 2) - 27, maxy, (maxx div 2) + 20, maxy - 25, 0)
Font.Draw ("EXIT", (maxx div 2) - 25, maxy - 20, fontExit, col1) %level's exit point
col1 += 1
if col1 = 40
then
col1 := 0
end if
end mainLevelUp
%%%%%%%%%%
procedure scoreLevelUp
cls %clears the screen for the scoring updates
%%%%%%%%%%%%%%%%%%%%%%%%
%scoring system (after each completed level)
Window.Select (scorewin)
put "Your score is: ", score
%theres more code in this procedure but i didnt add it all
scoreLevelUp
%%%%%%%%%%%%
if score <scoreLevel then
Draw.FillOval (food1, food2, foodSize, foodSize, green)
else %stop the food from drawing
fork mainLevelUp %exit point process (processes are evil >:@)
if whatdotcolour (snake (1).x, snake (1).y) = white %if the snake reaches the exit
then
scoreLevelUp %score chart procedure
end if
%%%%%%%%%%%%% |
i cant ever get to the scoreLevelUp procedure because the collision detection after the mainLevelUp process doesnt work. |
|
|
|
|
|
Delos
|
Posted: Sat May 28, 2005 9:05 pm Post subject: (No subject) |
|
|
Until I see the snake of which you speak, I can only offer this as a suggestion...
Let # be space, 0 be snake head, - be snake body, + be white box:
code: |
##########
#####+++##
##----0+##
#####+++##
##########
##########
|
Now say you whatdotcolour in the area represented by (3,7) (the '0'). This will return the colour of the 0. Unless you have the white stuff drawn over the 0, you'll only have the colour of the 0 returned.
If it looked like this, you'd get the colour of the white box returned:
code: |
##########
#####+++##
##---+++##
#####+++##
##########
##########
|
I can suggest, however, that you display the whatdotcolour of your inconvenience [sic.] in a little box somewhere so that you can monitor its possible changes.
Have fun. |
|
|
|
|
|
Mr. T
|
Posted: Sat May 28, 2005 9:13 pm Post subject: (No subject) |
|
|
thnx for the assistance. i guess the fork was preventing the snakes head from detecting the white exit point (evil ) |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Cervantes
|
Posted: Sat May 28, 2005 9:16 pm Post subject: (No subject) |
|
|
I've said it before and I'll say it again: you shouldn't be using processes. They are only making your coding more difficult.
Also, you shouldn't be using whatdotcolour collision. This is snake, it works on a grid system, which means you don't have to worry about comparing ranges of pixels. You just have to compare x-y ordered pair to another. It couldn't be easier. |
|
|
|
|
|
|
|