• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Dissipate

-1.#IND00 in my debug text out

3 posts in this topic

Hi,

I am displaying -1.#IND00 as the m_fX and m_fY positions of a square that is supposed to orbit. The code works but I only get the error output to my debug textout function when I create the object before 1 second (ie the FPS is caculated). The Orbit Code calculates the required movement needed by observing the amount of frametime passed.

Is there a work around or correction or should I wait 1 second before drawing anything...?

The Game Loop:

 

// Game loop
    while (g_App.GetD3DStatus())
    {
        // If there are any window messages, process them
        while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }

        // Quit if message recieved
        if (msg.message == WM_QUIT)
        break;
        if (KEY_DOWN(VK_ESCAPE)) PostMessage(hWnd, WM_DESTROY, 0, 0);
        if (KEY_DOWN(VK_MBUTTON)) PostMessage(hWnd, WM_DESTROY, 0, 0);

        // Read the Performance Counter, which may be divided by the
        // counter frequency to determine the time in seconds
        __int64 iiCurrentTimeStamp = 0;
        QueryPerformanceCounter((LARGE_INTEGER*)&iiCurrentTimeStamp);
        float dt = (iiCurrentTimeStamp - iiPrevTimeStamp) * fSecondsPerCount;

        // Increment the frame count.
        iNumberOfFrames++;

        // Accumulate how much time has passed.
        fTimeElapsed += dt;

        // Has one second passed?--we compute the frame statistics once
        // per second.  Note that the time between frames can vary so
        // these stats are averages over a second.
        if( fTimeElapsed >= 1.0f )
        {
            // Frames Per Second = numFrames / timeElapsed,
            // but timeElapsed approx. equals 1.0, so
            // frames per second = numFrames.
            g_uFPS = (UINT)iNumberOfFrames;

            // Average time, in milliseconds, it took to render a single frame.
            g_dMilliSecPerFrame = 1000.0f / g_uFPS;

            // Save the framerate to tell CApplication, sprites and meshes
            g_uFrameRate = g_uFPS;
        
            strcat_s(c, "\n");
            fputs(c, pFile);
            
            // debug text out framerate before it's reset
            g_Text->SetRowEx(TXT_FRAMERATE, "FPS = ", g_uFrameRate);
            g_Text->SetRowEx(TXT_FRAMETIME, "FrameTime = ", g_dMilliSecPerFrame);

            // Reset time counter and frame count to prepare for computing
            // the average stats over the next second.
            fTimeElapsed    = 0.0f;
            iNumberOfFrames = 0;
            iFrameCycles    = 0;

            // Increase the number of seconds passed
            iNumSecs++;
        } // end if


        //g_App.DetectPicking();                // Detect mouse over mesh & turn off lighting

        // Check for user input
        g_App.DetectInput();

        // Render
        g_App.Render();

        g_Text->SetRowEx(TXT_DELTA, "delta = ", fDelta);

        // Prepare for next iteration: The current time stamp becomes
        // the previous time stamp for the next iteration.
        iiPrevTimeStamp = iiCurrentTimeStamp;

        iFrameCycles++;

    } // end while (g_App.GetD3DStatus())


 

// ********************************************************************* //
// Name: Orbit															 //
// Description: Calculate a circular motion 		  					 //
// ********************************************************************* //
void CShape::Orbit(float fX, float fY, float fZ)
{
	float fU = (float) g_uFrameRate / g_dMilliSecPerFrame;

	// Calc xyz velocity's cirular points
	m_fXV = 0.0f; //(float)(sin(fX) * 12.0f) * 800.0f;
	m_fYV = 0.0f;
	m_fZV = 0.0f; //(float)(cos(fZ) * 25.0f) * 800.0f;

	// Ensure XYZ is within the limits otherwise flip the direction headed
	BoundsCheck();

	// Stop movement if required
	if (m_uDirection & SHAPE_NONE)
	{
		m_fXV = 0.0f;
		m_fYV = 0.0f; // No movement
		m_fZV = 0.0f;
		m_uDirection = 0; 
		g_Text->SetRowEx(TXT_SHAPEDIR,  "m_uDirection = ", m_uDirection);
	}

	// Move on X-axis
	if (m_uDirection & SHAPE_LEFT)
	{
		m_fXV = -m_fV; // Going left
		m_uDirection |= SHAPE_LEFT;
		m_uDirection &= ~SHAPE_RIGHT;
		g_Text->SetRowEx(TXT_SHAPEDIR,  "m_uDirection = ", m_uDirection);
	}
	else if (m_uDirection & SHAPE_RIGHT)
	{
		m_fXV = m_fV; // Going right
		g_Text->SetRowEx(TXT_SHAPEDIR,  "m_uDirection = ", m_uDirection);
	}

	// Move on Y-axis
	if (m_uDirection & SHAPE_UP)
	{
		m_fYV = -m_fV; // Going up
		g_Text->SetRowEx(TXT_SHAPEDIR,  "m_uDirection = ", m_uDirection);
	}
	else if (m_uDirection & SHAPE_DOWN)
	{
		m_fYV = m_fV; // Going down
		g_Text->SetRowEx(TXT_SHAPEDIR,  "m_uDirection = ", m_uDirection);
	}

	// Move on Z-axis
	if (m_uDirection & SHAPE_FORWARD)
	{
		m_fZV = -m_fV; // Going forward
		g_Text->SetRowEx(TXT_SHAPEDIR,  "m_uDirection = ", m_uDirection);
	}
	else if (m_uDirection & SHAPE_BACKWARD)
	{
		m_fZV = m_fV; // Going backward
		g_Text->SetRowEx(TXT_SHAPEDIR,  "m_uDirection = ", m_uDirection);
	}

	// Units per second over frames per second
	m_fX += m_fXV / fU;
	m_fY += m_fYV / fU;
	m_fZ += m_fZV / fU;

	g_Text->SetRowEx(TXT_SHAPEXYZ,  "m_fX = ", m_fX);
	g_Text->SetRowEx(TXT_SHAPEXYZ2, "m_fZ = ", m_fZ);
	//g_Text->SetRowEx(TXT_SHAPEDIR,  "m_uDirection = ", m_uDirection);
	
	// Apply this to a matrix
    D3DXMatrixTranslation(&m_matTranslate, m_fX, m_fY, m_fZ);
}// Orbit

 

 




Please do also suggest if I am doing all this correctly. I did have the formulae for circular movement in the first few lines of commented out code in the CShape::Orbit function but I didnt know how to apply it to the calculated Units per second calculation.

I worked out that Movement per frame would be = Units per second / (FPS / FrameTime)
Error is produced from Lines

g_Text->SetRowEx(TXT_SHAPEXYZ,  "m_fX = ", m_fX);	g_Text->SetRowEx(TXT_SHAPEXYZ2, "m_fZ = ", m_fZ);

at the end of the function.

EDIT** initialised the FPS to something I saw currently as well as the milliseconds per frame as it was a divide by zero error

Thanks

Edited by Dissipate
0

Share this post


Link to post
Share on other sites

[code]

float fU = (float) g_uFrameRate / g_dMilliSecPerFrame;
[/code]

creates a division by 0 until g_uFramerate != 0. (not certain if your edit is referring to this, and if your problems are fixed?)

 

their's also an issue with your time-step code: [url="http://gafferongames.com/game-physics/fix-your-timestep/"]http://gafferongames.com/game-physics/fix-your-timestep/[/url]

 

[code]
        if( fTimeElapsed >= 1.0f ){
            fTimeElapsed    = 0.0f;         }[/code]

instead of resetting to 0, subtract by 1. this is very important for maintaining consistent frame times.

2

Share this post


Link to post
Share on other sites
creates a division by 0 until g_uFramerate != 0. (not certain if your edit is referring to this, and if your problems are fixed?)

I sorted the div/0 by pluggin in numbers initially so they are not zero to begin with.

 

I am reading the article now...

 

 

instead of resetting to 0, subtract by 1. this is very important for maintaining consistent frame times.

I dont understand... what is the effect of subtracting by 1. Oh I see maybe the overflow is kept for the next second (?) What I mean is the bit left over after 1 sec (eg. 1.000463 - 1 = 0.000463) which can accumulated towards the next second.

So the so called seconds that go by aren't really real seconds, as they roll over continuosly..?

 

I dont think I am correctly moving by a certain Unit Per Second as when I add Sleep(5) to the Render() function The Square moves even faster. How should I be doing this?

0

Share this post


Link to post
Share on other sites
creates a division by 0 until g_uFramerate != 0. (not certain if your edit is referring to this, and if your problems are fixed?)

I sorted the div/0 by pluggin in numbers initially so they are not zero to begin with.

 

I am reading the article now...

 

 

instead of resetting to 0, subtract by 1. this is very important for maintaining consistent frame times.

I dont understand... what is the effect of subtracting by 1. Oh I see maybe the overflow is kept for the next second (?) What I mean is the bit left over after 1 sec (eg. 1.000463 - 1 = 0.000463) which can accumulated towards the next second.

So the so called seconds that go by aren't really real seconds, as they roll over continuosly..?

 

I dont think I am correctly moving by a certain Unit Per Second as when I add Sleep(5) to the Render() function The Square moves even faster. How should I be doing this?

 

 

what you appear to be doing right now(i may be wrong, as i've not given a heavy look at your code), is trying to do a delta time step, to run at variable frame's per second.  this is fine and dandy if you really want that, but instead, i'd recommend trying to target a specefic frame-rate, a locked frame rate across all your builds makes making things consistant much easier.

 

the idea of the time step is to update the program more frequently if it's falling behind(and well hopefully stabilize quickly), essentially by subtracting by 1(or w/e your time step is, such as 1/60th a second or 1/30th a second are very common), you are preserving that "roll over" seconds, so that the program can consistently update itself at a fixed time-step, this is important considering that many modern os's can switch back to your program in ~16ms(which this is important to know for how sleep works, since sleep does not guarantee that you well return in the amount of time you request to sleep for), and makes it very important for preserving "roll over seconds", otherwise if you don't preserve these missed second you'll get estatic fps changes.

 

so, here you are, you have a time step, now forget about passing that delta time to other objects, and instead update the object by one "step" when you are inside your timestep, subtract, and wait for another step to come around.  this makes programming object interaction across different computer's very consistent, because they don't move at variable speeds, and instead each object well move at the same speed on all computers, even if the computer begins to fall behind which that computer well just try to take more steps(because your preserving that "roll over" by subtracting instead of resetting it.)

 

hopefully this comes across coherently(i have a sneaking suspicion being up this late is making me ramble on at the moment.)

2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0