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


  • Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About ohohvi

  • Rank
  1. Finally, I figured it out. Somehow event.motion.x gets messed up when I called SDL_GetKeyState(), so when I use it to determine the distance between the ship and the cursor after SDL_GetKeyState, I was getting bogus numbers. Thanks for the help everyone.
  2. The wierd part is that even if the line reads : if( keys[SDLK_UP ); with nothing after it, the ship will still fly off when up is pressed. I just don't understand...
  3. Well that fixed my mouse lag, which is a big plus. However, the ship still likes to fly off to the right whenever I push up or down. Should SDL_GetKeyState be included in the while(SDL_PollEvent()) loop or should it be after the switch and outside the loop?
  4. I am trying to write a simple game in SDL but I'm having some problems. Basically, the event loop from this program is modified from cone3d, which isn't quite working now. The mouse controls the x movement of the ship, and the ship moves towards the cursor at a speed inversely proportional to the ship's distance from the cursor. The y movements are controlled by the up/down arrows. The ship moves along the x axis just fine, but as soon as I hit up or down, it goes flying off to the right, which shouldnt be affected by the y movements, only the mouse. Anyways, another problem I've been having is the mouse has a lag between when I move the mouse and when the cursor actually moves. This is pretty much my first real program so feel free to critique any problems you see with the code. Thanks. int main( int argc, char* argv[] ) { SDL_Surface* screen; //Sprite class basically just loads BMP, converts it to display format, and draws it when necessary Sprite* background; Sprite* cursor; //Ship class controls position of ship as well as its own sprite class Ship* ship; SDL_Rect shiprect, bgrect, cursorrect; int running = 1; SDL_Event event; Uint8* keys; int distance, one = 1; float angle; if( SDL_Init( SDL_INIT_VIDEO ) == -1 ){ cout<<"Error initializing SDL"<<endl; exit(-1); } atexit(SDL_Quit); screen = SDL_SetVideoMode( 800, 600, 24, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_ANYFORMAT | SDL_FULLSCREEN ); if( screen == NULL ) { cout<<"Unable to initialize screen"<<endl; exit(1); } shiprect.x = 0; shiprect.y = 0; shiprect.w = 32; shiprect.h = 32; ship = new Ship( "ship.bmp", &shiprect ); ship->SetPos( 300, 400 ); bgrect.x = 0; bgrect.y = 0; bgrect.w = 800; bgrect.h = 600; background = new Sprite( "stars.bmp", &bgrect ); SDL_ShowCursor(0); SDL_WM_GrabInput( SDL_GRAB_ON ); cursorrect.x = 0; cursorrect.y = 0; cursorrect.w = 32; cursorrect.h = 32; cursor = new Sprite( "cursor.bmp", &cursorrect ); while( running == 1 ) { SDL_PollEvent( &event ); switch( event.type ) { case SDL_QUIT: running = 0; break; case SDL_KEYDOWN: if( event.key.keysym.sym == SDLK_ESCAPE ) running = 0; break; case SDL_MOUSEMOTION: cursorrect.x = event.motion.x-16; cursorrect.y = event.motion.y-16; break; default: break; } keys = SDL_GetKeyState( NULL ); if( keys[SDLK_UP] ) ship->ChangePos( 0, -3 ); if( keys[SDLK_DOWN] ) { if( ship->GetYPos() < 568 ) ship->ChangePos( 0, 3 ); } //determine distance between ship and cursor and move ship accordingly distance = (event.motion.x-ship->GetXPos()-16)/10; if( distance < 0 ) { one = -1; distance *= one; } else one = 1; cout<<distance<<endl; if( distance != 0 ) ship->ChangePos( (one * (int)sqrt((double)distance)), 0); //angle between cursor and ship, not yet implemented (double)angle = atan( (double)(event.motion.y-ship->GetYPos()-16)/(ship->GetXPos()-event.motion.x+16) ); cout<<angle<<endl; background->DrawSprite( screen, &bgrect ); ship->DrawShip( screen ); cursor->DrawSprite( screen, &cursorrect ); SDL_Flip( screen ); } delete ship; delete background; delete cursor; return 1; }