
-----------------------------------
Mr. T
Sat May 28, 2005 8:18 pm

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 
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  :cry:

-----------------------------------
Delos
Sat May 28, 2005 8:22 pm


-----------------------------------
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
Sat May 28, 2005 8:32 pm


-----------------------------------
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
Sat May 28, 2005 8:38 pm


-----------------------------------
@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
Sat May 28, 2005 8:40 pm

Alex's Opinion
-----------------------------------
its not a white dot, its a white box  :?

-----------------------------------
Mr. T
Sat May 28, 2005 8:54 pm

Alex's Opinion
-----------------------------------
BAH, i still cant figure out whats wrong...here lemme give a little more code, to aid you in assisting me.

%%%%%%%%%%
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 :@)
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
Sat May 28, 2005 9:05 pm


-----------------------------------
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:


##########
#####+++##
##----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:



##########
#####+++##
##---+++##
#####+++##
##########
##########


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
Sat May 28, 2005 9:13 pm


-----------------------------------
thnx for the assistance. i guess the fork was preventing the snakes head from detecting the white exit point (evil   :evil:  )

-----------------------------------
Cervantes
Sat May 28, 2005 9:16 pm


-----------------------------------
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.
