Frame rate within a frame rate - Better! - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Utilities (https://staging.qb64phoenix.com/forumdisplay.php?fid=8) +---- Thread: Frame rate within a frame rate - Better! (/showthread.php?tid=1435) |
Frame rate within a frame rate - Better! - TerryRitchie - 02-01-2023 A while back I started a discussion on determining frames rates within other frame rates here: https://staging.qb64phoenix.com/showthread.php?tid=1107 The method I came up with for Pac-Man I thought was quite clever. Turns out not so much. Not only is it ugly (string manipulation) but it only worked for one global frame rate. If another global rate was needed the entire set of strings need to be recreated. Ugly, yes, but functional for the game. I have a project I'm working on that needs the ability to have the global FPS change at any time but still have the ability to know when lower frame rates change within that global frame rate, in real time. So, while investigating (and pulling my hair out for an hour) my son walks up and asks, "What ya doing?" I explain to him what I'm trying to accomplish. He listens, says "huh?", then wanders off. Ten minutes later he came back with a super simple solution! (He's autistic on the Asperger's scale and his mind amazes me) The code below contains a function called FrameChange that can report lower frame rates within a global frame in real time, even if the global frame rate changes. Now I have to go back to my Pac-Man code and put this in place of my ugly solution. His solution is so freaking simple. Code: (Select All) ' A better frame counter RE: Frame rate within a frame rate - Better! - mnrvovrfc - 02-01-2023 Albert Einstein was like "Huh?" many times while he had to go to school too. It indicates a genius hears something for the first time but then quickly figures it out afterward. This is an interesting concept going on in what seems to be a simple arcade game quite easy to program, given the development tools available. I guess with eg. Lua Love frame rate for anything is nothing to worry about as long as "critical section" interprets the fewest lines possible. A game like Pac-Man should have been doable on QB64 SDL, this is what I believed when I started using it. Then I figured out what was wrong when I attempted to create a simple music sequencer. Trying to play more than one wave file at a time was all over the place, and I couldn't get _SNDPLAY to cooperate on tight timing. Then I created a "vector synthesizer" which sounded off when a "joystick" hit at least one of the corners. It was messy having to use _SNDRAW to produce the sound and there was serious latency with the visuals. I wanted it to be like Logo but with sound. Now with the hotrod GPU's and this programming system's ability to use hardware pages, someone might be able to do that one-man MMORPG after all... |