Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to make a class for displaying levels  (Read 2454 times)

0 Members and 1 Guest are viewing this topic.

GroundZero

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
How to make a class for displaying levels
« on: June 28, 2012, 07:31:45 pm »
Dear readers,

could someone give me a sample code, or explain to me (since I am totally noob when it comes to developing games) how I should make a class to load levels?

I have no clue where to start and -or how to do it.

I need a class which includes (i think).
What level to load, what enemies in it and where to spawn, and some general info i guess like "level name" and so on.

Hope someone can tell me how they did it :)

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: How to make a class for displaying levels
« Reply #1 on: June 28, 2012, 07:40:40 pm »
Could you give some more precis info?

What kind of level?
What info (precisely) would you like to load?

I made a 2d platformer level loader which loads from a .txt file. Would that be relevant for you?

GroundZero

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: How to make a class for displaying levels
« Reply #2 on: June 28, 2012, 08:55:35 pm »
Hey natchos, thanks for your reply!!!
I am not sure as this is my first game but I will try to type out all the info I need.

1. Level name
2. Chapter number (each level has multiple chapters)
3. Chapter name

4. What sort (different species) enemies will spawn
5. What sprites to load and display (the level sprites and so on)
6. ????

I am not sure what more to do as this is my first game and it is still a learning process :)

Edit
I think a level range would be good to i.e. level 1-5. If someone is higher, then he will not receive experience or receive less from killing enemies.

I also want to be able to make a list of enemies with their statistics like:
- HP (health)
- Damage (Strenght based for example)
- Gold drop (how much he can drop)
- Item drop (which items he can drop, items will be in a list to like enemies list)
- Enemy sprite(s)

This so I can easilly add new monsters or items. But that is of no concers for the class I am asking for now ;)
« Last Edit: June 28, 2012, 09:01:12 pm by GroundZero »

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: How to make a class for displaying levels
« Reply #3 on: June 28, 2012, 10:15:23 pm »
It's best to list out everything you're going to need for one level of the game so you know what's going to end up copied from LV to LV and what's going to not be.

Each level object should hold
the LV name and/or number
list of sprites (This one is a must)
list of maps?? (Depends on what you are doing)
lists of (anything else) : You should get the idea by now what I mean by now

There are going to be a lot of lists for just one LV object. So it's a good idea to make a list of all the things you are going to have more than one of in the level first that way you know what's coming.  Things like the name and number of a LV are important but can be put in at any time and only useful for when you need to track something.

I've found that my level objects are mostly lists of other things in them and have some kind of mini game loop that runs the level and updates everything. :)
I have many ideas but need the help of others to find way to make use of them.

game_maker

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
    • Email
Re: How to make a class for displaying levels
« Reply #4 on: June 28, 2012, 10:19:25 pm »
You can save maps in text files (.dat, .map, ...).
Then u just read, with stdio, if u want.
You will checking character by character, and then u create instances according to these characters.

The map would be something like:

0001111222000
0011122221110
0000111100000
2222111100000
0011110001110

Two links that might interest you:

http://lazyfoo.net/SDL_tutorials/lesson29/index.php
http://www.parallelrealities.co.uk/2011/10/intermediate-game-tutorial-1-displaying.html

Note: Both work with SDL, but logic is the same.
If u can't translate the code, ask it here in the forum.

Goodbye!

GroundZero

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: How to make a class for displaying levels
« Reply #5 on: June 28, 2012, 11:34:33 pm »
Think I forgot to tell you it is a 2D game like Maplestory... so basicly you can fall down, jump, and walk left and right and thats basicly it (you can attack to obviously lol). I generate maps by making sprites which are basicly build up out of square images (PNG).

A image can be 20x100 pixels, 100x 100 but obviously 100x200 pixels to. Multiple items will be the "decor" of one scene (level, chapter, whatever you want to call it).

 

anything