Thanks for your reply,

So just to recap...
I draw the main maze png background image and then have another image
I draw on top of this which is fully transparent apart from lines of
non transparent pixels which represent the maze walls. That sounds
nice and easy.

To make this work I'd need to find out the center point (coordinates)
of the screen, determine which coordinates the playing piece current
fills (i.e. y,x,y+10,x+10) and then check to see whether any of these
pixels are also occupied by the mask "walls" layer.

Could you let me know the best way to implement multiples layers, i.e.
the maze background image, the mask walls image and the playing piece.

Also could you let me know how you retrieve a section of pixels from
an image, so I can determine whether the mask layer for example has
walls in a section occupied by the playing piece.

Many thanks!



On Oct 19, 10:38 pm, Robert Green <[EMAIL PROTECTED]> wrote:
> 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- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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