Thanks for the update...

I believe I am using a SurfaceView, I edited the LunarLander game
which has things like SurfaceHolders I am making use of. I use a
simple Canvas and draw onto it in much the same way you described,
i.e. base images first then draw another image on top. I was just
wondering whether Android had a layer manager much like J2ME does in
the GameCanvas class.

Anyway thanks for your help, I believe I can implement the game now.

Oh, one last question - why does my game run faster when the emulator
is in a portrait orientation? When I switch to landscape the game
slows by at least 20 FPS. Is this normal?

Thanks

On Oct 20, 3:55 pm, Robert Green <[EMAIL PROTECTED]> wrote:
> Something like that.  Play around with it and I'm sure you'll find a
> way to make it work.
>
> Here's how I do mine:
>
> When initializing the game/map, I load the map resource and draw it
> onto a bitmap.
>
> My Main Loop:
>
> update()
> draw()
>
> My update method does:
>
> updatePhysics (moves players, checks collisions)
> updateAI (figures out next move for AI players)
> updateState (for state transitions)
> updateAnimations
> updateSound
>
> My draw method does:
>
> draws background/map bitmap to surface canvas
> draws objects or anything under the players to canvas
> draws players to surface canvas
> draws FX, explosions, etc over players to surface canvas
> draws scores, text or anything on the very top to surface canvas
>
> I've been very careful to write efficient math for physics, AI and
> collisions.  I also was careful so as to draw the absolute minimum as
> 2d drawing is a little expensive in android.  Overall I get a
> framerate around 40-45 FPS on my emulator.
>
> Also - if you're not already, use a SurfaceView.
>
> On Oct 19, 6:37 pm, mscwd01 <[EMAIL PROTECTED]> wrote:
>
> > 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