How did you express your walls programmatically?  Did you use tiles or
did you draw lines?

If you used tiles, the collision detection is very easy.  If the next
move will cause the player to enter the tile, game over.

If you drew the walls on a full coordinate system, you have to keep
the coordinates that you used in an array or list or wherever and
write a little algorithm that checks to see if the position of the
player on the next tick will intersect with a wall.

I used the second method for my game and it works very well.

I just wrote all this then reread and saw that you used a png
background.  Here's what you can do to use that:

Create a second background that is only black and white and masks the
png background you have.  Load both but of course only draw your
normal one.  Load the mask into a bitmap and for collision detection,
just call bitmap.getPixel() for the next position of your player.  If
it's the wall color (let's say you use white for walls), there is a
collision.

On Oct 19, 5:51 am, mscwd01 <[EMAIL PROTECTED]> wrote:
> I am fairly new to android, although I have been using Java for a
> while.
>
> I am creating a 2d maze based game which consists of a bunch of walls
> and a rotating player piece (which rotates 360 degrees), while trying
> to get from the entrance to the exit of the maze - without touching
> the walls.
>
> My question is, what is the best way to represent the walls of the
> maze and the playing piece (which rotates, hence doesn't always occupy
> the same location on screen) so that I can effectively check for
> collisions between the two entities?
>
> The level itself will be quite small so the maze will be a png
> background image which moves when the player moves up, down, left or
> right (the playing piece will remain at the center of the screen). I
> was thinking of drawing a polygon object over the walls of the png
> image and try to detect collisions between the rectangle playing piece
> and the polygon shape - is this possible?
>
> There may be a better way, if there is please let me know!
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to