RPGDXThe center of Indie-RPG gaming
Not logged in. [log in] [register]
 
The most bizzare problem I've ever incountered
 
Post new topic Reply to topic  
View previous topic - View next topic  
Author Message
Gardon
Scholar


Joined: 05 Feb 2006
Posts: 157

PostPosted: Sat Feb 11, 2006 10:57 pm    Post subject: The most bizzare problem I've ever incountered [quote]

Please, I beg of you, download my project and tell me what's wrong. It's really dumb, and I know what the problem is, but don't know why it's happening.

If you look in the player.cpp file, towards the bottom, you see two different states: HandleWalkState and HandlePauseState.

Can someone tell me why I have to do the HandlePauseState the way I do, but not the HandleWalkState?

I can simply reference the bitmaps with the m_currentDirection variable via HandleWalkState, but I have to explicitly load the specified bitmap from the HandlePauseState.

Why does this happen?

It's making me so frustrated on why it won't work, and I can't take it anymore!

I also found out what's causing the memory expansion (I think). Whenever I move the mouse around in my game it slows everything down. I dont' know why, but it does. I have to figure out a way to not have my mouse ruin everything else.

please help me, the link is here

Jason
Back to top  
RuneLancer
Mage


Joined: 17 Jun 2005
Posts: 441

PostPosted: Sat Feb 11, 2006 11:12 pm    Post subject: [quote]

You should comment your source. Trust me, you'll hate yourself if you don't do it a few months down the line...

What happens when you treat HandlePauseState like HandleWalkState?
_________________
Endless Saga
An OpenGL RPG in the making. Now with new hosting!

Back to top  
Gardon
Scholar


Joined: 05 Feb 2006
Posts: 157

PostPosted: Sat Feb 11, 2006 11:32 pm    Post subject: [quote]

It compiles but shows that windows message a second after execution, and I'm unable to proceed.

Basically my analogy of it is:

2 + 3 = 5, so why the fuck doesn't 3 + 2 = 5?

Oh, and I junked my project. I do that a lot. Even though I wasted about 10 hours, I feel refreshed enough to make it better next time around.

The only problem I'm having now is mouse movement. SDL polls for events, which includes clicking and moving the mouse. I want to keep it for later on during development, but I don't know how to have it stop taking up so much time and memory. If I move the mouse in circles really fast it totally lags my game, delaying my character's actions and such

This is where windows would come in handy, where I could declare another winProc for the mouse function. Too bad it's overly confusing and I'm sticking with SDL.

Jason
Back to top  
RuneLancer
Mage


Joined: 17 Jun 2005
Posts: 441

PostPosted: Sat Feb 11, 2006 11:38 pm    Post subject: [quote]

Which message comes up? I'm unable to fire up my compiler at the moment so I'm just looking at the source.

Why not simply handle the mouse message but do nothing with it? I haven't touched SDL in a while, but I'd guess the message queue is being stuffed up with WM_MOUSExyz messages because nothing handles them?
_________________
Endless Saga
An OpenGL RPG in the making. Now with new hosting!

Back to top  
Rainer Deyke
Demon Hunter


Joined: 05 Jun 2002
Posts: 672

PostPosted: Sun Feb 12, 2006 12:33 am    Post subject: [quote]

The problem is that Input::m_currentDirection is initialized as None, which is eventually passed to Player::m_currentDirection, causing an out-of-bounds array access. When you start moving, Input::m_currentDirection becomes a real direction and stays that way, so Player::HandleWalkState is unaffected.
Back to top  
Gardon
Scholar


Joined: 05 Feb 2006
Posts: 157

PostPosted: Sun Feb 12, 2006 1:01 am    Post subject: [quote]

Thank you rainer, I spent so much time trying to figure out what the hell was going on. I appreciate it.

And I don't know what's up with the mouse. I'll try to figure it out.

Jason
Back to top  
zenogais
Slightly Deformed Faerie Princess


Joined: 10 Jan 2006
Posts: 34

PostPosted: Sun Feb 12, 2006 2:01 am    Post subject: [quote]

Gardon: I think I can help you a bit, I've been working on a game engine for a bit, and I've actually used some of the components from your engine that I liked. My input system is fairly different, but it does not have the same mouse problem, and also my image system caches repeatedly loaded graphics, something you might find useful for a map system. It's fairly ugly right now, as its still heavily in development, but it should seem somewhat familiar.

You can find my sources here: agEngine
Back to top  
Gardon
Scholar


Joined: 05 Feb 2006
Posts: 157

PostPosted: Sun Feb 12, 2006 5:41 am    Post subject: [quote]

