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

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

LeonBlade wrote:
MrDeathNote wrote:
LeonBlade wrote: Oh, and I want to use ColorKey to set a certain color to be transparent... except... I can't get that to work...
So, I'm just using a regular PNG with transparency instead :roll:
What code where you using for the ColorKey?
I just was about to get you or someone else to help me out, but I got it working.
Only problem is, I have to use BMP files in order for it to work right... what the fuck is this shit?
You're better off just using a regular PNG with transparencies anyway. In the hardware accelerated world (OpenGL), you never mask colors. You just use textures that have transparency. It's less of a pain in the ass in the long run.
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 »

GyroVorbis wrote:
LeonBlade wrote:
MrDeathNote wrote:
LeonBlade wrote: Oh, and I want to use ColorKey to set a certain color to be transparent... except... I can't get that to work...
So, I'm just using a regular PNG with transparency instead :roll:
What code where you using for the ColorKey?
I just was about to get you or someone else to help me out, but I got it working.
Only problem is, I have to use BMP files in order for it to work right... what the fuck is this shit?
You're better off just using a regular PNG with transparencies anyway. In the hardware accelerated world (OpenGL), you never mask colors. You just use textures that have transparency. It's less of a pain in the ass in the long run.
/agreed
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 »

GyroVorbis wrote:
LeonBlade wrote:
MrDeathNote wrote:
LeonBlade wrote: Oh, and I want to use ColorKey to set a certain color to be transparent... except... I can't get that to work...
So, I'm just using a regular PNG with transparency instead :roll:
What code where you using for the ColorKey?
I just was about to get you or someone else to help me out, but I got it working.
Only problem is, I have to use BMP files in order for it to work right... what the fuck is this shit?
You're better off just using a regular PNG with transparencies anyway. In the hardware accelerated world (OpenGL), you never mask colors. You just use textures that have transparency. It's less of a pain in the ass in the long run.
Very true, thats exactly what i'm doing in my rpg engine with opengl. I looked at scanning through each pixel and adding an extra channel for alpha, but holy fuck was it a pain in the ass lol.
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 »

Alright, thank you everyone for your responses.
I'll continue to use transparent PNGs instead of ColorKey.

The only thing is, when I use the map editor, and I want to use a transparent tile on ground, it shows up as transparent, but when you click, it makes it black (the screen color).
What should I do for this? Should I just make a seperate black tile or what?
There's no place like ~/
quickshot14
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 31
Joined: Thu Mar 11, 2010 2:51 am
Current Project: VB.NET Direct X Game Engine (Working Title)
Favorite Gaming Platforms: PC
Programming Language of Choice: VB.NET (for now)
Location: Nebreska, USA
Contact:

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

Post by quickshot14 »

GyroVorbis wrote:
LeonBlade wrote:
MrDeathNote wrote:
LeonBlade wrote: Oh, and I want to use ColorKey to set a certain color to be transparent... except... I can't get that to work...
So, I'm just using a regular PNG with transparency instead :roll:
What code where you using for the ColorKey?
I just was about to get you or someone else to help me out, but I got it working.
Only problem is, I have to use BMP files in order for it to work right... what the fuck is this shit?
You're better off just using a regular PNG with transparencies anyway. In the hardware accelerated world (OpenGL), you never mask colors. You just use textures that have transparency. It's less of a pain in the ass in the long run.
Falco just nailed it its much simpler easier and of course standard pretty much to use in my vb.net project i'm using pngs for there transparencies and it really is easy. And definlty saves times and issues. You have a good questions and granted i'm not this far on the step yet (working on a tile editor) i belive having a seprate black tile is something thats normal or basic, if my memory servers i belive even mappy does this. So that is a possiblity unless there is a better way of doing or handling it witch more experinced people here may have and idea on.
Amatuer Game Design/Programmer & College Student (Kaplan University: Associate of Applied Sceince in Information Technology: Application Devleopment)
Know Programming Languages & Considered Levels Of Programming in them: Basic(DOS) - 10%, VB(Legacy) - 15%, VB.NET - 55%, C/C++ - 1%, C# - 1%, LUA - 25%, Java - 0%, COBOL - 0%
________________________________________________
Current Game Development/Programming Projects:
VB.NET Direct X Game Engine (Working Title) - (Lanugage: VB.NET | Released Type/Status: Open Soruce / Unreleased)
________________________________________________
Quicks14Blog (My Gaming Related Blog Page) - My Youtube Channel Page
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 »

