I'm at a new roadblock in my racer project, making an active timer. I'm using the coding from the tutorial on how to make Fonts appear(got that problem solved the other day), but now I want a timer in the corner, like in Wipeout or Diddy Kong Racing, or anything of that sort.
So far I've tried putting in a value, i.e. int Time and placing it in parens in the text, but the compiler says "is not an L-value", the program doesn't run, or it only prints the value, not the time.
How would one make actively changing text for time?
ITimer* Timer = device->getTimer();
u32 lastTime = Timer->getRealTime();
u32 timeSinceLastFrame = 0;
while(device->run() && driver)
{
if (device->isWindowActive())
{
u32 time = device->getTimer()->getTime(); //get time
driver->beginScene(true, true, 0);
smgr->drawAll();
//draw some text
if (Time)
Time->draw(L"Time: ",
core::rect<s32>(500,75, 600,75),
video::SColor(255,255,255,255));
driver->endScene();
}
I Want to Make an Active Timer!
Code: Select all
ITimer* Timer = device->getTimer();
u32 lastTime = Timer->getRealTime();
wchar_t msg[64];
while( device->run() && driver)
{
u32 currTime = Timer->getRealTime();
driver->beginScene(true, true, 0);
smgr->drawAll();
wsprintf(msg, "Time: %f", (currTime - lastTime) / 1000.f);
// assumes you have a font pointer and the position to render the message...
Font->drawText(msg, position);
driver->endScene();
}
either by #including the appropriate file for your system, forward declaring the appropriate function yourself, or by using google to find an alternative answer. Teach a man to fish...
Last edited by vitek on Tue Jan 31, 2006 11:49 pm, edited 1 time in total.
-
- Posts: 377
- Joined: Fri Oct 28, 2005 10:28 am
- Contact:
I should also point out that http://msdn.microsoft.com is a good place to go for questions specific to windows.
I think you had better mean swprintf. wprintf formats output to the console, but we want it to format the output into a string. If you did use swprintf, that is okay, unfortunately the signature for swprintf on windows systems is not in compliance with the C language standard... That isn't really a big problem, until you start porting to another platform.