Yes thank you. I saw how you polled events twice, once for mouse and once for input (I think... it's getting late :) )

I basically polled for events twice (I added a second SDL_PollEvent() function to my HandleInput() function), which cleared the problem up right away.

By the way, do you mind if I ask why everything is prefixed with "ag".

Sorry, I have to know, it was bugging the hell outta me.

Thanks again,

Jason
Back to top  
zenogais
Slightly Deformed Faerie Princess


Joined: 10 Jan 2006
Posts: 34

PostPosted: Sun Feb 12, 2006 6:09 am    Post subject: [quote]

Gardon: No problem, the reason I prefixed everything with ag is because the engine is for a project called Afterglow.
Back to top  
Gardon
Scholar


Joined: 05 Feb 2006
Posts: 157

PostPosted: Sun Feb 12, 2006 6:33 am    Post subject: [quote]

I got a couple more questions for you.

What's the difference between 16, 24, and 32 bit tiles? Whenever I save bitmaps in photoshop it asks me which one I want, and I've previewed all 3 and they all look the same. Is there a difference later on down the road?

My guess is that since it's such primitive coloring 16 bits is covering it.

My next question is about layering. Wich my current engine, the maps, players, entities, etc. can render themselves, so if I call the player->update function after the map->update function, the player gets drawn on top of the tiles. However, if I want to have trees and background images, which way should I go about drawing them after the player?

See you in the morning,

Jason
Back to top  
RuneLancer
Mage


Joined: 17 Jun 2005
Posts: 441

PostPosted: Sun Feb 12, 2006 7:46 am    Post subject: [quote]

Bit depth indicates how many bits are used to represent your image. 16bpp uses 16 bits (2 bytes) per pixel. 24bit is full-color, but 32bit also allows the use of an alpha channel with formats that support it.

If you only need 16bpp, use it. In fact, if you only need 8bpp, use it. A 512x512 image is 256k at 8bpp, 512k at 16bpp, 768k at 24bpp, and 1 meg at 32bpp.

There are multiple ways to handle layering. The most common approach is to create two layers: an object layer and a foreground layer. The object layer will have the tree's trunk (ie, the stuff the player will overlap) and the foreground layer will have the leaves and branches (ie, stuff that goes over the player.) Then you render the ground, objects, sprites, and finally foreground.



(The last screenshot is all three layers with the walkthrough data represented visually.)

Free cookie to RPGDX members who recognize this map. ;)
_________________
Endless Saga
An OpenGL RPG in the making. Now with new hosting!

Back to top  
LeoDraco
Demon Hunter


Joined: 24 Jun 2003
Posts: 584
Location: Riverside, South Cali

PostPosted: Sun Feb 12, 2006 7:53 am    Post subject: [quote]

Gardon wrote:
What's the difference between 16, 24, and 32 bit tiles? Whenever I save bitmaps in photoshop it asks me which one I want, and I've previewed all 3 and they all look the same. Is there a difference later on down the road?


Those numbers signify the bit depth of the digital image, and, more specifically, denote the total number of bits needed to store a single pixel color. So, each depth requires more space to store the same information, but you get more with the extra space: moving from 16 to either 24 or 32, you move from 65,536 possible colors to 16,777,216 possible colors; 32 bit depth is the same as 24 (in that each RGB component gets alloted 8 pixels), but it adds an 8 bit alpha channel, which is most often utilized to denote the translucency of the color. (Although, this really does not introduce any "new" colors, as it is just another way to index into colors in the 24 bit depth. Also, given that the cardinality of the set of colors the eye can differentiate is less than the number of colors representable in truecolor, that space is slightly wasted.)

Quote:
My next question is about layering. Wich my current engine, the maps, players, entities, etc. can render themselves, so if I call the player->update function after the map->update function, the player gets drawn on top of the tiles. However, if I want to have trees and background images, which way should I go about drawing them after the player?


This is why I like 3D engines: in 3D systems, you have something called a depth buffer, which automagically sorts items within a scene based upon how far the object is away from the camera, usually using the axis most orthogonal to the direction of the camera. (Which, for most texts, degenerates to a "z"-order, although that is not necessarily the axis that will be used.)

So! To tie that in to your question, you could look into performing some sort of depth ordering of your objects; most often, I have seen this done by sorting the object's y-component for top-down games. There is also something known as the Painter's Algorithm, which may be useful.
_________________
"...LeoDraco is a pompus git..." -- Mandrake
Back to top  
Post new topic Reply to topic Page 1 of 1 All times are GMT
 



Display posts from previous:   
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum