• Advertisement

Archived

This topic is now archived and is closed to further replies.

[java] Draw method, how to draw map

This topic is 5190 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working on a tile-based game which has to draw a map. I know how to do this alright, but once i add animation, is there any way to not have to keep re-drawing the map each frame? I have an animated character that walks over the map, and thus at the moment I am updating the screen when he walks and I have to re-draw the map each time.. is there any way to not have to do this? Or is there any way to increase the speed, because draw the map is eating up a lot of CPU.

Share this post


Link to post
Share on other sites
Advertisement
I''d like a look at the code, but what I''d do would be to have a boolean global that determines if the map needs updated via some random method, then an ''if'' statment inside the paint() method.
But I''m fairly new to Java, so I don''t know how much that fixes the CPU problem.

Hope this helps,
~Justin

Share this post


Link to post
Share on other sites
You could just redraw the map characters the player over laps

That would save some time, of course for lots of players then you should also check if a square has already been redrawn and there is a point when you have X players and it''s quicker to do a full redraw of the map.

If you are scrolling the map then it is also easier to redraw the entire map as well and you can draw ontop of it as much as you like.

:-)

Share this post


Link to post
Share on other sites
well, i plan to be scrolling the map, and I also plan to have like 5 plus player as well, so I suppose I will just re-draw the map

Share this post


Link to post
Share on other sites
1. Keep track of where the map was obscured and only redraw that portion.

2. Also look at clipping in the Graphics class.

3. Even though you are using tiles, you could draw out the entire map ahead of time and then transfer the portion you need to the screen as needed. You can do this with drawImage of the Graphics class.



First make it work, then make it fast. --Brian Kernighan

The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte

Share this post


Link to post
Share on other sites
Investigate using VolatileImages to speed up the tile rendering as well. VolatileImages reside in graphics card RAM; they get blitted to your backbuffer very fast indeed. Assuming you''re using a BufferStrategy etc.

Cas

Share this post


Link to post
Share on other sites

  • Advertisement