Okay so I am implementing physics into my game, Picraft 2 and need help on testing sprite collision. It is not in tilemap and uses Pt-off(_,_,pic_ to display sprites. I need to make it so that when the player places a block he can't walk/fall through it. I do not need anything complex just a simple way to test collision. Here are to methods that I would like to use:
One that detects a whole sprite and keeps the player from entering the 8*8 radius of the sprite, even if the pixels are white(remember these will be placed by the player, not be there to begin with) Also my method of destroying a block is by placing a blank sprite over it, and I want to make it so the player can walk through the 8*8 blank square, aka the destroyed block, which is why method one would not work.
Method two however would detect if two black pixels touched each other and would then return the player to the position that he was in exactly before he tried to go through a sprite that had black pixels boardering it. In other words I want to make it so that the player can only pass through white pixels not black if you know what I mean. Like I said this would be the PREFERED way, but if you know another way that would be simpler that would most likely be better, as I do not want a very confusing code to deal with. Can someone show me a code and explain it to me? Here is a sample of my method of outputting sprites in case you need it:
:[]->pic1A
:.you insert the sprite data in the brackets
:If getKey(34)
:Pt-off(W,H,Pic1A
:End
That is a basic idea of what the code looks like(W H are variables for XY that place a block at the current location of the cursor)(getKey(34) is just an example I use multiple keys for placing blocks)
Remember I want a SIMPLE, easy to understand code for detecting black pixels colliding with other black pixels if possible, that can detect user placed and user destroyed blocks. If you know a solution please tell me, I would be very grateful.