• Create Account

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

11 replies to this topic

### #1SoulHeart  Members

101
Like
0Likes
Like

Posted 20 February 2012 - 12:51 PM

I'd like to learn more about 2d level design. I've done some simple 2d games but i'm looking to get a little more complex in the future.
1. What is the best way to load and draw all of my sprite into my map.
2. How would i make a side-scroller (Isn't something about changing the sf::View)
3. What are the purposes of level editors and how do they work.
4. Anything else i should know.

I know i don't know nearly as much as i should, but that's why i'm here.

### #2Washu  Senior Moderators

7714
Like
1Likes
Like

Posted 20 February 2012 - 02:47 PM

1. What is the best way to load and draw all of my sprite into my map.

Loading is simple, you just have a level file that tells you what resources it needs, then you load those resources

2. How would i make a side-scroller (Isn't something about changing the sf::View)

There are many ways to do this. You can change your view, or you can move the entire level, or... well, if you imagine it, you can probably find a way to do it.

3. What are the purposes of level editors and how do they work.

Level editors make it easy to create content. In essence you have a GUI application that you do your work in, which when saved translates the data into a level format you recognize.

4. Anything else i should know.

Experiment and play around. Google a lot, there are a lot of people who have written things on side scrollers and the like. While they may not all use SFML, you can certainly pick up tips and tricks to use.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX

### #3SoulHeart  Members

101
Like
0Likes
Like

Posted 20 February 2012 - 03:56 PM

I still don't understand level editors at all. Are they worth using? How do they work with your program?

290
Like
1Likes
Like

Posted 20 February 2012 - 08:19 PM

I still don't understand level editors at all. Are they worth using? How do they work with your program?

Ok, think of it like this, how would you plot all the positions of every object/tile in your level? by manually inputting all the coordinates? seems a bit tedious.. you could come up with a file format which tiles different sprites based on a number index in text file. Such a file might look something like this:

w h
1 1 1 1 1 1 1 1
1 0 0 0 0 0 2 1
1 0 0 0 0 1 1 1
1 1 1 1 0 0 0 1
1 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1

where 0 represents empty space 1 a solid block and 2 something else. However this becomes tedious to edit/manage when levels become large with more than a few different types of objects, also if your not using a tile based system this will fail altogether.

Enter the Map/Level Editor, a tool that allows you to design levels visually which makes managing large levels easier with the ability to supply additional information such as collision/layers objects that exist in the map, tiles and more. Generally, the map editor will output all the necessary data in a file which can then be read by your application that runs the game.

In the end a Map/Level editor does what an useful tool does.. makes your job easier.

### #5SoulHeart  Members

101
Like
0Likes
Like

Posted 21 February 2012 - 07:45 PM

Ok that clears a lot up, thanks for helping out.

### #6BeerNutts  Members

4288
Like
0Likes
Like

Posted 21 February 2012 - 11:08 PM

If you're talking about a shoot-em up side-scroller, then, one common solution for "levels" is to create your "levels" details when and where objects/enemies appear on your screen. Typical space shoot-em ups, the main ship is always moving (right, for side scrolling, up for vertical), so you just plug in when to make an object appear.

I did this long ago (2001 or so, I was still learning) for an old game, and my "levels" looked like this:
(The 1st number is the time in Milliseconds after the level starts.
E: stands for Enemy, B: stands for Background, M: stands for Music, S: for sound
Most of my objects had default X, Y, speeds, etc/ but I could change them here too. If I did it now, I would've probably used xml)

# The format for the stage is like follows, it must be in order!
# Time enemy (or Background object) should appear since start (in mS)
# Enemy (or BackGround object) Name
# Flags (should be 0)
# Any other enemy attribute you want to change from default

# start music
250
M:stage1.wav

# Back Grounds
2500
B:Moon
0

500
B:Hills
0

65000
B:Moon
0

# Flags 131078 = SPECIAL_ENEMY | WEAPON_UPGRADE | WEAP_PLASMA
#1100
#E:Special
#0
#Flags: 131078

# Enemies/Objects
1500
E:Orb
0

2000
E:Orb
0

2500
E:Orb
0

3000
E:Orb
0

3500
E:Orb
0

5000
E:Special
0

10000
E:Fighter
0

15000
E:Special
0
LocationXY: 640 80
SpeedXY: -134 -134

20000
E:Skimmer
0
LocationXY: 640 10

20000
E:Fighter
0

23500
E:Orb
0

24000
E:Orb
0

25500
E:Orb
0
LocationXY: 640 400

26000
E:Orb
0
LocationXY: 640 400

28000
E:EMP
0
LocationXY: 640 50

31000
E:Orb
0

31500
E:Orb
0

32000
E:Orb
0

32500
E:Orb
0

33000
E:Orb
0

31000
E:Orb
0
LocationXY: 640 400

31500
E:Orb
0
LocationXY: 640 400

32000
E:Orb
0
LocationXY: 640 400

32500
E:Orb
0
LocationXY: 640 400

33000
E:Orb
0
LocationXY: 640 400

# Flags 10 = SPECIAL_ENEMY | NEW_OPTION
33000
E:Special
0
Flags: 10

34100
E:Fighter
0

35000
E:Orb
0

35500
E:Orb
0

36000
E:Orb
0

35000
E:GunTower
0
LocationXY: 640 446

41000
E:Skimmer
0
LocationXY: 40 400
SpeedXY: 268 0


My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

### #7KanonBaum  Members

277
Like
0Likes
Like

Posted 22 February 2012 - 12:00 AM

I'd like to learn more about 2d level design. I've done some simple 2d games but i'm looking to get a little more complex in the future.
1. What is the best way to load and draw all of my sprite into my map.
2. How would i make a side-scroller (Isn't something about changing the sf::View)
3. What are the purposes of level editors and how do they work.
4. Anything else i should know.

I know i don't know nearly as much as i should, but that's why i'm here.

1. It depends. From what I've seen, resources are loaded from the "map file" whenever they are needed for the game. For instance, there was a game that needed a long level. This level was divided by a certain amount of screens (the portion of the level viewed by the player). Whenever this portion of the level was approached, these portions were loaded in a thread so when said player entered the portion, the level was already loaded and the future portion was being loaded.

2. Side-scrollers consist of a "camera" following a player as he/she progresses horizontally. To achieve this affect, programmers take the "view" (a difference between the initial level coordinates and the current displacement to achieve this "camera" effect. I.e. If a player holds a KB_RIGHT_KEY (keyboard right key), some variable x_displacement will increase.) So we'll have (x_origin - x_displacement) = cam_x; If the x_origin is 0, then the displacement will be -x_displacement from the screen. (movement to the right will be moving everything to the left). It's smart trickery. ;)

3. Level editors allow you to view the level as you make it graphically. Some editors are so advanced to allow you to place objects as you see fit (with properties) and load them in your own time. Save's a lot of dev time!

4. Know your geometry. 2D games consist of geometry and the more complex your games become, the more complex the geometry may come to. For instance, I came to a point when I needed to know what angle some wall would be moving my colliding object (pseudo physics), so that it would move out of the wall's way and continue to move in some direction it was headed. Geometry really comes into play.
I'm that imaginary number in the parabola of life.

### #8SoulHeart  Members

101
Like
0Likes
Like

Posted 22 February 2012 - 06:24 PM

Does anyone know a good 2d level/map editor out there. It needs to be free and I'd like for it to be able to make good quality games and I'd like for it to be open source.

### #9Servant of the Lord  Members

33514
Like
0Likes
Like

Posted 22 February 2012 - 07:15 PM

Tiled or Mappy or Gleed2D, depending on your needs. Note, they won't make your game for you, nor do they teach your game to read their files.
You still have to make your game, and you still have to teach your game to read their file formats. This may be difficult if you've never done it before, but if you are persistent, it'll definitely be worth it.
It's perfectly fine to abbreviate my username to 'Servant' or 'SotL' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames -

### #10SoulHeart  Members

101
Like
0Likes
Like

Posted 26 February 2012 - 08:36 AM

Can I use tiled with sfml?

### #11lmbarns  Members

460
Like
0Likes
Like

Posted 26 February 2012 - 10:49 AM

I haven't used sfml but I don't see why you couldn't use Tiled to layout your maps. If you save a map as .tmx and open it in a text editor you can copy the array of tiles it created and use that in your code.

So you visually can make a map in tiled by drawing your tiles based off your sprite sheet, save it as .tmx, copy the array, load the original sprite sheet in your program, loop through the array and draw corresponding tile from sprite sheet based off array entry.

Here's a visual example using just basic javascript and html5 that loads 500x300, 64-pixel tiles based off a sprite image http://simplehotkey.com/Tiles/main.html if you could reproduce that in c++ you'd have it made.

### #12Servant of the Lord  Members

33514
Like
0Likes
Like

Posted 26 February 2012 - 10:54 AM

Can I use tiled with sfml?

Certainly. But like all programming, you have to make the 'glue' between piece one (SFML) and piece two (Tiled's maps).
It will take some work, and you'll face some challenges, but without difficulties to overcome, we don't grow as programmers.

If that's too daunting a task, someone else has already made some glue between those pieces that you can re-purpose for your project, and you'll still have to figure out how to use it, and how it will work within the structure of your game.
It's perfectly fine to abbreviate my username to 'Servant' or 'SotL' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames -

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.