Page 1 of 2

Shadows of Power - 2d RPG made in SDL & C++

Posted: Tue Jan 01, 2013 6:25 pm
by lalacomun
Hello to all of you guys! This is my first SERIOUS attempt to make a 2d rpg game made in SDL and C++ :) i started working on the engine 2 weeks ago and 3 weeks on the level editor.

A video showing both Engine and Level editor!



Engine:

The engine currently supports:
- Tile maps with multiple layers
- Basic physics(Collision, Acceleration etc..)
- Players lol
- Npc's
- Camera system
- Simple AI (for the npc's)
- Lua scripting for the level and objects
- Objects

Some Images!

Image

Image

All the objects have "attached" a lua script, so when the player use them it runs the current object script, im working on Separating axis theorem for collision as well :mrgreen:

Level Editor:

The level editor has a simple GUI made in sdl, im going to be using Qt in the future :)
it supports 2 layers but im working on a 3'rd one now!

You can download a simple demo of the engine so far!||

http://www.mediafire.com/?doscy6wryz8gzdf


Hope you guys enjoy and i would like to hear your thought about the engine and the level editor, if you have any suggetion or question feel free to ask! ;)

And thanks to all the ES team, they got me into programming, and are my source of inspiration to continue working on my game ;)

Re: Shadows of Power - 2d RPG made in SDL & C++

Posted: Wed Jan 02, 2013 10:19 am
by dandymcgee
Great work man. Though tech demos and engines are cool I'd love to see this turn into a playable game.
I hope you find the motivation and desire to bring it to something you can call a final product.

Re: Shadows of Power - 2d RPG made in SDL & C++

Posted: Wed Jan 02, 2013 10:57 am
by lalacomun
dandymcgee wrote:Great work man. Though tech demos and engines are cool I'd love to see this turn into a playable game.
I hope you find the motivation and desire to bring it to something you can call a final product.
Yes, i would love that to, thats actually the most difficult part :| the demo was only showing some of the engine functionality, but my new plan is to release a "game" demo, just 1 - 2 quest's to see how the engine works on an actual game :)

Re: Shadows of Power - 2d RPG made in SDL & C++

Posted: Wed Jan 02, 2013 12:10 pm
by Falco Girgis
Looks great, dude!
lalacomun wrote:All the objects have "attached" a lua script, so when the player use them it runs the current object script, im working on Separating axis theorem for collision as well
Out of curiosity, how do you plan to render oriented objects? SDL's rendering is software-based, so you don't have GPU acceleration to rotate your images. There are software-based rotation and scaling algorithms for SDL, but they are going to be extremely slow and CPU heavy.

Your best bet is really to move to OpenGL if you plan to start transforming objects like that.

Re: Shadows of Power - 2d RPG made in SDL & C++

Posted: Wed Jan 02, 2013 12:34 pm
by lalacomun
Falco Girgis wrote:Looks great, dude!
lalacomun wrote:All the objects have "attached" a lua script, so when the player use them it runs the current object script, im working on Separating axis theorem for collision as well
Out of curiosity, how do you plan to render oriented objects? SDL's rendering is software-based, so you don't have GPU acceleration to rotate your images. There are software-based rotation and scaling algorithms for SDL, but they are going to be extremely slow and CPU heavy.

Your best bet is really to move to OpenGL if you plan to start transforming objects like that.
I was planning on using SDL_gfx, that allows me to rotate and scale surfaces, but yes, is slow as hell, so i think im gonna be using OpenGL :) and thanks for the feedback!

Re: Shadows of Power - 2d RPG made in SDL & C++

Posted: Wed Jan 02, 2013 3:43 pm
by DistortedLance
SDL_gfx is indeed incredibly slow, and with SDL 1.2 (which I see you're using), only multiples of 90 degree rotations have acceptable performance.

SDL 2.0 has hardware accelerated surfaces, though (called SDL_Texture; SDL_SWSURFACE, SDL_HWSURFACE, etc. are deprecated, I believe). SDL_Textures can be blit with a rotation applied to them, or just rendered normally.
//Renders a hardware-accelerated texture to the destination renderer
int SDL_RenderCopy(SDL_Renderer* renderer, SDL_Texture* texture,
     const SDL_Rect* srcrect, const SDL_Rect* dstrect);

//Renders a hardware-accelerated texture with optional rotation and/or flipping applied
int SDL_RenderCopyEx(SDL_Renderer* renderer, SDL_Texture* texture,
     const SDL_Rect* srcrect, const SDL_Rect* dstrect,
     const double angle, const SDL_Point* center,
     const SDL_RendererFlip flip);
It's not too different from SDL 1.2, with the main differences being that you now have SDL_Window and SDL_Renderer instead of something like SDL_Surface* screen = SDL_SetVideoMode() (which is also deprecated).
SDL_Window* window = SDL_CreateWindow("My Game", 0, 0, 640, 480, SDL_WINDOW_SHOWN);
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);

SDL_Surface* surface = IMG_Load("MyLovelyImage.png");
SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surface);
SDL_FreeSurface(surface);

