else if( m_bSloMo )
{
int t = ( SDL_GetTicks() - m_iStartTicks - m_iSloMoTicks ) / 4;
return m_iSloMoTicks + t;
}
I'm trying to implement slow-mo...
So, I've got an vertically scrolling shooter in SDL (original, I know), and I'm looking to add a slo-mo bullet time type of effect.
So, when the player enters bullet time, the screen goes black and white (not greyscale), a motion-blur is added, and (obviously) time slows down. The first two were easy to implement, but I'm having trouble with the slow motion.
In the Engine class, I have a timer object, and any object that requires time-based movement or animation is passed a pointer to the timer when they get constructed - this way our objects can be in-sync and don't get messed up when the game is paused.
I've added this code to the Timer class's GetTicks() function to attempt to implement slow-mo:
where m_iSloMoTicks is initialized to this->GetTicks() when slomo is activated.
The logic all works out in my head but it just doesn't do anything when I activate it in game... anybody see any flas in my code?
What does it return normally?
I would set it up like this:
Later, this can be generalized by replacing the sloMo member with a 'clock multiplier' member (int; 1 for what is currently considered slo-mo, 4 for normal speed, say 12 for hyper speed in some other part of the game...)
I would set it up like this:
// As a member variableint m_previousSDLTicks; // the value returned by the last SDL_GetTicks() callint m_myTicks; // time since the beginning of the game. This timer will run// at 4 times the SDL tick rate.// In the getTicks()// First, see how much time has elapsedint elapsedRealTimeTicks = SDL_GetTicks() - m_previousSDLTicks;m_previousSDLTicks += elapsedRealTimeTicks; // set up for next call.if (m_sloMo) { // don't use those prefixes for type; they don't tell you anything your // declarations/IDE can't. Hungarian notation is supposed to be about "type" // of the sort that isn't checked by the language, which often isn't really // a useful concept at all. // Anyway. If we're in slow motion, we add 1*elapsed time to our timer m_myTicks += elapsedRealTimeTicks;} else { // normally, we add 4*elapsed time. m_myTicks += 4*elapsedRealTimeTicks;}
Later, this can be generalized by replacing the sloMo member with a 'clock multiplier' member (int; 1 for what is currently considered slo-mo, 4 for normal speed, say 12 for hyper speed in some other part of the game...)
Thanks, I got it working. Turns out I had my SlomoToggle() function messed up.
Anyway, I use Hungarian notation because
1) I'm terrible with naming conventions
2) It narrows the search down when using Intellisense to type m_b rather than just m_
It's kind of hard to think of good prefixes for classes I wrote myself, though.
Anyway, I use Hungarian notation because
1) I'm terrible with naming conventions
2) It narrows the search down when using Intellisense to type m_b rather than just m_
It's kind of hard to think of good prefixes for classes I wrote myself, though.
why not just slow all the physics to 50% or something? if its _bullet time_, shouldn't the player's craft operate as normal anyway? I think you could have more control and less hastle if you did it this way. just a thought, cheers!
[Edited by - AAAP on November 27, 2005 8:38:22 PM]
[Edited by - AAAP on November 27, 2005 8:38:22 PM]
I love Hungarian notation, it makes perfect sense to me. Using the "m_" prefix in a class for data members makes it easy to identify what is a data member and what is an outside variable. Although the only notation I really use is:
"m_" prefix: for data members
"p" prefix: for pointers (of course I use references for most cases)
Capitolized first letter (no underscores) of every word in the name (ie "PrintCopy"): for function names, I do the same with variable names except the very first letter is lower case
All caps with underscores: for macros and constants (mostly enums)
"_t" postfix: for typenames
By employing that I can quickly scan through blocks of code and know exactly what I am looking at without having to look up definitions or rely on the the IDE.
"m_" prefix: for data members
"p" prefix: for pointers (of course I use references for most cases)
Capitolized first letter (no underscores) of every word in the name (ie "PrintCopy"): for function names, I do the same with variable names except the very first letter is lower case
All caps with underscores: for macros and constants (mostly enums)
"_t" postfix: for typenames
By employing that I can quickly scan through blocks of code and know exactly what I am looking at without having to look up definitions or rely on the the IDE.
^you're right. After I got the whole time-based thing worked out, I realized that it made all the movements look really choppy... I switched to a physics-based system and it looks a ton better. It makes it easy to do a fast slow-down type thing a la FEAR.
Thanks for the help :)
Thanks for the help :)
Quote:Original post by nsto119
[...] a fast slow-down type thing [...]
Aside, will you be releasing a demo any time soon? I love vertical scrolling shooters.
MAYBE a demo soon... I have a friend who's an absolutely INCREDIBLE artist, but he's stationed at an Army base in Hawaii right now and he hasn't emailed me. With him on board, the game could be done really soon, if not, I'll have to draw all the sprites myself, and I suck.
As far as the programming goes, that's all completed, though. It's got some cool features, like locational damage (and therefore a repair system), the whole bullet time thing (which happens to look really cool), and even a neat looking menu!
As far as the programming goes, that's all completed, though. It's got some cool features, like locational damage (and therefore a repair system), the whole bullet time thing (which happens to look really cool), and even a neat looking menu!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement