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
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 »

mv2112 wrote:I was following the tutorial on the homebrew site on how to install SDL. I guess i'll go get the prebuilt stuff instead. :|

EDIT: Which prebuilt files do i get? There are mac,linux and win32 ones.
...I would assume you get the one for your operating system...
There's no place like ~/
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 »

Well all the libs that came with the compiler are .a libs, rather than .lib libs that visual studio uses so i dont know which one to get, unless it doesnt matter...

EDIT:
I ended up just putting the source files in the project rather than using a library.
User avatar
epicasian
Chaos Rift Junior
Chaos Rift Junior
Posts: 232
Joined: Mon Feb 22, 2010 10:32 pm
Current Project: Gigazilla Engine
Favorite Gaming Platforms: Dreamcast, SNES, PS2, PC
Programming Language of Choice: C/++
Location: WoFo, KY

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

Post by epicasian »

How is SDL on the Wii, performance wise? Because I know SDL is terrible on the DC.

Thanks,
~Asian
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 »

epicasian wrote:How is SDL on the Wii, performance wise? Because I know SDL is terrible on the DC.

Thanks,
~Asian
Uh I have some problems with it right now but... idk
There's no place like ~/
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

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

Post by Falco Girgis »

epicasian wrote:How is SDL on the Wii, performance wise? Because I know SDL is terrible on the DC.

Thanks,
~Asian
I'm sure it's pretty shitty on the Wii. It's 100% CPU and NO hardware acceleration.

There is a "hardware accelerated" SDL port on Dreamcast that performs just fine, but there are some rendering glitches when porting certain applications.
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 »

epicasian wrote:How is SDL on the Wii, performance wise? Because I know SDL is terrible on the DC.

Thanks,
~Asian
On a scale of 0-10, about a 4.
It gets the job done...
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 »

Cool so I got autotiles working thanks to my friend. :)
Image

I realized what my error was, and now I'm smooth sailing, time to put it in the Engine.
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 »

LeonBlade wrote:Cool so I got autotiles working thanks to my friend. :)
Image

I realized what my error was, and now I'm smooth sailing, time to put it in the Engine.
Finally! Nice one ;)
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 »

Thanks man, I was having a little bug with it, but I sorted it out.
Now I'm kinda updating the engine here and there.

I got it now on a 32x32 grid instead of 16x16 which means GRAPHICS OVERHAUL I need some new resources, so I'm gonna rip some shit for now.
Here's what I got planned...

For my editor I want the ability to place ground tiles and also object tiles which would take care of the rendering order like a virtual z-buffer if you will. (got the idea from this guy's editor on YouTube really cool shit).

Only problem is, I wanna have a GUI intense fucking editor and shit but like I cannot for the life of me get SDL working in Qt on my Mac.
So I was thinking about switching to OpenGL instead and trying to get that rendering? So like switch my engine from SDL to OGL.
But basically the ground tiles are ju... Here let me organize the shit out of this post.

GROUND TILES
Could also just be called terrain but whatever. These tiles are the ones that sit there being all ground like and are going to always be under the player no matter what so you step on shit and be like fuck your shit bitch I'm a mother fucking Hero trying to save the day 'n shit and you're just being in my way.

The ground tiles are going to be their own separate sheet 256px by 256px image with 32px by 32px tiles making 8x8 tiles so 64 tiles total.
So from there you can just place the fuck out of these tiles and set the ground without and fancies on it.

On the editor when you chose to draw with the ground tiles, the properties section on the right or whatever will populate with the ground tiles of the specific tile sheet you associated with this map file (this is where the GUI stuff really needs to come into play).

OBJECT TILES
Object tiles are really cool because they're just bad ass and shit. Basically you have an object image for each object you wanna place in the game.
So lets say you made some bad ass looking map but it's just grass and it's not bad ass at all you dirty liar. So you wanna spice things up like Emeril does and throw some shit in the pan and go BAM like a retard. So what you would do is create a new object tile. Basically what that does is you pick an object resource like a damn tree or something cool like that. Now it opens up in a preview window which you can set the layering of it. Basically there's a virtual grid drawn over the object so you can see each tile more clearly. Now what you would do is click on the spots that are supposed to be above everything else, and that will put those above the player and also above other stuff too so you don't have to worry about layering.

Okay so now you got your bad ass tree all tree like and you're ready to tree the fuck out of your new map. So all you gotta do is go to the object drawing tool and open up the object panel which shows all your little objects being all object like and stuff. You simply select the object you wanna draw and then you place it on the damn map and bam you got yourself a tree. But wait, if you put a tree right below it the mother fucker does some z-buffering like shit and puts the top of the tree on top of the last tree so you don't have to worry about layers or anything.

AUTO TILE
These guys are really cool cause they know what the hell you're drawing like magic and miracles or something I don't even know anymore. So pretty much you set up the auto tiles just like you do object tiles, the only difference is that you don't stamp them down like you do normal tiles or object tiles. You draw them and they fill in the area you want automatically fixing the problem of drawing edges and corners and all that stupid shit no one wants to hand draw themselves you know?

So you open up a new auto tile and you set the special auto graphic tile which is just a 3x4 tile sheet. The top left is the preview tile that will be in the editor so you don't see a huge ass tile in the thing. Then the tile on the top right are the inside corner tiles which are actually broken into half the regular tile size so in this case 16x16 but that doesn't matter. Then the bottom 9 tiles are the corners and sides and middle. So here you can also set what will be above the player just by clicking on the tiles that you want to float above everything else.

So now you got your auto tile, all you gotta do is select it and then draw and bam the shit just works.
This is used for things like water, pathways with dirt, roofs and houses anything like that to make life easier for map making.

COLLISION TILES
This is pretty simple to explain... it's just collision...

EVENTS
This is where the cool shit comes into play.
I still need to iron this shit out more, but whatever.
Basically you just give a few parameters to the event.
First you give it an identifier to reference it from.
Then you chose what graphic you want. The editor/engine will know if it's a static image or a NPC character sheet based on dimensions.
Then that's pretty much it for the event, it just goes somewhere on the grid in the map.

Sorry for posting all this shit here, it's just easy for me to put it here for later heh.

Also, I'm trying to get tile based movement down, and for whatever reason, I'm having some problems with that haha.
So like my guy will move and I say...

If he's NOT moving then check his position and keep the accel going until your position modulus the tile size (32x32) is zero then you're on a tile.
My guy updates something like player postion += accel and the accel is basically if you're moving in some direction set the velocity to that direction with a speed of 5.0f.

Now what happens is, it tries to stop on (32x32) even section. So it stops not on 32 but instead 160 because if you keep adding 5 over and over again to position you wont hit a 32 mod until then. So what I wanna do is change that so it will work basically...
Does anyone have a good site that has good like old school Final Fantasy movement stuff so I can model my movement off of it?

Thanks, sorry for such a long post that I'm sure most of you wont read.
A lot of this I've said in previous posts but I kind of just channel all my ideas here and then yeah...

But here's the major thing though.
You guys think I should switch to OpenGL? I started to but then I didn't know how to use it very well... :roll:
OR if anyone knows how to get SDL in Qt that would be great too.

Thanks.
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

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

Post by XianForce »

I'm glad to say I read that whole post. I found it interesting to be honest. I think the switch to OpenGL will be good though. It doesn't take long to learn how to do what you can do in sdl, using immediate mode. If you need more power, or usage, OpenGL has plenty of options. I love using OpenGL with sdl =D
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 »

XianForce wrote:I'm glad to say I read that whole post. I found it interesting to be honest. I think the switch to OpenGL will be good though. It doesn't take long to learn how to do what you can do in sdl, using immediate mode. If you need more power, or usage, OpenGL has plenty of options. I love using OpenGL with sdl =D
Thanks for reading it haha :)
If you have any suggestions for me or anything let me know!
And I think I'll try a little demo of getting OpenGL running in Qt to better motivate me to make the switch to do my rendering in OpenGL.
There's no place like ~/
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

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

