Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411423 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 19, 2024, 04:37:17 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)TutorialsSimple C++ platforming engine with SFML 2
Pages: [1]
Print
Author Topic: Simple C++ platforming engine with SFML 2  (Read 6810 times)
oahda
Level 10
*****



View Profile
« on: July 02, 2012, 06:20:06 AM »

This might not count as a tutorial. I wouldn't count it as that. If there is any forum that is more appropriate, please move it there.

Kind of over the course of one night and some hours of the following day I made a basic platforming engine with some help from a friend, who mainly took care of resource management. Initially we were going to actually make a game, but we had gotten into the mindset of programmatic design from the framework writing efforts of the previous day, so we soon went into a generic direction. It was never intended to be anything big, serious or public, but it seems to be working well enough, so I see no reason not to share it, in case anybody finds it difficult to get this kind of stuff working.

Features:
* WASD movement (A = left, D = right, W = jump)
* Gravity
* Walls, grounds, roofs/ceilings and floating platforms are possible (just put blocks anywhere, and the engine should take care of it)
* Camera following
* Resource management for images
* Nothing that's not visible on screen will be drawn, and only stuff within that area and a little bit outside of it will be updated and handled for collision

Common features unfortunately not implemented:
* Slopes
* Wall jumping
* Mid-air extra jumps

Since this was indeed not written with any kind of publication in mind, there is no tutorial on how to use the engine, but there were a couple of blocks and a character implemented, so look through the code and see if you can figure it out. The blocks and the character are added to the level in the Game class.

No licensing rubbish. Just do whatever you want with it. Claim to have written it yourself if you wish. It'd make you a terrible liar, but I won't come after you.

Download our working folder as a .zip here.

Compile and run to try. Uses no other dependencies than STL and SFML 2.
« Last Edit: July 05, 2012, 04:33:18 AM by Skomakar'n » Logged

Halcyon
Level 2
**



View Profile
« Reply #1 on: July 04, 2012, 10:12:32 PM »

Thanks for posting your source code, I will definitely have a good look through it. One thing I did notice was defining classes within classes and then setting them as a friend class. This is something I have never seen before and I can't quite make sense of how it works. It is probably a simple concept, but any light you could shed on it would be much appreciated.  Gentleman
Logged
baconman
Level 10
*****


Design Guru


View Profile WWW
« Reply #2 on: July 05, 2012, 01:26:52 AM »

Quote
Features:
* WASD movement (W = left, D = right, W = jump) <= HUH?
* Gravity
* Walls, grounds, roofs/ceilings and floating platforms are possible (just put blocks anywhere, and the engine should take care of it)
* Camera following
* Resource management for images
* Nothing that's not visible on screen will be drawn, and only stuff within that area and a little bit outside of it will be updated and handled for collision

Also, go CONTRA!! :D

Logged

oahda
Level 10
*****



View Profile
« Reply #3 on: July 05, 2012, 04:40:32 AM »

Thanks for posting your source code, I will definitely have a good look through it. One thing I did notice was defining classes within classes and then setting them as a friend class. This is something I have never seen before and I can't quite make sense of how it works. It is probably a simple concept, but any light you could shed on it would be much appreciated.  Gentleman
I'm afraid I've been mistaught for a long time, it seems! I was dead sure that not even child classes could have access to private members in C++ for years. This is new. Wow. I made a test program, and they can! Thanks for pointing that out. I wonder what past event may have lured me into that belief, for it was indeed a firm one. I'm not sure whether I like this truth. I think private members should be private, even to child classes. Big Laff

Quote
Features:
* WASD movement (W = left, D = right, W = jump) <= HUH?
* Gravity
* Walls, grounds, roofs/ceilings and floating platforms are possible (just put blocks anywhere, and the engine should take care of it)
* Camera following
* Resource management for images
* Nothing that's not visible on screen will be drawn, and only stuff within that area and a little bit outside of it will be updated and handled for collision
I don't know what you're talking about. Roll Eyes

Also, go CONTRA!! :D
Hm?
Logged

ra51
Level 0
***


View Profile
« Reply #4 on: July 11, 2012, 05:10:40 AM »


Contra, one of the greatest platform shooters ever.
Logged
oahda
Level 10
*****



View Profile
« Reply #5 on: April 25, 2013, 04:01:03 PM »

I just fixed some bugs and wrote a post about the engine on the Ludum Dare blog. There is now also a JavaScript version for HTML5 Canvas. There is an archive with precompiled versions for OS X, Linux and Windows, and the HTML5 version is included too, of course.

http://www.ludumdare.com/compo/2013/04/25/simple-2d-platformer-engine-sfml2html5/

Mentioned it in this thread as well, along with two other of my related LD posts:

http://forums.tigsource.com/index.php?topic=33037.0
Logged

indie11
Level 2
**


View Profile
« Reply #6 on: April 25, 2013, 07:47:34 PM »

The download link doesn't seem to be working, anyway the collision is tile based or using AABB?
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic