2D RPG 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

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: Simple 2D RPG Engine

Post by Falco Girgis »

Light-Dark wrote:Basically it's doing a bounding box collision detection between the player and the specified tile, if the player is colliding with the lower tile it shifts the depth value down in lua, however if the player is colliding with the upper tile it shifts the depth value up. To keep from creating unnecessary issues I have the players x and y 'snapped' to multiples of 32x32 so the player won't be colliding with both at the same time. This system serves as a place holder for the moment.
Yeah, that's basically how we're going to handle it. I didn't even realize the player was being snapped to a grid in the video, since motion looked so smooth.

Chrono Trigger's engine calls these "z-transitional" tiles.
Light-Dark wrote:And this is how camera zooming/rotating is currently handled:
void GameSystem::Camera_Transform(const float scale,const float rotation)
{
    UniformScaleVal = scale;
    camera.w = SCREEN_WIDTH * (1/scale);
    camera.h = SCREEN_HEIGHT * (1/scale);
    glScalef(scale,scale,1);
    
    glTranslatef(camera.w/2,camera.h/2,0);
    glRotatef(rotation,0,0,1);
    glTranslatef(-camera.w/2,-camera.h/2,0);
    
}
You have the right basic idea (obviously, or it wouldn't be working as well as it is now). The order of operations is:
1) translate to the center of the screen, so that every transform is now relative to this point.
2) apply the camera's uniform zoom/scale
3) apply the camera's rotation
4) translate back to the camera's world-space coordinates

Actual algorithm used in ES:

Code: Select all

void CameraSystem::PushTransform(void) {
	gyMatPush();
	gyMatTranslate(_scrWidth/2.0f, _scrHeight/2.0f, 0.0f);
	gyMatScale(transform._scale.x, transform._scale.y, 1.0f);
	gyMatRotateZ(transform._orientZ);
	gyMatTranslate(-transform._pos.x, -transform._pos.y, 0.0f);
}
Cheers.
User avatar
Light-Dark
Dreamcast Developer
Dreamcast Developer
Posts: 307
Joined: Sun Mar 13, 2011 7:57 pm
Current Project: 2D RPG & NES Platformer
Favorite Gaming Platforms: NES,SNES,N64,Genesis,Dreamcast,PC,Xbox360
Programming Language of Choice: C/++
Location: Canada

Re: Simple 2D RPG Engine

Post by Light-Dark »

Falco Girgis wrote:You have the right basic idea (obviously, or it wouldn't be working as well as it is now).
Good to know I'm on the right track :)!

Anyways, I've recently begun learning to do some pixel art so I can make placeholder or possibly real assets for the game itself and this is what I have to show for it:
Placeholder.png
Artwork
(112.96 KiB) Not downloaded yet
It's pretty meh right? I'm not that great of an artist :lol:. You'll also notice I've changed the layout around on the editor and added a new depth settings widget for controlling the newfangled depth/elevation system annnd I also changed the style of the UI because why not!
<tpw_rules> LightDark: java is a consequence of inverse moore's law: every 18 months, the average program will be twice as slow. therefore, computers always run at the same percevied speed. java's invention was a monumental step
Image
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: Simple 2D RPG Engine

Post by Falco Girgis »

How does the depth slider work? Do you have to make a selection first, and it is applied to the tile(s) within the selection?
User avatar
Light-Dark
Dreamcast Developer
Dreamcast Developer
Posts: 307
Joined: Sun Mar 13, 2011 7:57 pm
Current Project: 2D RPG & NES Platformer
Favorite Gaming Platforms: NES,SNES,N64,Genesis,Dreamcast,PC,Xbox360
Programming Language of Choice: C/++
Location: Canada

Re: Simple 2D RPG Engine

Post by Light-Dark »

Falco Girgis wrote:How does the depth slider work? Do you have to make a selection first, and it is applied to the tile(s) within the selection?
The depth is applied when you lay a tile with the depth flag turned on(otherwise it's automatically set to 0), the depth slider also controls which elevation of the collision layer you are dealing with/viewing.
<tpw_rules> LightDark: java is a consequence of inverse moore's law: every 18 months, the average program will be twice as slow. therefore, computers always run at the same percevied speed. java's invention was a monumental step
Image
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: Simple 2D RPG Engine

Post by Falco Girgis »

Aaaaah, I gotcha. Nice!

Thought of another question. Is only one of your layers elevatable? If they are both elevatable, does one always have to be above the other one, or can layer 1 technically be levated above layer 2?
User avatar
Light-Dark
Dreamcast Developer
Dreamcast Developer
Posts: 307
Joined: Sun Mar 13, 2011 7:57 pm
Current Project: 2D RPG & NES Platformer
Favorite Gaming Platforms: NES,SNES,N64,Genesis,Dreamcast,PC,Xbox360
Programming Language of Choice: C/++
Location: Canada

Re: Simple 2D RPG Engine

Post by Light-Dark »

Falco Girgis wrote:Aaaaah, I gotcha. Nice!

Thought of another question. Is only one of your layers elevatable? If they are both elevatable, does one always have to be above the other one, or can layer 1 technically be levated above layer 2?
I spent a bit testing that out and it appears that layer 2 will always render above the first layer despite elevation levels.


Also, I thought I should show some footage of the Dreamcast version in action. It's kinda outdated now as I'm still working on getting/making a BBA or coders cable but consider this confirmation that it is indeed happening!

<tpw_rules> LightDark: java is a consequence of inverse moore's law: every 18 months, the average program will be twice as slow. therefore, computers always run at the same percevied speed. java's invention was a monumental step
Image
User avatar
bbguimaraes
Chaos Rift Junior
Chaos Rift Junior
Posts: 294
Joined: Wed Apr 11, 2012 4:34 pm
Programming Language of Choice: c++
Location: Brazil
Contact:

Re: Simple 2D RPG Engine

Post by bbguimaraes »

I smell an instant promotion...
User avatar
Light-Dark
Dreamcast Developer
Dreamcast Developer
Posts: 307
Joined: Sun Mar 13, 2011 7:57 pm
Current Project: 2D RPG & NES Platformer
Favorite Gaming Platforms: NES,SNES,N64,Genesis,Dreamcast,PC,Xbox360
Programming Language of Choice: C/++
Location: Canada

Re: Simple 2D RPG Engine

Post by Light-Dark »

bbguimaraes wrote:I smell an instant promotion...
I guess your prediction was right :lol:, I've always wanted to have a game I made run on a console and now that dream is going to be realized!
<tpw_rules> LightDark: java is a consequence of inverse moore's law: every 18 months, the average program will be twice as slow. therefore, computers always run at the same percevied speed. java's invention was a monumental step
Image
User avatar
Light-Dark
Dreamcast Developer
Dreamcast Developer
Posts: 307
Joined: Sun Mar 13, 2011 7:57 pm
Current Project: 2D RPG & NES Platformer
Favorite Gaming Platforms: NES,SNES,N64,Genesis,Dreamcast,PC,Xbox360
Programming Language of Choice: C/++
Location: Canada

Re: Simple 2D RPG Engine

Post by Light-Dark »

Just a quick update everybody, got a DC SD card adapter ordered! Expect some more Dreamcast in future updates/videos!

EDIT:

Adding on to this update, I updated KOS and the Dc tool-chain so now everything runs on KOS 2.0.0.
<tpw_rules> LightDark: java is a consequence of inverse moore's law: every 18 months, the average program will be twice as slow. therefore, computers always run at the same percevied speed. java's invention was a monumental step
Image
User avatar
Light-Dark
Dreamcast Developer
Dreamcast Developer
Posts: 307
Joined: Sun Mar 13, 2011 7:57 pm
Current Project: 2D RPG & NES Platformer
Favorite Gaming Platforms: NES,SNES,N64,Genesis,Dreamcast,PC,Xbox360
Programming Language of Choice: C/++
Location: Canada

Re: Simple 2D RPG Engine

Post by Light-Dark »

I'm rewriting it again. Now you might be wondering why I'm deciding to rewrite it in the middle of a rewrite? Well that's because of a few design issues and the annoyance of switching between two different builds of the same thing. To combat these issues I've been working on a library written in C that abstracts the engine away from the PC and Dreamcast, so far I've got the PC version up and running and I'm working on the DC version now. I'm currently working on the Matrix transformations for the Dreamcast and I'm hoping to have basic functionality for both versions of the library working soon. All of this shouldn't be to big of a delay, this is something I feel that overall will be more beneficial to the project. More updates later!
<tpw_rules> LightDark: java is a consequence of inverse moore's law: every 18 months, the average program will be twice as slow. therefore, computers always run at the same percevied speed. java's invention was a monumental step
Image
User avatar
bbguimaraes
Chaos Rift Junior
Chaos Rift Junior
Posts: 294
Joined: Wed Apr 11, 2012 4:34 pm
Programming Language of Choice: c++
Location: Brazil
Contact:

Re: Simple 2D RPG Engine

Post by bbguimaraes »

Light-Dark wrote:Now you might be wondering why I'm deciding to rewrite it in the middle of a rewrite?
Everybody knows time passes more slowly on the inner rewrites.
User avatar
Light-Dark
Dreamcast Developer
Dreamcast Developer
Posts: 307
Joined: Sun Mar 13, 2011 7:57 pm
Current Project: 2D RPG & NES Platformer
Favorite Gaming Platforms: NES,SNES,N64,Genesis,Dreamcast,PC,Xbox360
Programming Language of Choice: C/++
Location: Canada

Re: Simple 2D RPG Engine

Post by Light-Dark »



Got things running on the Dreamcast nicely now as shown in the video ( apologies for the camera-pointed-at-tv method of recording, I long for the days when I had my capture card). I now have a Dreamcast SD Card adapter and that has made testing a lot easier and reliable ( NullDC does not seem to like hardware sprites ).
<tpw_rules> LightDark: java is a consequence of inverse moore's law: every 18 months, the average program will be twice as slow. therefore, computers always run at the same percevied speed. java's invention was a monumental step
Image
User avatar
Light-Dark
Dreamcast Developer
Dreamcast Developer
Posts: 307
Joined: Sun Mar 13, 2011 7:57 pm
Current Project: 2D RPG & NES Platformer
Favorite Gaming Platforms: NES,SNES,N64,Genesis,Dreamcast,PC,Xbox360
Programming Language of Choice: C/++
Location: Canada

Re: Simple 2D RPG Engine

Post by Light-Dark »



Progress Made on top of the rewrite:
- Totally revamped Character system
- Revamped animation system ( way more flexible for character animations)
- New Dialogue/Textbox System ( allows for complex branching conversations)
- Revamped log system ( looks prettier! )
- Optimized rendering routines ( Noticeable performance gain, especially on the dreamcast, runs at 60fps)
<tpw_rules> LightDark: java is a consequence of inverse moore's law: every 18 months, the average program will be twice as slow. therefore, computers always run at the same percevied speed. java's invention was a monumental step
Image
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Simple 2D RPG Engine

Post by dandymcgee »

Wow, didn't know you were still working on this. Nice progress, you should post updates here more often!
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
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: Simple 2D RPG Engine

Post by Falco Girgis »

Glad you're still fighting the good fight! Looks great.
Post Reply