-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|686|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Blogs Home -> Blogs


 
Jayenkai
Created : 17 March 2008
 

Tilemaps again!?!

Come off it!!!

Is it really that hard to draw a tilemap?
I mean, really?

Am I overdoing things?

Why is it, lately, that all my projects seem to be hitting major roadblocks..
..
And the roadblocks are always tilemap related!!


Today's Failed attempt in Java

Today I tried to create a nice playfield.
I figured a 50x50 grid, of 16x16 pixel blocks would be a decent play area, whilst keeping things down enough that the system could handle it.

..

The system couldn't handle it.
Java peeps bothered to give me a nice handy "TiledLayer" thing, but it still goes painfully slow, reducing my framerate to about 2fps..
It works fine if I make it 10x10.
But.. What type of rubbish games do you do in 10x10?
...
...

Phone games..

Bloody phone games....

 

Comments


Monday, 17 March 2008, 18:56
spinal
are you drawing ALL of the blocks, or just the visible ones?
Tuesday, 18 March 2008, 00:20
JL235
I'd expect Java to skip commands which are drawing off-screen.

Jayenkai But.. What type of rubbish games do you do in 10x10?
Minesweeper?
Tuesday, 18 March 2008, 03:13
Jayenkai
I would assume (rolleyes) that Java would only draw the tiles onscreen.
I could easily just draw the tiles myself, I just figured an internal function would probably have some kind of magical speed-ups involved.
Unfortunately, it doesn't.

In much the same way as my initial "add more sprites, see when it slows down" tests, I've found that once you hit 150 tiles onscreen.. It's gonna go slow..

Which is dumb, and mostly defeats the point in even having the function there at all.

Alternative options..

Drawing bigger tiles. 32x32 tiles is a lot slower than 16x16, but... Maybe it's enough to keep the screen full..?

Drawing to a big image, then drawing image. Would require me to test big-big-image drawing on different phones.. Not so sure how well that'd work, but it might be the best option so far.

I'll let you guys know!
Tuesday, 18 March 2008, 09:59
Jayenkai
The "Draw to an image, scroll the image" method seems to be quite successful, but I'm not going to get anywhere near the size originally planned.

With smaller sprites I can achieve a decent map size.. roughly 8x8 sprites, 75x75 map, 20fps.. but I'll have to do further tests.

Still not sure what type of game I can do, though, since the slow framerate's still going to be a problem.

Back to the drawing board, methinks..
Tuesday, 18 March 2008, 11:10
Paul
Does Java have a built in graphics library?

Anyway, there must be alternatives, there must be something that can draw more than 150 tiles!?
Tuesday, 18 March 2008, 12:24
blanko1324
Tile maps, in general, have got to be the biggest pain the ass...
Tuesday, 18 March 2008, 14:01
JL235
Paul Does Java have a built in graphics library?

Yes, in Java SE (the standard desktop version) it's the Java 2D framework which is in the Java API and on Java ME (micro edition) I believe it's Java FX.
Wednesday, 19 March 2008, 10:16
Jayenkai
Ok, we seem to be getting there.. Bit by bit.
Using the "draw tiles to a big image, draw the big image to the screen" method, and having to fiddle about with a few extra little core rules for the game, I've got things looking a little more..


Blocky!

Sure, my Platdude "Random sprites to test the framerate" thing's still going, but at least the background works now!

Unfortunately, to get everything to wrap-scroll "Just Right" I've had to draw the background image TWICE! Which is taking it's toll, meaning I can now only draw about 50 sprites.
Still.. I think that's enough for Blockman, right?!

Also, since I can no longer do the Z-Ordering (due to the background blocks having already been drawn) I've had to squish everything back into the 2D realm, instead of having the nice chunky look to it.
Bah, humbug..

It's getting there..

Bloody Java.