Blade Brothers Engine: Creating my first 2D Game Engine
Moderator: PC Supremacists
Re: Blade Brothers Engine: Creating my first 2D Game Engine
who's the cute gurl is all i really wanna know.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
Dad, "Yea well I have a fan belt in street fighting"
- Bakkon
- Chaos Rift Junior
- Posts: 384
- Joined: Wed May 20, 2009 2:38 pm
- Programming Language of Choice: C++
- Location: Indiana
Re: Blade Brothers Engine: Creating my first 2D Game Engine
Looking like a good start. Keep up the good work.
Hopefully its his girlfriend or its a little creepy that he's using her as a test sprite. :Pavansc wrote:who's the cute gurl is all i really wanna know.
- LeonBlade
- 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
Hahaha, me and her are togetherBakkon wrote:Looking like a good start. Keep up the good work.
Hopefully its his girlfriend or its a little creepy that he's using her as a test sprite. :Pavansc wrote:who's the cute gurl is all i really wanna know.
I hope to either work on it within the next few hours, or tomorrow perhaps.
There's no place like ~/
- LeonBlade
- 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
Hey everyone, I'm experiencing some issues on my tilesheet...
For whatever reason it returns the tile on the right and whatever Y gets passed in.
Here is an example:
This is me passing in (0,2) yet it doesn't do the X position correctly.
I'll try outputting some information to the console, in the mean time, here is my for loop:
For whatever reason it returns the tile on the right and whatever Y gets passed in.
Here is an example:
This is me passing in (0,2) yet it doesn't do the X position correctly.
I'll try outputting some information to the console, in the mean time, here is my for loop:
Code: Select all
void BBETileSheet::LoadTiles(BBETexture *texture, int rows_w, int rows_h)
{
t_Texture = texture;
t_TilesW = rows_w;
t_TilesH = rows_h;
for (uint x=0; x<rows_w; x++) {
for (uint y=0; y<rows_h; y++) {
SDL_Rect tileRect;
tileRect.w = tileRect.h = 32;
tileRect.x = (x * 32);
tileRect.y = (y * 32);
t_Tiles[x, y] = tileRect;
}
}
}
There's no place like ~/
- Bakkon
- Chaos Rift Junior
- Posts: 384
- Joined: Wed May 20, 2009 2:38 pm
- Programming Language of Choice: C++
- Location: Indiana
Re: Blade Brothers Engine: Creating my first 2D Game Engine
This is C++, correct? This doesn't look right. You probably want t_Tiles[x][y] if this is a 2D array.LeonBlade wrote:Code: Select all
t_Tiles[x, y] = tileRect;
- GroundUpEngine
- 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
That was I was thinking, How did that compile with no errors?Bakkon wrote:This is C++, correct? This doesn't look right. You probably want t_Tiles[x][y] if this is a 2D array.LeonBlade wrote:Code: Select all
t_Tiles[x, y] = tileRect;
- LeonBlade
- 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
Yeah I'm not sure what I was thinkingGroundUpEngine wrote:That was I was thinking, How did that compile with no errors?Bakkon wrote:This is C++, correct? This doesn't look right. You probably want t_Tiles[x][y] if this is a 2D array.LeonBlade wrote:Code: Select all
t_Tiles[x, y] = tileRect;
This is what it looks like now:
Code: Select all
void BBETileSheet::LoadTiles(BBETexture *texture, int rows_w, int rows_h)
{
t_Texture = texture;
t_TilesW = rows_w;
t_TilesH = rows_h;
int cTile = 0;
for (uint y=0; y<rows_h; y++) {
for (uint x=0; x<rows_w; x++) {
SDL_Rect tileRect;
tileRect.w = tileRect.h = 32;
tileRect.x = (x * 32);
tileRect.y = (y * 32);
t_Tiles[cTile] = tileRect;
cTile++;
}
}
}
Basically it makes it a long string of tiles, but in reality, the image isn't spliced up or anything.
I was also having problems with optimizing my image for transparency with a transparent color with color keys, so I just instead made it a PNG and transparent
So now everything is working just as I want it to with BBETileSheet!
Next I plan on making some sort of level editor... should I do this using SDL to render the graphics?
Or should I just load in the graphics a different way? I want to have an actual UI that you can click around and stuff, and have the SDL screen in a portion of the window if at all possible.
And then there is the issue of in what format should my maps be saved in.
Would an XML based map system be worth it? Or should I just make a large file full of numbers and commas to delimit them and load it in and parse out the tiles from there?
Thanks for everyone's words so far.
There's no place like ~/
- RyanPridgeon
- Chaos Rift Maniac
- Posts: 447
- Joined: Sun Sep 21, 2008 1:34 pm
- Current Project: "Triangle"
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C/C++
- Location: UK
- Contact:
Re: Blade Brothers Engine: Creating my first 2D Game Engine
Unless you plan on doing alot of pixel manipulation you may want to look into using OpenGLLeonBlade wrote: Next I plan on making some sort of level editor... should I do this using SDL to render the graphics?
- Ginto8
- 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
and even if you want to do a lot of pixel manipulations, you can probably implement it more efficiently than SDL does by using OpenGL and some stuff like glUpdateTexture() (or w/e the function is, I remember seeing it used in a nehe tutorial)RyanPridgeon wrote:Unless you plan on doing alot of pixel manipulation you may want to look into using OpenGLLeonBlade wrote: Next I plan on making some sort of level editor... should I do this using SDL to render the graphics?
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.
- LeonBlade
- 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
Hmm, well that doesn't sound too goodRyanPridgeon wrote:Unless you plan on doing alot of pixel manipulation you may want to look into using OpenGLLeonBlade wrote: Next I plan on making some sort of level editor... should I do this using SDL to render the graphics?
I think I'll just make the level editor entirely in the game engine instead of making a graphical UI.
It wont be a challenge, and with the right graphics I can make it look nice
Here are some of the features/goals I want for the editor:
Ease of use:
This one should come as no surprise. Obviously you want a level editor to be easy to use.
I plan on making a simple HUD that will hold tiles and other properties on the right side, and tools on the left side.
Features like a rectangle tool to easily draw large areas, being able to right-click to set the current tile to the one under your mouse, things like that.
Multiple Layers:
There will be the base ground layer which will contain all the basic tiles that wont have transparency on them.
This includes things like grass, pathways, walls, etc.
The base layer or ground layer will be below every thing else
A second layer will hold elements that will be above the ground layer, but not over your character.
This is where you would place tiles like flowers, windows, trees, chairs, things with transparency in their tile.
The third layer will be all tiles you want to be placed above everything else.
These would be things like bridges for example that are over your character.
I may decide to make a priority layer that will sort the Z of the tile instead and just have 2 extra layers for transparency.
Collision Layer:
This is pretty straight forward, all tiles with an X or some other form of way to signify a collision will be a solid[/b] tile and you cannot pass through it.
Event Layer:
When you go into the event layer, the right panel will change.
Instead of showing all the map tiles, it will instead show character tiles and other event tiles that can be used, as well as an invisible tile.
The right panel will contain properties for your event as well.
Every event has:
- Tile or character tilesheet for NPCs.
- Trigger type whether it be auto-start, key press, player touch/collision, etc.
- Solidity either true or false to determine if you can walk through the event or not.
- Script file will be the name of the script you wish to call when the trigger is fired.
I'm going to look into Lua and see if I want to use that, but I may decide to use Ruby instead.
If you have any suggestions, please let me know.
That's pretty much it for my mock-up of the level editor.
Let me know what you guys think and what I should change or improve on.
Right now I'll be working on statically loading in a hard-coded map file.
Here is an example of how I want to have my map saved:
Code: Select all
<Map name="My Map" width="300" height="250" tilesheet="mytileset.png">
<GroundLayer>
TILE_NUMBER,X_POSITION,Y_POSITION,COLLISION_STATE
</GroundLayer>
<SecondLayer>
TILE_NUMBER,X_POSITION,Y_POSITION,COLLISION_STATE
</SecondLayer>
<ThirdLayer>
TILE_NUMBER,X_POSITION,Y_POSITION,COLLISION_STATE
</ThirdLayer>
<EventLayer>
SPRITE_SHEET,X_POSITION,Y_POSITION,COLLISION_STATE,TRIGGER_STATE,SCRIPT_FILE
</EventLayer>
</Map>
Code: Select all
0,0,0,0
0,0,1,0
2,0,2,1
Then I would have the tile which I could delimit each property with the comma and then create a sprite for that tile etc.
For events it's the same way, only I do other stuff for the events of course because they aren't just tiles.
Let me know what you think of my approach to this!!!
If you think that I'm just going crazy with it and should tone it down, or if you have some suggestions PLEASE PLEASE PLEASE let me know.
This is my first engine and my first level editor, so right now I'm not entirely sure what to do.
Next I'll be working on loading in a level just with tiles that just appear in rows like this:
Code: Select all
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
Thanks, and hope to hear your input.
There's no place like ~/
Re: Blade Brothers Engine: Creating my first 2D Game Engine
Some suggestions to your map implementation:
- Use YAML instead of XML, easier to read and maintain.
- Don't limit one map to one tileset. You will end up merging images with something like GIMP, unneccessary extra work.
- Use YAML instead of XML, easier to read and maintain.
- Don't limit one map to one tileset. You will end up merging images with something like GIMP, unneccessary extra work.
- Bakkon
- Chaos Rift Junior
- Posts: 384
- Joined: Wed May 20, 2009 2:38 pm
- Programming Language of Choice: C++
- Location: Indiana
Re: Blade Brothers Engine: Creating my first 2D Game Engine
It's also pretty easy to create an OpenGL texture from an SDL_Surface*. I find it easier to keep track of GLuints instead of SDL_Surface pointers.RyanPridgeon wrote: Unless you plan on doing alot of pixel manipulation you may want to look into using OpenGL
This is a big one IMO. Just have a tile know which spritesheet to use and then the (x,y) block on that sheet.K-Bal wrote: - Don't limit one map to one tileset. You will end up merging images with something like GIMP, unneccessary extra work.
- LeonBlade
- 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
Thank you for the suggestions and improvements.
Once I get to work again, I will implement them.
Once I get to work again, I will implement them.
There's no place like ~/
- RyanPridgeon
- Chaos Rift Maniac
- Posts: 447
- Joined: Sun Sep 21, 2008 1:34 pm
- Current Project: "Triangle"
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C/C++
- Location: UK
- Contact:
Re: Blade Brothers Engine: Creating my first 2D Game Engine
Sorry, I didn't realise you were talking about an external level editor.
For that I'd recommend Qt, it's cross-platform, powerful and intuitive
For that I'd recommend Qt, it's cross-platform, powerful and intuitive
Re: Blade Brothers Engine: Creating my first 2D Game Engine
I hope to get an ingame level editor in my platformer soon. School has pulled me in, and I have other things to do for an alliance I'm in... One of my friends runs the alliance, so he forces me to work XD but anyways looks great and keep it up. Do you have youtube vids, if so I'll go sub :D