Sign in to follow this  
Kami Lucky

How to platform(c++,sfml)

Recommended Posts

Being an Indian born in India taking computer science in my senior years, i have always adored c++. 

When i saw this place that said c++ is not the best first language to learn i was aghast!

 

But that has nothing to do with my problem. 

Ever since i met sfml, i have loved her. She is my sugar to my butter, my heart to me soul, my life to her death. Sure soon i'd see unreal and scoot over (Honestly the only reason i am not running one is because i have to upgrade my laptop to do so) but that destroys the point.

 

So for one of my projects i have decided to make a platformer. 

I went about it in this way.

Step 1: Start

 

Step 2: figure out where out would get the art

This was a bit of challenge, but i usually go to open game art, sometimes other places who's name i forget

 

Step 3: Use the art for a character using sprites and draw it.

This is easier said than done.considering most of the free art dosn't come as sprite sheets, what does come in sprite sheet comes without an idle animation, and so on. Eventually i had to make my own sprite sheets using someone else's images

Ah, before you ask the sprite sheets are for the animation. 

 

Step 4: figure out how to draw a map

This was somehow tougher. For starters i had no clue on how to start, i am a computer scientist not an artist. why is it so hard!!!

So i found this software called tiles, and well i can make maps from given tilesets and it works. 

 

Step 6: draw a map.

Easy a simple draw function, took me time to realize that the map has to be drawn before the characters....sad...

 

Step 7:Place the character on the map.

Again when i did draw the character he was standing at 0,0..that's top left if you go by graphics logic. took me time but now i have approximately placed him on top of the first tile. 

 

Step 8: now what?

Now i have a lot of problems with this.

The major on of them is the fact that my character walks over water, like no difference.

I looked for tutorials online. there was this one guy who's idea was a naive if anything. 

he had an array of strings and used it to draw every tile on the game. 

As good as it is, isn't it better to have the map as an single image, instead of drawing it one tile at a time?

i'm not sure, i'm a noob.

So my question is, what's the logic in a platformer. I mean 2d games usually are not supposed to have that level of depth, how do i check if my character is flying over the place where he should be dead?

Share this post


Link to post
Share on other sites

If you are making your own game engine, then there are a very great many ways to go about it. You have to understand in logical, abstract terms what you want the program to do then write code that will achieve that result.

I do not know what it is that is working in your code so far: do you have basic physics, for example? Can your character sprite jump and walk? Do you have basic collision detection? Does the character land on the floor rather than continue falling forever?

You mention "tiles": you do not necessarily need to have tiles (although having tiles is one way of doing things, I suppose): you can use splines instead. You could in principle use a 3d engine even for your 2d game (just by locking it to one perspective, although I cannot go into detail, as I have no experience with 3d engines). You mention software called "tiles": is this a game engine?

Share this post


Link to post
Share on other sites

I suspect that you have yet to add gravity into your game. In general, for every frame of processing, move your sprite down some amount if it's not standing just above a floor tile.

Share this post


Link to post
Share on other sites

No, i Do not Have basic physics yet, i'm working on it.And i'm using tiled only as an image maker.

So you are telling me to draw it speratly?

Because my floor and background are on the same image, it makes me question.

Because i read somewhere that instead of rendering each tile individually it's better to have them in one image and use that

Share this post


Link to post
Share on other sites

Sorry if I'm misunderstanding, I'm not quite clear what you're looking for.

It sounds to me like you're using Tiled like a paint program and then loading an image like a bmp or png file into your project. If that's the case, then you don't have the tile information from when you've drawn everything in Tiled that defines the floor or any platforms. You could in theory find a way to define floors and platforms yourself. But the general idea of a tile editor is having access to the attributes of all the tiles you've laid down for your level. If your sprite is at a given x,y point on the screen, you find the relevant tiles to that point and execute the behavior desired depending on the types of tiles you're looking at.

It is entirely possible to start with a non-tile based image that comes from you or an artist and then you'd define floors or platforms or different types of areas on your own but that doesn't quite sound to me like what you're trying to do.

Unless what you're asking about is how to go about doing some kind of double buffering for rendering your level to the screen which is something different. Drawing your tiles and sprites and other things to a buffer in the background first instead of directly to the screen has advantages that other people here would be able to explain better than me. In general, you draw everything to this background buffer first and then when it's all done you draw that buffer to the screen.
 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this