Post by XianForce »

LeonBlade wrote:
XianForce wrote:I'm glad to say I read that whole post. I found it interesting to be honest. I think the switch to OpenGL will be good though. It doesn't take long to learn how to do what you can do in sdl, using immediate mode. If you need more power, or usage, OpenGL has plenty of options. I love using OpenGL with sdl =D
Thanks for reading it haha :)
If you have any suggestions for me or anything let me know!
And I think I'll try a little demo of getting OpenGL running in Qt to better motivate me to make the switch to do my rendering in OpenGL.
Well first, let me say what I love most about that long post, is that you explain a little bit of how each thing works. It really motivates me, and inspires me with new ideas to steal haha.

But I don't know anything about Qt except I hear it's amazing. One of these days I want to play around with it...


But the only suggestion I can give, is to expand the collision section. Although it doesn't seem like much at first, when you really go to implement things, how are collisions ultimately handled? Is each object/tile going to have a 'solid' boolean? Are you just going to have a list of rects which define the collidable areas of the map? Are you going to implement some type of quad tree, where each thing belongs to some section?

I mean I really thing there's a lot to talk about regarding collision, in which your map editor should have control over.
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, my engine is clearly fucked from switching to OpenGL.
I'm blitting before I render with OpenGL doing a mix of SDL and OpenGL so I can get my tile frames for my character.

Here is the code that runs every game loop for rendering:

Code: Select all

SDL_Surface *tempSurface;
tempSurface = SDL_CreateRGBSurface(0, 32, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
	
SDL_BlitSurface(entitySurface, &frameRect, tempSurface, NULL);
	
glBindTexture(GL_TEXTURE_2D, entityTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, tempSurface->pixels);
	
glBegin(GL_QUADS);
	
glTexCoord2d(0.0, 0.0);	glVertex2d(position.x, position.y + 0.0);
glTexCoord2d(1.0, 0.0);	glVertex2d(32.0 + position.x, position.y);
glTexCoord2d(1.0, 1.0);	glVertex2d(32.0 + position.x, position.y + 32.0);
glTexCoord2d(0.0, 1.0);	glVertex2d(position.x, position.y + 32.0);
	
glEnd();
	
SDL_FreeSurface(tempSurface);
I understand there are a few things that should change, for example the way I'm positioning this on the screen.
However, I have no idea how OpenGL works heh.

So this works fine for just one thing, only my character speeds around the screen fast as all hell (need to fix my player movement)
Quick note, if anyone knows where I can find a good resource on tile movement like Final Fantasy let me know.

Anyways, if I try to render the map the same way... I don't get transparency and I also get really sluggish performance which means I'm doing something wrong. Anyone know what I should do?
There's no place like ~/
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 »

I'm currently online with my mobile phone so I can't post any links or so - but as far as I remember you have to create the screen in sdl with a special flag in order to use sdl functions with sdl ( something like sdl_blit) - and if I remember correctly there is a note in the docs that this shouldnt be used.

So you will have to switch completly to OpenGl - I mean stuff like displaying/loading images.
Also, you should not recreate the texture within each loop - I think this is the main reason for its slow loading. Do it the following way:
Load the textures with sdl
Convert them over to ogl texture
Discart the sdl texture
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 »

I'll look more into how to create textures without SDL when I wake up, it's 10 AM time for sleep haha. :lol:
Thanks for the help Milch!
There's no place like ~/
Post Reply