Image
This is what the editor looks like atm... shitty graphics I know (I can't sprite :lol:)
I'm gonna add in the side panel to load all the sprites and UI to scroll through the full tilesheet.
Then I'm going to add scrolling for the map...
Then I'm going to make the buttons do shit at the top there ;)
Finish up the UI classes to handle some dialogs for New/Open/Save and some other shit as well.

So that's my plan of attack for the next few days or so.
There's no place like ~/
quickshot14
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 31
Joined: Thu Mar 11, 2010 2:51 am
Current Project: VB.NET Direct X Game Engine (Working Title)
Favorite Gaming Platforms: PC
Programming Language of Choice: VB.NET (for now)
Location: Nebreska, USA
Contact:

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

Post by quickshot14 »

LeonBlade wrote:Image
This is what the editor looks like atm... shitty graphics I know (I can't sprite :lol:)
I'm gonna add in the side panel to load all the sprites and UI to scroll through the full tilesheet.
Then I'm going to add scrolling for the map...
Then I'm going to make the buttons do shit at the top there ;)
Finish up the UI classes to handle some dialogs for New/Open/Save and some other shit as well.

So that's my plan of attack for the next few days or so.
Awsome man! Looks like a good start and a plan of attack, things will probley change but hey that happens no matter what its progress and thats always encourging, looks good :)
Amatuer Game Design/Programmer & College Student (Kaplan University: Associate of Applied Sceince in Information Technology: Application Devleopment)
Know Programming Languages & Considered Levels Of Programming in them: Basic(DOS) - 10%, VB(Legacy) - 15%, VB.NET - 55%, C/C++ - 1%, C# - 1%, LUA - 25%, Java - 0%, COBOL - 0%
________________________________________________
Current Game Development/Programming Projects:
VB.NET Direct X Game Engine (Working Title) - (Lanugage: VB.NET | Released Type/Status: Open Soruce / Unreleased)
________________________________________________
Quicks14Blog (My Gaming Related Blog Page) - My Youtube Channel Page
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 just realized that scrolling my map is going to be a bitch...
Everything is loaded onto a single dimension LOL.
So here's how I'm going to have to do this if I continue to just load tiles in on a single dimension.

Lets say I'm 3 tiles over...
I have to start 3 tiles over so 3 times the tiles high and then get all tiles from my position over and BLAH BLAH
I DONT EVEN WANNA WRITE IT OUT IM BUSY

So yeah... I'll have to reconfigure that unless I wanna do extra work :lol:
There's no place like ~/
User avatar
RyanPridgeon
Chaos Rift Maniac
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

Post by RyanPridgeon »

Aye, you'll wanna be doing something which only renders the tile in view of the camera. Something like

Code: Select all

for (i = cameraX / tileWidth; i < (cameraX + screenW) / tileWidth; i++){
 for (j = cameraY / tileHeight; j < (cameraY + screenH) / tileHeight; j++){
  renderTile(tiles[i][j], i * tileWidth - cameraX, j * tileHeight - cameraY)
 }
}
Ryan Pridgeon
C, C++, C#, Java, ActionScript 3, HaXe, PHP, VB.Net, Pascal
Music | Blog
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 »

RyanPridgeon wrote:Aye, you'll wanna be doing something which only renders the tile in view of the camera. Something like

Code: Select all

for (i = cameraX / tileWidth; i < (cameraX + screenW) / tileWidth; i++){
 for (j = cameraY / tileHeight; j < (cameraY + screenH) / tileHeight; j++){
  renderTile(tiles[i][j], i * tileWidth - cameraX, j * tileHeight - cameraY)
 }
}
Yea this is pretty much what your gonna have to do, it works well and i've used it myself.
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 »

MrDeathNote wrote:
RyanPridgeon wrote:Aye, you'll wanna be doing something which only renders the tile in view of the camera. Something like

Code: Select all

for (i = cameraX / tileWidth; i < (cameraX + screenW) / tileWidth; i++){
 for (j = cameraY / tileHeight; j < (cameraY + screenH) / tileHeight; j++){
  renderTile(tiles[i][j], i * tileWidth - cameraX, j * tileHeight - cameraY)
 }
}
Yea this is pretty much what your gonna have to do, it works well and i've used it myself.
Thanks guys, I could of planned it out like I normally do when I write the topic concerning my issue.
However, I was under a lot of shit atm and VERY tired :lol: thank you for your help :)
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'm thinking ahead at the moment, but I want to obviously use Lua as my scripting language in my engine.
What I want to do, is have Events essentially on my map.

You can create either: NPCs, Signs and Scripts.
Each event ties back to a script, I want to have my events in my map file look like this...

Code: Select all

00 00 06 07 03 01 00 01
Which is first the ID of the event so I can reference it from other events.
Then Event Type which is either 00, 01 or 02.
Then X and Y for position on the map.
Then there's Sprite which will be the sprite ID of the event or 00 if there is no sprite.
Then the Face of the sprite. This value is either 00, 01, 02, or 03 (4 faces). The value is used for NPCs to chose what way they face.
Then Moving is just a 00 or 01 value. Either they're not moving or they are. The moving is just a random movement.
The last is Script and that is the script ID that the event is associated with.

Now, there are two issues I need to address.
First off, is how I'm going to compile a list of Sprites to associate with the Sprite ID.

Sprites will be stored in a sprite folder.
There will be a tool created that will allow you to add sprites to a list and save out a binary file that will store the name of the sprite texture file and the ID associated with it. The byte FF will signify the end of a filename string.
Here is an example of 3 sprites (in readable form)

Code: Select all

01 "hero.png"
02 "evil_bad_guy.png"
03 "warrior3.png"
Each sprite file is going to be a different length, so instead of just wasting space by creating a static size, I will just use the byte FF to separate the end of the texture.

Here is that same list in hex:

Code: Select all

01 68 65 72 6f 2e 70 6e 67 FF
02 65 76 69 6c 5f 62 61 64 5f 67 75 79 2e 70 6e 67 FF
03 77 61 72 72 69 6f 72 33 2e 70 6e 67 FF
In the actual file, they wouldn't be split up on lines (obviously) but I did this so you could see the break more easily.
So when the engine starts it parses the sprite binary file and adds the sprite textures to the Sprite Texture Manager.

Same goes with the scripts as well, those can be taken care of with a script manager as well.
A separate manager class can be created to handle loading those in, however, I'm not entirely sure how to link Lua up to C++ yet so I'm not sure what I'll do until I read up some more.

But yeah, figured I'd get that down so I don't forget later :lol:
Let me know what you think.

ALSO! The editor in SDL is kind of coming along... not really though.
I'm currently working on it though... so I'll let you know how that goes.
I think I'm looking too much into the big picture.
I'll just focus on the UI alone first then I'll worry about the entire map editor later.

So far, Buttons have been created... that's it... lol.
Well that is all.
There's no place like ~/
Live-Dimension
Chaos Rift Junior
Chaos Rift Junior
Posts: 345
Joined: Tue Jan 12, 2010 7:23 pm
Favorite Gaming Platforms: PC - Windows 7
Programming Language of Choice: c++;haxe
Contact:

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

Post by Live-Dimension »

Each sprite file is going to be a different length, so instead of just wasting space by creating a static size, I will just use the byte FF to separate the end of the texture.

Here is that same list in hex:

Code: Select all

01 68 65 72 6f 2e 70 6e 67 FF
02 65 76 69 6c 5f 62 61 64 5f 67 75 79 2e 70 6e 67 FF
03 77 61 72 72 69 6f 72 33 2e 70 6e 67 FF
FF is a bad choice. I don't know how moddable you plan to make a game, but FF is an allowed character in the windows file naming system, so as such, can be input as a file name. I do know that some characters are banned for file/folder names, such as the question mark "?" (3F). I don't know if it's also a banned name on unix systems. If it is, then it's a better way to differ between files then FF, which is ÿ. Thankfully, I don't thing that unicode is apart of any file/folder naming system, so you only have to deal with ASCII, but I could be totally wrong.

I do like the idea of your sprite management system, linking sprites directly to ID's.
Each event ties back to a script, I want to have my events in my map file look like this...

Code: Select all

00 00 06 07 03 01 00 01
I'm also going to assume that you realise you need more then 8 bytes for what your planning ;) As I'm sure you know, each byte is only capable of 256 unique values. It's just you seem insistent on using a maximum of 256 events, 256 sprites.... upto 256 X/Y positioning.

There's some things about your idea of events that confuse me, so if you don't mind (if more for personal curiosity/learning then anything else)
Which is first the ID of the event so I can reference it from other events.
Then Event Type which is either 00, 01 or 02.
Then X and Y for position on the map.
Then there's Sprite which will be the sprite ID of the event or 00 if there is no sprite.
Then the Face of the sprite. This value is either 00, 01, 02, or 03 (4 faces). The value is used for NPCs to chose what way they face.
Then Moving is just a 00 or 01 value. Either they're not moving or they are. The moving is just a random movement.
The last is Script and that is the script ID that the event is associated with.
Why do you need a sprite/facing/moving for an event? What triggers these events? Other events?
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 »

Hahahaha yeah I wrote this at like wicked early and didn't really think it through :lol:
The basic idea is there though...

Also, an even can be an NPC.
So the sprite/facing/moving is for NPCs.

Like I said, I have no idea what I was thinking about completely haha :lol:
I was basing it off of something else, I think I'll create NPCs and other Events separate...

Also, for the sprite manager, what should I use to break the different IDs apart... if at all...
Should I even MAKE a binary file for sprites?
There's no place like ~/
Live-Dimension
Chaos Rift Junior
Chaos Rift Junior
Posts: 345
Joined: Tue Jan 12, 2010 7:23 pm
Favorite Gaming Platforms: PC - Windows 7
Programming Language of Choice: c++;haxe
Contact:

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

Post by Live-Dimension »

I don't see the need to. It's easier to mod and mess around with text-based files. I'd probably end up making final archive files to store all the files in, however.
Image
Post Reply