2d Platformer to 3D

Blitz3D Forums/Blitz3D Programming/2d Platformer to 3D

FatboY(Posted 2003) [#1]
Hey guys,

I recently decided to rewrite an old platform game of mine, made in Blitz on the Amiga, in B3D.

I had previously started writing it in C/OpenGL a while ago, but gave up because model loading in C looked like a nightmare. Anyway, that's beside the point.

The first task in both the B3D and OpenGL versions was to load a level from a map and draw it on the screen, in the same way as a 2D platformer, but to give each tile depth, as shown in this screenshot from the OpenGL version:



In OpenGL this was relatively easy - simply draw a cube for each square on the map, leaving out faces that were hidden by an adjoining block. In the OpenGL version, I drew the map with every frame, but drew only the 10x10 or so blocks around the player that were actually visible.

In B3D I tried the same method, but creating a mesh with every frame proved very slow. So I tried creating the whole map as a mesh, which I would just move as needed. The more faces I added, the more the level started to jerk when it was moved around.

So I'm now stuck wondering how best to create and display the level. My current attempt is available at http://www.fatweb.org/files/gf3d.zip (load and run gf3d.bb) if anyone would be kind enough to take a look and offer some friendly pointers?

TIA


jhocking(Posted 2003) [#2]
One thing to keep in mind is that frustrum culling will only help you (by not rendering stuff off camera) if things are separate objects. If the entire level is a single mesh the entire level will be rendered every frame, resulting in a lot of wasted rendering time as stuff out of view is drawn. Make sure that the level is split up into separate objects (every continuous chunk of blocks, like the J at the left of your screenshot, would be a good start) so that things off camera won't be drawn.

The idea is so that Blitz will automatically do what you were doing manually, only drawing the few visible blocks immediately surrounding the character.

I've not downloaded your demo so I don't know if you are already doing this, but I assume you aren't because you are getting slowdowns rendering the simple scene depicted in your screenshot.


FatboY(Posted 2003) [#3]
Thanks Joe!

Your idea was a kickstart in the right direction, Instead of making the level one whole mesh, I made each individual block a mesh, and it now runs zoomspeedy :D

I think i'm just having trouble converting from OpenGL thinking to DX thinking - in OpenGL you could simply draw polys onto the screen, then clear 'em off. With DX, it's all a case of thinking meshes and surfaces etc, and it's proving to be quite different :|