PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Strangest defect in my code

Well, I'm hoping that explaining this anomaly will turn a light on in someone's head. Here's what I see.

Trying to optimize my app, I noticed that I was only getting about 30 FPS (debug build). It is a scrolling tiled map with 1024 tiles each 32x32 and a little player that moves around (no collison detection yet).

One thing I noticed however is that while moving around in the world, my FPS would all of a sudden jump to between 50&60 FPS and stay there.

Running it through the debugger I was able to somewhat track it down. It appears that it happens (ready for this) if I push the D-Pad down (note down as in South but straight down like a button).

In my ButtonUp and ButtonDown handlers, I receive the following:

ButtonDown: code=134
ButtonUp: code=134
ButtonDown: code=13
ButtonUp: code=13

Well, according to the keylist structure, code 13 doesn't exist. But for some reason, something happens and I get the performance that I'm looking for.

Man, this one is boggling the mind. I hope someone can help.
Ok, this one's out of left field (a complete guess which could be utter nonsense).

If your movement is tied the the buttons (i.e. only moving when the ButtonDown is triggered), and the buttons are only triggering at 30Hz, then holding down one button would move at 30Hz.. if it's triggering two buttons you should get 60Hz... = 30Hz for each button.
codepunk · 09 Oct 2002, 19:33 UTC — Thanks anyway
refractor wrote:
Ok, this one's out of left field (a complete guess which could be utter nonsense).

If your movement is tied the the buttons (i.e. only moving when the ButtonDown is triggered), and the buttons are only triggering at 30Hz, then holding down one button would move at 30Hz.. if it's triggering two buttons you should get 60Hz... = 30Hz for each button.


I'm not sure that's the case but I do thank you for brainstorming with me. I haven't looked at it since this post since I'm busy with other stuff. The only thing that would make your argument invalid is that after I press the d-pad the game always runs at the higher framerate regardless if a button is pressed down or not. When I look at it again and have absolutely no idea then I guess my next step would be to post code.

In case anyone is interested, the code is part of a 2d tile based game engine. When running a level, I can get around 60 fps in a world that contains thousands of tiles so I think the performance is looking good. I also have a cool level editor that I'm working on in parallel. My current work is revolving around collision detection.