• 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.

Aerodactyl55

Members
  • Content count

    62
  • Joined

  • Last visited

Community Reputation

149 Neutral

About Aerodactyl55

  1. The sign of the z-component (for 2D games) of that perpendicular vector will tell you the direction (left/right) to rotate.
  2. I believe you need two vectors for this type of targeting system: The first, from the center of your cannon to the mouse hotspot position; and the second is the current orientation of the cannon. Then you can use the dot product to find the angle between these two vectors and then use the cross product to find the direction to rotate.
  3. I believe you are looking for the DXGI_MWA_NO_ALT_ENTER flag.
  4. ID3DXSprite::Begin()/ID3DXSprite::Draw()/ID3DXSprite::End must be called inside a IDirect3DDevice9::Begin()/IDirect3DDevice9::End() Block.
  5. After so much frustration this is what worked for me: [CODE] int accumulator = ( int )( ( ( tNow - tPrev ) * 1000 ) / tFreq ); tPrev = tNow; while( accumulator > 0 ) { Update( DELTA_TIME ) accumulator -= UPDATE_TICKS; } //Compensate for the extra update loop that consumes the remainder if( accumulator != 0 ) Sleep( abs( accumulator ) ); Render(); [/CODE] And i removed the interpolation. Thanks everyone.
  6. Khatharr, your pseudocode seem to suggest a variable time step which i have used in previous projects, and it works. The problem is if the game slows down a big delta time is passed to Update(), which may result in missed collisions. [quote name='Khatharr' timestamp='1354743715' post='5007534'] Try this: [code]lerp = (float)accumulator / UPDATE_TICKS;[/code] [/quote] Doesnt help.
  7. According to [url="http://gafferongames.com/game-physics/fix-your-timestep/"]this article[/url] interpolation is needed to avoid stuttering and this seems to be true because removing the interpolation doesn't help. Maybe I should use the next position instead of the previous. I dont see any error in the way i am calculating the interpolation yet the movement of the sprite is not smooth. I tried putting some sleep calls and it does minimize the stuttering but it doesn't eliminate it completely.
  8. i decided to refine the code a little to make it easier to understand, but i didnt add "g_" to variables because 99% of them are globals. [CODE] #include "core.h" struct OBJECT { IDirect3DTexture9* Tex; //Object texture D3DXVECTOR2 Pos; //Current position D3DXVECTOR2 prevPos;//Previous position, this will be used for interpolation D3DXVECTOR2 Vel; //Velocity }; LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM ); BOOL Init(); void Update( float dt ); void Render(); void Cleanup(); Core::CGraphics gfx; Core::CSprite sprite; OBJECT star; ULONGLONG tNow = 0; ULONGLONG tPrev = 0; ULONGLONG tFreq = 0; DWORD accumulator = 0; const int UPDATE_TICKS = 10; //10ms const float DELTA_TIME = UPDATE_TICKS * 0.001f; //The dt passed to the update function float lerp = 0.0f; //The interpolation value to be used during rendering int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { if( !gfx.InitWindow( hInstance, WndProc, L"Game Loop Test", nCmdShow ) ) return 0; if( !Init() ) { gfx.MsgBoxError( L"Init() Failed!" ); return 0; } MSG msg = { 0 }; QueryPerformanceFrequency( ( LARGE_INTEGER* )&tFreq ); QueryPerformanceCounter( ( LARGE_INTEGER* )&tPrev ); while( WM_QUIT != msg.message ) { if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } else { QueryPerformanceCounter( ( LARGE_INTEGER* )&tNow ); accumulator += ( DWORD )( ( ( tNow - tPrev ) * 1000 ) / tFreq ); tPrev = tNow; while( accumulator >= UPDATE_TICKS ) { Update( DELTA_TIME ); accumulator -= UPDATE_TICKS; } //Compute the interpolation value for this frame lerp = accumulator / ( float )UPDATE_TICKS; Render(); } } return static_cast< int >( msg.wParam ); } BOOL Init() { if( !gfx.CreateDirect3D9() ) return FALSE; if( FAILED( gfx.CreateDevice9() ) ) return FALSE; if( FAILED( sprite.Init( &gfx ) ) ) return FALSE; ZeroMemory( &star, sizeof( OBJECT ) ); //Load the texture if( FAILED( gfx.LoadTextureFromFile( L"star.png", &star.Tex ) ) ) return FALSE; star.Pos.y = 284.0f; star.Vel.x = 500.0f; //The sprite only moves on the x-axis star.prevPos = star.Pos; return TRUE; } void Update( float dt ) { //Store the position before updating star.prevPos = star.Pos; //Move the sprite star.Pos = star.Pos + star.Vel * dt; //Prevent the sprite from leaving the screen boundaries [0 - 800] if( star.Pos.x + 32.0f > 800.0f ) { star.Pos.x = 768.0f; star.Vel.x = -star.Vel.x; star.prevPos = star.Pos; } else if( star.Pos.x < 0.0f ) { star.Pos.x = 0.0f; star.Vel.x = -star.Vel.x; star.prevPos = star.Pos; } } void Render() { gfx.Clear(); gfx.BeginScene(); sprite.Begin(); D3DXVECTOR2 p; //interpolated position //Interpolate between the previous and the current position p = star.prevPos * lerp + star.Pos * ( 1.0f - lerp ); //Draw the sprite sprite.Translate( &p ); sprite.Draw( star.Tex, NULL, BLUE_COLOR ); sprite.End(); gfx.EndScene(); gfx.Present(); } void Cleanup() { //Release the texture Core::ReleaseCOM( star.Tex ); } LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch( msg ) { case WM_DESTROY: Cleanup(); PostQuitMessage( 0 ); break; default: return DefWindowProc( hwnd, msg, wParam, lParam ); } return 0; } [/CODE] I am still unable to find any mistake but the stuttering is still there. And thanks for the replies.
  9. First i am really sorry about bad coding, this isnt my real coding style. This application was rushed just to test how the fixed time-step loop behaved. This test application only moves a 32x32 sprite left-right. There is visible stuttering in the motion which i was unable to fix even with interpolation. I am not sure if it is the loop itself or something else.
  10. I recently decided to switch from a variable step to a fixed step game loop. So i created a small application to test the new loop. I dont know why but the new loop does not produce smooth movement. I hope maybe someone here will spot a mistake because i cant find it myself. Here is the code: [CODE] #include "core.h" struct STAR { IDirect3DTexture9* Tex; D3DXVECTOR2 Pos; D3DXVECTOR2 prevPos; D3DXVECTOR2 Vel; }; LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM ); BOOL Init(); void Update( float dt ); void Render(); void Cleanup(); Core::CGraphics gfx; Core::CSprite sprite; STAR star; ULONGLONG tNow = 0; ULONGLONG tPrev = 0; ULONGLONG tFreq = 0; DWORD accumulator = 0; const int UPDATE_TICKS = 10; const float DELTA_TIME = UPDATE_TICKS * 0.001f; float lerp = 0.0f; wchar_t str[64] = L""; int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { if( !gfx.InitWindow( hInstance, WndProc, L"Game Loop Test", nCmdShow ) ) return 0; if( !Init() ) { gfx.MsgBoxError( L"Init() Failed!" ); return 0; } MSG msg = { 0 }; QueryPerformanceFrequency( ( LARGE_INTEGER* )&tFreq ); QueryPerformanceCounter( ( LARGE_INTEGER* )&tPrev ); float c = 1.0f / tFreq; while( WM_QUIT != msg.message ) { if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } else { QueryPerformanceCounter( ( LARGE_INTEGER* )&tNow ); accumulator += ( DWORD )( ( ( tNow - tPrev ) * 1000 ) / tFreq ); tPrev = tNow; while( accumulator >= UPDATE_TICKS ) { Update( DELTA_TIME ); accumulator -= UPDATE_TICKS; } lerp = accumulator / ( float )UPDATE_TICKS; Render(); } } return static_cast< int >( msg.wParam ); } BOOL Init() { if( !gfx.CreateDirect3D9() ) return FALSE; if( FAILED( gfx.CreateDevice9() ) ) return FALSE; if( FAILED( sprite.Init( &gfx ) ) ) return FALSE; ZeroMemory( &star, sizeof( STAR ) ); if( FAILED( gfx.LoadTextureFromFile( L"star.png", &star.Tex ) ) ) return FALSE; star.Pos.y = 284.0f; star.Vel.x = 500.0f; star.prevPos = star.Pos; return TRUE; } void Update( float dt ) { star.prevPos = star.Pos; star.Pos = star.Pos + star.Vel * dt; if( star.Pos.x + 32.0f > 800.0f ) { star.Pos.x = 768.0f; star.Vel.x = -star.Vel.x; star.prevPos = star.Pos; } else if( star.Pos.x < 0.0f ) { star.Pos.x = 0.0f; star.Vel.x = -star.Vel.x; star.prevPos = star.Pos; } } void Render() { gfx.Clear(); gfx.BeginScene(); sprite.Begin(); D3DXVECTOR2 p; p = star.prevPos * lerp + star.Pos * ( 1.0f - lerp ); sprite.Translate( &p ); sprite.Draw( star.Tex, NULL, DODGERBLUE_COLOR ); sprite.End(); gfx.EndScene(); gfx.Present(); } void Cleanup() { Core::ReleaseCOM( star.Tex ); } LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch( msg ) { case WM_DESTROY: Cleanup(); PostQuitMessage( 0 ); break; default: return DefWindowProc( hwnd, msg, wParam, lParam ); } return 0; } [/CODE]
  11. if you want to make video games then perhaps you sould start by learning how to output images(sprites) on the screen. Then learn how to move them. After that you should be able to make a simple game( pong or even snake ).
  12. Thanks for replying. In fact i have been using them since and never had any problems with them. Only recently a found some claims on the internet that the frequency could change. I guess they forgot to mention that it affected only certain (buggy) motherboards.
  13. MSDN says that the frequency cannot change while the system is running, but i have seen some claims that it does change. So is it safe to use them? And what are the other available options?
  14. How was ZENVERTEX and CUSTOM_ZENVERTEX defined? Is ZENVERTEX expecting a texture?
  15. i dont know much about OpenGL but i believe that lighting is not enabled thats why your mesh is dark.