SDL_Point center = {16, 16};
SDL_RenderCopyEx(renderer, texture, 0, 0, 45, &center, SDL_FLIP_HORIZONTAL);
SDL_RenderPresent(renderer);
Considering SDL_Textures are solely primarily (they might exist outside of hardware memory if you're out of it) hardware textures, I would imagine that this is a hardware-accelerated process and wouldn't be as painfully slow as SDL_gfx. I haven't run any tests to see if it's significantly faster or close enough to OpenGL (I'm too lazy to compile the latest version of SDL_image and can't run OpenGL. Go me), although you might find this to be acceptable compared to switching completely to OpenGL rendering. It's another option if your hardware can't handle the newer versions of OpenGL, at least (Intel, you suck).

Re: Shadows of Power - 2d RPG made in SDL & C++

Posted: Wed Jan 02, 2013 4:35 pm
by Falco Girgis
I would imagine that should probably be pretty fast. Do they not also have a way to scale it?

Re: Shadows of Power - 2d RPG made in SDL & C++

Posted: Wed Jan 02, 2013 4:55 pm
by DistortedLance
Scaling is actually done automatically. The dimensions of the destination rect are used to scale. If you have a 32x32 image with a destination rect of (0, 0, 320, 32), the image will be stretched by a factor of 10 horizontally. This occurs before any rotation/flipping, so if you specify a rotation and a destination rect, you see the scaled THEN rotated image. It's still developmental, but it's pretty neat stuff nonetheless.

EDIT: A quick test using some random wallpapers I have showed that flipping and rotating are pretty much instantaneous (software-rotating the same images took at least 2 seconds before the image was finished rotating/flipping).

Re: Shadows of Power - 2d RPG made in SDL & C++

Posted: Wed Jan 02, 2013 5:37 pm
by lalacomun
DistortedLance wrote:Scaling is actually done automatically. The dimensions of the destination rect are used to scale. If you have a 32x32 image with a destination rect of (0, 0, 320, 32), the image will be stretched by a factor of 10 horizontally. This occurs before any rotation/flipping, so if you specify a rotation and a destination rect, you see the scaled THEN rotated image. It's still developmental, but it's pretty neat stuff nonetheless.

EDIT: A quick test using some random wallpapers I have showed that flipping and rotating are pretty much instantaneous (software-rotating the same images took at least 2 seconds before the image was finished rotating/flipping).
I think i will give SDL 2.0 a try, are the bin files available?? i only see the merccurial repository aveilable :|

Re: Shadows of Power - 2d RPG made in SDL & C++

Posted: Wed Jan 02, 2013 6:42 pm
by DistortedLance
They have the latest versions of the SDL source in a .zip file on the website. There aren't any pre-compiled files available, but they included the project files for Visual Studio, XCode, etc. If you aren't using Visual Studio...DOO ED :P To build, I literally just had to open up their solution/project files and hit Build. They don't have SDL 2.0 versions for SDL_image, SDL_ttf, etc. available as archives, so you need to clone their Mercurial repository if you want to use those. I could also send you compiled libraries for Windows if you can't get things to work.

Anyway, the game's looking nice. Are you going for a Final Fantasy style game? ^_^ ^_^ ^_^

Re: Shadows of Power - 2d RPG made in SDL & C++

Posted: Wed Jan 02, 2013 6:49 pm
by lalacomun
DistortedLance wrote:They have the latest versions of the SDL source in a .zip file on the website. There aren't any pre-compiled files available, but they included the project files for Visual Studio, XCode, etc. If you aren't using Visual Studio...DOO ED :P To build, I literally just had to open up their solution/project files and hit Build. They don't have SDL 2.0 versions for SDL_image, SDL_ttf, etc. available as archives, so you need to clone their Mercurial repository if you want to use those. I could also send you compiled libraries for Windows if you can't get things to work.

Anyway, the game's looking nice. Are you going for a Final Fantasy style game? ^_^ ^_^ ^_^
Thanks! ;) , actually i want the game to be a bit more like Chrono trigger gameplay and Secret of mana combat system, you know a bit more "dynamic" 8-)

Re: Shadows of Power - 2d RPG made in SDL & C++

Posted: Tue Jan 08, 2013 11:08 am
by bbguimaraes
Thought I'd make a developer happy today: your game runs on linux/wine! Screenshot attached.

Oh, and I really laughed when I saw Luigi didn't animate when walking up or down. I remember I did the same thing back when I was first messing with movement animations.

Keep up the good work!

Re: Shadows of Power - 2d RPG made in SDL & C++

Posted: Tue Jan 08, 2013 2:46 pm
by lalacomun
bbguimaraes wrote:Thought I'd make a developer happy today: your game runs on linux/wine! Screenshot attached.

Oh, and I really laughed when I saw Luigi didn't animate when walking up or down. I remember I did the same thing back when I was first messing with movement animations.

Keep up the good work!
Holy Shit! Thanks! you just made my day! :mrgreen: :mrgreen:

Re: Shadows of Power - 2d RPG made in SDL & C++

Posted: Mon Mar 11, 2013 7:22 pm
by lalacomun
Well, this is the first update of the game! and no, the project is not dead, im just to lazy to do a vid and update the post, that actual content of the vid was made about a month ago :lol: im working on the battle system and the quest system now so i can have a playable rpg demo someday soon! you will see all that in the vid.

Things implemented on the vid:

- OpenGL rendering!! :mrgreen:
- Improved items (exmine them)
- Added a health and a stamina bar
- Added an npc dialogue box
- Fading text effect when talking to an npc

Thing im working on:

- Battle system
- Quest system
- DC port, its almost done, im working on the input for the controller now
- Inventory system :p
- Separating axis theorem for rotated textures collision

The video:



Some images:

Image

Image

Well, thats it, what do you guys think?? please feel free to criticize!

Re: Shadows of Power - 2d RPG made in SDL & C++

Posted: Tue Mar 12, 2013 5:26 am
by bbguimaraes
Looking nice, specially the transparent menus (programmer's only know how much you struggle to get it right the first time). If I would suggest something: a little more contrast between the text and the text box and aligning the bars with the text box. Otherwise, good job!