How can I make "levels" to my game world?

Previous topic - Next topic

RunningSpoon

Greetings!

I'm trying to make 2D RPG (Top View) and I run into a problem in the first steps.
I would like to have level changed when I walk to top-side of screen. Example : Level 1 is Plains and if I go to top-side of screen then Level 2 activates which is Village and when I go to down-side of screen in Level 2 I would go back to Level 1. Both Levels would have different stuff in them, like Level 1 has rocks and other stuff and Level 2 would have houses and NPCs.

I also though this could be made with big map (example 10k x 10k) and camera (size 640 x 640) follows player around, but I think that is harder to make. Not sure because I'm quite new with game coding.

I hope my problem description was understandable :)

Ian Price

There are a number of ways to do this -

1) Pre-render each scene. In other words use an art program to draw the whole level.
2) Pre-render a huge scene. As above
3) Tile map each scene (use smaller images to create larger images - like a jigsaw)
4) Tile map a huge scene (as above, but larger

Pre-rendered
==========
The first two options are valid but will take up an awful lot of time to create a large image and when saved will take lots of memory. The benefit is that everything is all in one scene and needs only one sprite call to display the scene. You can use any art editor program to create a scene. Scrolling one image would be easy

Tiled
====
This takes lots of individual tiles (usually square images) and uses them to build the scene. The scene has to be put together by the creator first and saved. It can then be re-drawn, but takes lots of calls to draw each tile. You'll need to use a map editor for this - either by creating your own or using an existing one. But you will also have to create a routine to draw your scene and deal with scrolling issues. You will have to understand arrays to be able to use tile-maps. You'll also have to create loading routines for your tile map data.

I personally would go for Tiled every single time. It's quick and easy to create a scene and elements (tiles) can be re-used elsewhere. 20 16x16 tiles are quicker to draw than one 640x480 full screen-scene. Tiles also reduce memory usage and can be displayed very quickly with GLBasic.

Have a look on the forum for scrolling/displaying tilemaps - there's plenty of info on the net with code for this (most languages will use roughly the same code, but may need tweaking a bit). It is very easy though.
I came. I saw. I played.

Wampus

As Ian suggests, yeah, go for tiled. Every single time. That's the standard, especially with 2D RPGs.

Example 10,000 x 10,000 map:-

Held as fully rendered screens. Each array element or 32-bit depth pixel is 8 bytes. So, 800 million bytes needed, i.e. 762 megabytes. TOO DAMN HIGH.

Held as tiles in an array. Each tile size is 32x32. Full map is 313 tiles by 313 tiles. If each array element is 8 bytes then you need less than 1 megabyte to fit the entire map into memory and another megabyte or two for the tiles images. No problem.

RunningSpoon

Thank you for answers. I need to check tilemaps.. Sounded little confusing, but I'm quite sure it will open to me, when I study enough :P

As Wampus put it.. tiles seems to be only option I have :)

matchy


RunningSpoon

Seems like I missed that one, thank you for linking it, matchy.

matchy

The first item on the forum search for "mappy" brings up the update for Mappy:
http://www.glbasic.com/forum/index.php?topic=4433.msg59607#msg59607

The existing sample maps and tilesets that come with mappy can be used to learn how to import and display them in to GLB. Otherwise, you can still create some level maps regardless of GLB. For example, paint one level all sand and pop some trees and houses. On another level, paint all grass and plot some houses and cows.

Look forward to seeing a map!

Darmakwolf

Heya Mr. Spoon. I'm currently working on a 2D-topdownish game myself! Check out the latest demo:
http://www.glbasic.com/forum/index.php?action=dlattach;topic=7756.0;attach=4635

If this sort of pixel-y game interests you, I can give you the source to the basic map editor and player I created  :booze:

RunningSpoon

There are couple things that got my attention, I shall PM you :)

Darmakwolf

I replied to your PM - give that a try :)