Unfortunately I need more help again. I´m trying to do a pixel perfect collision function but I can´t get passed a simple maths problem. I need to figure out the x and y position of a pixel of a sprite. I have the x position and y position of the sprite and I know it´s width and height. I have the image that the sprite uses stored in a memblock. I now need to think up some maths that gives me the pixel´s position given the height, width and size of the sprite. I use a for next loop like this to check the sprites colour and get the pixel´s x and y values:
xsize1=sprite width(sprite1) : ysize1=sprite height(sprite1)
xsize1*ysize1=size1 : xsize2*ysize2=size2
memsize=(size1*4)+12
for imageloop=12 to memsize step 4
if memblock byte(1,imageloop)=255
pixelposx=
pixelposy=
endif
next imageloop
Basically if imageloop=12 then the pixel´s position is the same as the sprites position. If imageloop=16 (step 4) then the pixels x position is one greater than the sprite and it´s y value stays the same and so on and so fourth. How do I tell the computer the rules? Any ideas? If you want me to explain anything more clearly don´t hesitate to say so.
You help is appreciated
P.S: Thank you Freddix for your pixel perfect collision function which I´m basing mine on.
Jam on mother f**ker.
Libera tu mente y te liberaras.