Re: Blade Brothers Engine: Creating my first 2D Game Engine
Posted: Sun Jan 31, 2010 8:52 pm
who's the cute gurl is all i really wanna know.
The Next Generation of 2D Roleplaying Games
http://elysianshadows.com/phpBB3/
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.
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.
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;
}
}
}
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;
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;
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;
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++;
}
}
}
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?
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?
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?
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
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
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.