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

Username:   Password: 
 RegisterRegister   
 [help][blitz]collision detection-color?
Index -> Programming, Visual Basic and Other Basics -> Other Basics
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Pickles




PostPosted: Sat Jul 03, 2004 8:08 pm   Post subject: [help][blitz]collision detection-color?

Ok, im making space invaders, and ive got all the tank movement and shooting in now im working on the blocks.. so i have the picture of the barrier and i want a chunk of it to come out when the bullet hits. in turing id just use if whatdotcolor, is there a way to do something similar to that in blitz. in the help file it says that it GetColor or ReadPixel will find the color of that pixel, so how do i convert this into a statement that will allow me to exit a loop for instance.

I think what has me confused most of all is the RGB color make up with the 3 components, cause i never did that in turing i just did the pick a colour from 0-255 ..

Now, before you suggest ImageRectOverlap, ive tried that but the image is a bos, but the actual picture of what i want it to hit is an irregular shape, also i want to take chunks out of it and have it progress more and more as you shoot up the barrier, so that wouldnt work cause the image would still because as soon as it overlaps it exits so youll never get to get rid of the barrier.


(hope you understand what i mean)
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sun Jul 04, 2004 6:28 am   Post subject: (No subject)

if the bullet is a rectangle then you could use ImageRectCollide, or you could just use ImageCollide.
if this is in 2D i don't think that ReadPixel and ReadPixelFast will help you much.
Quote:
V1.52 and above: It has been necessary to make ReadPixel and ReadPixelFast "alpha-aware".

This means that the high 8 bits of the color returned ReadPixel/ReadPixelFast now contain valid alpha information.

However, in the case of Blitz2D apps, there is no alpha information in images!

Mark decided that in the abscence of any alpha information, a pixel is assumed to have 'full' alpha.

Therefore, values returned by ReadPixel/ReadPixelFast will now (usually) have their high 8 bits sets. The exception will be when reading pixels from Blitz3D textures created with an alpha channel.


Edit:
you could do it a roundabout way: use GetColor(x, y) to set the current drawing colour to that of 1 pixel ahead of the bullet. then use any of ColorRed, ColorGreen, or ColorBlue to determine the current red, green, or blue value of the drawing colour. then compare that value against the red, green, or blue value of the monster, respectively.
hope you understood that.
Pickles




PostPosted: Sun Jul 04, 2004 1:29 pm   Post subject: ..

I Think i figured out a way that makes it look more like the original, just involves more pictures.. is there a way to flip a picture, i saw theres rotate, doesnt seem to be a flip, it would save me making half the pictures, seeing as how its symmetrical i could just do half and flip..

oh what i wanted to do was break the picture into smaller picturesand then have if ImageRectOverlap then it frees that image, and replaces it with the same block only drawn to look like its deteriorated more, then if you hit the same block again, it looks more deteriorated and finally if you hit it a 3rd time it just dissapears
Cervantes




PostPosted: Sun Jul 04, 2004 3:37 pm   Post subject: (No subject)

hmm, I do not believe there is such a command for flipping a picture, though I do know it can be done with some yummy roundabout methods 8)

Pic found here
or you could just use one of your own pics.
code:

Graphics 640,480

gfx = LoadImage ("c:/My Documents/My Pictures/cervantes_banner.jpg")

gfx_width = ImageWidth(gfx)
gfx_height = ImageHeight(gfx)

DrawImage gfx, 1, 1


For x = 1 To gfx_width
        For y = 1 To gfx_height
                       
                WritePixel gfx_width - x, y + gfx_height, ReadPixel(x,y)
               
        Next
Next


then maybe you could GrabImage() to finally assign the flipped picture a handle.

hope you understand that
-Cervantes
Pickles




PostPosted: Sun Jul 04, 2004 5:24 pm   Post subject: ..

heh, thx.. easier just to flip and save in paint heh
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Other Basics
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: