Blade Brothers Engine: Creating my first 2D Game Engine

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Post by dandymcgee »

MrDeathNote wrote:
LeonBlade wrote:I fucking dicked around with trying to set the current working directory in Qt for fucking an hour or two using all this stupid shit... (mind you I'm tired right now)
And out of god damn know where I check the project settings and it's in a fucking dialog...

I felt like such a fucking idiot :nono:
Anyways, I'm going to start getting the game to run in the window (just to test), then the editor!
Also, I got SDL to run in Qt finally too :) but I'm glad I'm using them both together though.

Also, today is my birthday... so I expect everyone to get me something when I wake up ;)
Thanks everyone for your help thus far, it's very much appreciated. <3
Just wondering, but why do you need to use SDL with Qt?
Audio maybe?

Happy Birthday Leon. Hope you get something nice from someone (cus you ain't getting it from me). ;)
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Post by LeonBlade »

Hahaha, thank you guys.
And thank you for the cat/cake :) haha.

Also, I'm using SDL for events just because it was the core of my engine when I started making it.
If you guys suggest I use something else, let me know!

OH using SDL in Qt haha I read that wrong...
Well, I wont actually be using it >_> but it's used currently in my animation system which I need to swap it out for something else.

Code: Select all

if (oldTime + frameRate > SDL_GetTicks())
	return; // not ready for next frame
	
oldTime = SDL_GetTicks();
currentFrame += frameIncrease;
Tell me if you know something I should use instead!
Sorry if these seems like noob-ish questions to you guys, haha. I've never used OpenGL or Qt really before... :roll:

I'll be getting the engine going inside Qt now, let me know if you have anymore suggestions.
There's no place like ~/
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Post by LeonBlade »

BAH, something's wrong... every so often the map will load in, other times it doesn't ):
I have no idea what's wrong at all... and it seems that my player wont move no matter what.
I try setting his position and it doesn't change on the screen.

I think I've come to the conclusion that my screen isn't updating!

BUT WAIT...
I realize lol I didn't call the updateGL() function >_> whoops...
So I do and BAM shit works :)
There's no place like ~/
User avatar
MrDeathNote
ES Beta Backer
ES Beta Backer
Posts: 594
Joined: Sun Oct 11, 2009 9:57 am
Current Project: cocos2d-x project
Favorite Gaming Platforms: SNES, Sega Megadrive, XBox 360
Programming Language of Choice: C/++
Location: Belfast, Ireland
Contact:

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Post by MrDeathNote »

LeonBlade wrote:BAH, something's wrong... every so often the map will load in, other times it doesn't ):
I have no idea what's wrong at all... and it seems that my player wont move no matter what.
I try setting his position and it doesn't change on the screen.

I think I've come to the conclusion that my screen isn't updating!

BUT WAIT...
I realize lol I didn't call the updateGL() function >_> whoops...
So I do and BAM shit works :)
Lol i've done that so many times, and every time it gets a WTF from me. As regards SDL, everything you need can be handled by Qt itself(probably), eg for the example you gave you could use a QTimer to manage framerate.
http://www.youtube.com/user/MrDeathNote1988

Image
Image

"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Post by LeonBlade »

Here's my update on my Editor.
Image
So far the scroll bars... don't actually work >_> you'll see that the map is being drawn from the 0,0 coords which I need to fix... again...
However! I've added a new little feature that will come in play for later that lets you set the tileset!
Image
Then I choose my tileset and there you go...
Image
This one is just another color haha, but you get the idea...

Sorry not much of really ANYTHING was done here... I was trying to get scrollarea working but that wasn't so I think I'll get these scrollbars working by "hand".
Work ends at 4:30 AM so that doesn't give me a lot of room to play other than the few minutes that are here and there during work.

Here are my goals for tomorrow:
1. Get the map to render from the top left ;)
2. Hook up the scrollbars to scroll the map, the max being the size of the map so there's no overflow of black on the outside like you see now.
3. Get the mouse events hooked up so I can click a tile to change it
4. Add a dock (the floating little panels) for the tileset you have loaded.
5. Get a "New Map" dialog working
6. Saving & Loading maps

And maybe something else after all that... well I'm off to bed!
There's no place like ~/
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Post by eatcomics »

good update, in my books if there's screenies, its good :D and keep it up
Image
User avatar
Milch
Chaos Rift Junior
Chaos Rift Junior
Posts: 241
Joined: Sat Jul 11, 2009 5:55 am
Programming Language of Choice: C++
Location: Austria, Vienna

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Post by Milch »

Cool, screenies :3
Looks nice so far - keep up the good work!
Follow me on twitter!
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Post by LeonBlade »

Well... my list of goals didn't get achieved yesterday, but today they will!
I had to get over a big UI hump plus work prevented me from doing much on it, but I have today and tomorrow off!

So here's my current status.
So far, I've added the scrollbars and they work like how I originally wanted them :)
And some small map properties have been added.

BUT, I've run into an error :(
Let me take you through the steps of resizing your map...

Here is my editor (fancy eh? lolnonotreally)
Image

Okay, so let's go to map properties! (oops should probably change the title heh)
Image

And lets resize it!
Image
Uh... oh god... what the shit?

Basically what happens is, my tiles get shifted all around the map because they're just layed out in order from top-left to bottom-right (like how you would read) and it goes down each line each time. So basically my tiles get moved around...

So there are a few ways I can get around this.
1. Have each tile have a coordinate on the map
2. Inject blank tiles where needed

While 1 would be kinda easier, 2 would be more efficient in the long run.
So that's what I'm gonna work on next.

Right now I wrote this all while having a POUNDING and I mean POUNDING FUCKING HEADACHE
So I'm going to bed now haha, suggestions if you have any and comments are always welcome!

Good night<3
There's no place like ~/
User avatar
GroundUpEngine
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 835
Joined: Sun Nov 08, 2009 2:01 pm
Current Project: mixture
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: UK

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Post by GroundUpEngine »

Man great work so far, looks sweet!! Be persistent my brotha, problem solving is an essential skill in programming ;)
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Post by eatcomics »

Dude nother fine update, I like it when people post frequent updates because it makes me feel bad for not and then I get to work :D
Image
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Post by LeonBlade »

Okay, so when I resize the map it was working... but I re-broke it >_<
I got saving, loading, etc implemented now.

Wait... what the fuck have I been doing all day then?
FFFUUUUUUUUUUUUUUU-
I'm gonna work harder today >_>

Anyways, the fucking thing screws up when I make the map any taller... I don't get it...
How should I get the tileset to load in on the left?
Should it be in a new OpenGL screen? Or should I learn how to use something like QGraphicsView or some shit?

See you guys later, I'm gonna get some breakfast and go to bed. <3
There's no place like ~/
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Post by LeonBlade »

I have a big update in store for my next post, but right now I some help.
As you all know, or should if you've been following along, my map file is stored in a binary format.

Now, I need to add a few things to the header section, which currently holds the filesize, tilesX and tilesY.
I need to store the tileset name that it uses, and also the name of the map, something like "The Town of the Dead" just a string like that.

Now, how should I go about this, because I've tried many ways and have failed every time.
This is my current MapHeader struct:

Code: Select all

struct MapHeader
{
	unsigned int		fileLength;
        unsigned short		tilesX;
	unsigned short		tilesY;
};
How do I add those few fields to it?
Thanks.
There's no place like ~/
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Post by Ginto8 »

LeonBlade wrote:I have a big update in store for my next post, but right now I some help.
As you all know, or should if you've been following along, my map file is stored in a binary format.

Now, I need to add a few things to the header section, which currently holds the filesize, tilesX and tilesY.
I need to store the tileset name that it uses, and also the name of the map, something like "The Town of the Dead" just a string like that.

Now, how should I go about this, because I've tried many ways and have failed every time.
This is my current MapHeader struct:

Code: Select all

struct MapHeader
{
	unsigned int		fileLength;
	unsigned short		tilesX;
	unsigned short		tilesY;
};
How do I add those few fields to it?
Thanks.

Code: Select all

struct MapHeader {
	char				name[32];
	unsigned int		fileLength;
	unsigned short		tilesX;
	unsigned short		tilesY;
};
this will allow for a name up to 31 characters (you need a trailing '\0'), and it will correctly serialize.

Anyway, I've been lurking a bit on this project, and it's really looking nice! Keep up the good work!
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
Van-B
Chaos Rift Regular
Chaos Rift Regular
Posts: 125
Joined: Tue Aug 10, 2010 7:17 am
Current Project: iPhone puzzle game
Favorite Gaming Platforms: All - Except Amiga
Programming Language of Choice: DBPro, ObjC++
Location: Scotland

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Post by Van-B »

I think your file format will go from neat and easy, to brutal rape in the course of that change. I hate doing anything with text,l spent the last 2 evenings making a bitmap text font system, and that drove me mad, not even saving data out or loading it in.

This will sound daft, but can't you just index things, like standardise your tile maps, store their name in an array, and stick to it - so that you can refer to a tile map by it's number instead. So your level file might say, use tile map 5 and it's area 7, which could be 'snowytiles' and 'horrible mountains'. That way you can keep the format as binary, but also you will have less chance of running into file issues - because if you specify a tile map by name in the level file, that tile map can't easily be renamed, nor can your level name - however if it's an index to an array, then your golden - you just change the index text instead.

Would take a bit of organisation, but compared to fighting with character strings in files, comparing them, consistancy... well I wouldn't relish that, infact I'd avoid it like the plague.
Health, ammo.... and bacon and eggs.
User avatar
mv2112
Chaos Rift Junior
Chaos Rift Junior
Posts: 240
Joined: Sat Feb 20, 2010 4:15 am
Current Project: Java Tower Defence Game
Favorite Gaming Platforms: N64/Xbox 360/PC/GameCube
Programming Language of Choice: C/++, Java
Location: /usr/home/mv2112
Contact:

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Post by mv2112 »

Ginto8's method works, i'm now using it for my map file format :mrgreen:
And also, great work, the editor looks awesome! I too am also making a map editor with Qt...
Post Reply