Page 2 of 19

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

Posted: Sun Jan 31, 2010 8:52 pm
by avansc
who's the cute gurl is all i really wanna know. ;)

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

Posted: Sun Jan 31, 2010 9:27 pm
by Bakkon
Looking like a good start. Keep up the good work.
avansc wrote:who's the cute gurl is all i really wanna know. ;)
Hopefully its his girlfriend or its a little creepy that he's using her as a test sprite. :P

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

Posted: Mon Feb 01, 2010 12:33 am
by LeonBlade
Bakkon wrote:Looking like a good start. Keep up the good work.
avansc wrote:who's the cute gurl is all i really wanna know. ;)
Hopefully its his girlfriend or its a little creepy that he's using her as a test sprite. :P
Hahaha, me and her are together :lol:

I hope to either work on it within the next few hours, or tomorrow perhaps.

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

Posted: Mon Feb 01, 2010 9:03 am
by LeonBlade
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:
Image
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;
		}
	}
}

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

Posted: Mon Feb 01, 2010 10:03 am
by Bakkon
LeonBlade wrote:

Code: Select all

			t_Tiles[x, y] = tileRect;
This is C++, correct? This doesn't look right. You probably want t_Tiles[x][y] if this is a 2D array.

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

Posted: Mon Feb 01, 2010 10:23 am
by GroundUpEngine
Bakkon wrote:
LeonBlade wrote:

Code: Select all

			t_Tiles[x, y] = tileRect;
This is C++, correct? This doesn't look right. You probably want t_Tiles[x][y] if this is a 2D array.
That was I was thinking, How did that compile with no errors?

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

Posted: Mon Feb 01, 2010 10:38 am
by LeonBlade
GroundUpEngine wrote:
Bakkon wrote:
LeonBlade wrote:

Code: Select all

			t_Tiles[x, y] = tileRect;
This is C++, correct? This doesn't look right. You probably want t_Tiles[x][y] if this is a 2D array.
That was I was thinking, How did that compile with no errors?
Yeah I'm not sure what I was thinking :roll:

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++;
		}
	}
}
I was having problems because the X and Y were reversed so I just swapped the two for loops and now it works fine like this.
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.

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

Posted: Mon Feb 01, 2010 11:44 am
by RyanPridgeon
LeonBlade wrote: Next I plan on making some sort of level editor... should I do this using SDL to render the graphics?
Unless you plan on doing alot of pixel manipulation you may want to look into using OpenGL :)

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

Posted: Mon Feb 01, 2010 12:52 pm
by Ginto8
RyanPridgeon wrote:
LeonBlade wrote: Next I plan on making some sort of level editor... should I do this using SDL to render the graphics?
Unless you plan on doing alot of pixel manipulation you may want to look into using OpenGL :)
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)

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

Posted: Mon Feb 01, 2010 1:27 pm
by LeonBlade
RyanPridgeon wrote:
LeonBlade wrote: Next I plan on making some sort of level editor... should I do this using SDL to render the graphics?
Unless you plan on doing alot of pixel manipulation you may want to look into using OpenGL :)
Hmm, well that doesn't sound too good :(
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>
I figured I could use XML to easily structure the file, but when it came down to parsing it, I would be left with this for example:

Code: Select all

0,0,0,0
0,0,1,0
2,0,2,1
And I would just remove all spaces and I could delimit each line with the line-break character.
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
Which would load a 12x3 tiled map full of all tile 0.

Thanks, and hope to hear your input.

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

Posted: Mon Feb 01, 2010 1:59 pm
by K-Bal
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.

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

Posted: Mon Feb 01, 2010 2:50 pm
by Bakkon
RyanPridgeon wrote: Unless you plan on doing alot of pixel manipulation you may want to look into using OpenGL :)
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.
K-Bal wrote: - Don't limit one map to one tileset. You will end up merging images with something like GIMP, unneccessary extra work.
This is a big one IMO. Just have a tile know which spritesheet to use and then the (x,y) block on that sheet.

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

Posted: Mon Feb 01, 2010 3:39 pm
by LeonBlade
Thank you for the suggestions and improvements.
Once I get to work again, I will implement them.

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

Posted: Mon Feb 01, 2010 5:26 pm
by RyanPridgeon
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 :)

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

Posted: Wed Feb 03, 2010 8:45 pm
by eatcomics
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