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

Mogthew

Members
  • Content count

    16
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Mogthew

  • Rank
    Member
  1. How do you render the objects - are you converting them back into Euler angles and then using glRotatef with them? AFAIK your general idea is correct, if you want to represent a bunch of rotations, you make them, and then combine then (and you're right, order matters). I think that the order you multiply them by should be the same order as the one you render them in, for example if you're multipling x * y * z, then when you convert to Euler angles you should rotate around the X axis, then Y then z. I'm still trying to get my head around Quaternions, but I _think_ this is correct. It's how they're being represented in my game at the moment anyway, and I'm doing a space themed game too ;p
  2. Hey all, I'm trying to convert two axis rotations into Quaternion rotations. When I constrain the rotations to one axis i can get it to work properly, but it requires I multiply it by a second quaternion of 90degres to get it to work. Note, this code doesn't compile, I will have the whichever two I'm not using commented out when running. [CODE] if(cameraXRotate > 180) { mult = -1; } /* rotation around the x axis*/ Quaternion cameraX = new Quaternion(mult * cameraXRotate * (float)(Math.PI / 180.0), new XYZ(1,0,0)); Quaternion camera = new Quaternion(90 * (float) (Math.PI / 180.0), new XYZ(0, 1, 0)); /* Rotation around the y axis*/ Quaternion cameraY = new Quaternion(-cameraYRotate * (float) (Math.PI / 180.0), new XYZ(0, 1, 0)); Quaternion camera = new Quaternion(90 * (float) (Math.PI / 180.0), new XYZ(1, 0, 0)); /* rotation around the z axis*/ Quaternion cameraZ = new Quaternion(cameraZRotate * (float)(Math.PI / 180.0), new XYZ(0,0,1)); Quaternion camera = new Quaternion(90 * (float) (Math.PI / 180.0), new XYZ(1, 0, 0)); [/CODE] Now, firstly, I'm not sure why I have to multiply by 90 to get all these to work, and I'm not sure why I have to reverse the rotation on the X axis if it's greater than 180. All I know, is that these seem to work properly on single axis rotation. This is the standard rotation code in openGL for the cameraX and Y, the negative cameraX is deliberate- [CODE] glRotatef(-cameraXRotate, 1, 0, 0); glRotatef(cameraYRotate, 0, 1, 0); [/CODE] Now, when I try to multiple the two rotations together, I get weird angles. This is my rotation code: [CODE] /* x axis rotation */ Quaternion cameraX = new Quaternion(mult * cameraXRotate * (float)(Math.PI / 180.0), new XYZ(1,0,0)).mul(new Quaternion(90 * (float)(Math.PI / 180.0), new XYZ(1,0,0))); /* y axis rotation */ Quaternion cameraY = new Quaternion(cameraYRotate * (float) (Math.PI / 180.0), new XYZ(0, 1, 0)).mul(new Quaternion(90 * (float)(Math.PI / 180.0), new XYZ(1,0,0))); Quaternion result = Quaternion.IDENTITY.mul(cameraX.mul(cameraY)); [/CODE] Any ideas? I'm really stuck on this one [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img] Thanks!
  3. Yes, all ships have the same width / height, which makes this work. I'm not entirely sure how you manage to do "one comparison per object if you're lucky", how is this achieved? The sorting doesnt take too long, the memory is initialized at start up and then only modified at a later time, it's not created or deleted. Again, the code you posted is specific to check for object vs object collisions, there's nothing there that shows how to cull the object collision pairs down. Could you explain further?
  4. Quote:Original post by Atrix256 "As for the vsync, that's a good point, i'd not thought of that. Most systems these days use LCD's so yeah. Maybe 60fps should be my goal. " For the record vsync existed before LCD's, there's nothing special about LCD's and vsync... it was on CRT's too :P Haha, I know that :p My point was simply that LCD's have a default VSYNC of 60. whereas CRT's where higher, and therefore 60fps should be perfectly sufficient. @Net-Ninja, I didn't realise you could do that (with the sqrt) but I've been using the separate axis idea for a bit. The current operation works like this: Sort the list of ships by their X values. Get a bullet. Get the index of the minimum X value, using a binary search, that will collide with the bullet Get the index of the maximum X value, using a binary search, that will collide with the bullet Using the two indices in the array, do a brute force comparison between the two array indices Code looks like this: double width = baddies[0].getClipBoundsWidth(); double height = baddies[1].getClipBoundsHeight(); int xMinIndex = BSearch.min(xSort, (int)locationX, (int)width); int xMaxIndex = BSearch.max(xSort, (int)locationX, (int)width); if(xMinIndex == -1) return null; if(xMaxIndex < 0) xMaxIndex = xMinIndex; //System.out.println("Searching between " + xMinIndex + " and " + xMaxIndex); for(int x = xMinIndex;x <= xMaxIndex;++x) { if(baddies[xPtrs[x]].dgetY() + width > locationY && baddies[xPtrs[x]].dgetY() - width < locationY) { return baddies[xPtrs[x]]; } } return null; FYI: I use java to do spikes, if they look promising I port them into my game. I have a simple framework set up to do tests on multiple different collisions detection schemes and report the results. Also, I found that the collision detection like this was bound by calls to getX() and getY(), so I extracted the xvalues into an array (which is what the bsearch operates on).
  5. Hmm, alot of excellent suggestions. I'll definitely go and look at either setting up a grid or making some sort of tree. As for the vsync, that's a good point, i'd not thought of that. Most systems these days use LCD's so yeah. Maybe 60fps should be my goal. I've considered grids and spatial hashing, but haven't tried to implement. That'll be my goal now I think. Thanks for all the suggestions, I should be able to get where I want to go now :D
  6. I probably should've mentioned, but it's for a 2d game. Can you still use a binary space partition for 2d stuff? My knowledge of BSP tree's is veery limited, but if it's the next step I guess I don't have much choice. EDIT: In this game, there's no closed areas. It's totally open, basically a gigantic flat area. Are BSP tree's still applicable?
  7. Hey people, Currently, I'm working on a space scroller shoot-em-up and need some really fast collision detection algorithms. Basically, it needs to be able to handle about 1,000 ships and 1,000 bullets. Currently, my code offers only 50fps when this is happening, and I'd like it to be closer to 100 at least. The algorithm I'm using at the moment gets a ship and does a binary search to find all bullets within the range of colliding with the ship. By itself, it takes ~15ms(by itself it seems to run in 8ms, not sure why there's so much difference. Probably cache or something?) to run, then there's the updating of ships and the AI and other stuff to do. Basically, I just want to know if there's anything out there right now I can use to increase the throughput? Thanks!
  8. Im not sure why the subtraction is there, it explains it in the tutorial so who knows. Also, the tutorial compiles and works as expected, so the code is how its supposed to be. " AFAIK, you cannot draw 2D with OpenGL. You must create a texture and render a quad to the screen as if 2D." Thats pretty much what im doing.
  9. I have looked at ttf, but I'm not sure how the performance aspect would be, creating surfaces, blitting text, converting to texture and then rendering it on screen. I plan on using numbers that will change so static text isn't an option. The rendering function is as follows: bool MenuInterface::renderInterface(){ drawImage(sun, 0, 0, 1152, 864); Font::drawText("test...", 100, 100); return true; } EDIT: Also, for some reason when I change the glColor3f(1.0f,1.0f,1.0f); call to something other than 1.0 for the arguments, it shades the screen a different colour.
  10. EDIT: Excuse the bad formatting, I don't know how to do the code windows :( Hi guys, I'm trying to get some text onto the screen for a test app. Using SDL as a wrapper for OpenGL. Currently I have them working together propperly, ie I have a texture drawn onto the screen. The current rendering code just renders a background image, and then tries to render text. The initialisation code for the font class i made is here (borrowing heavily from nehe tutorials): Font::Font(){ SDL_SysWMinfo window_info; SDL_GetWMInfo(&window_info); HWND window = window_info.window; HDC hDC = GetDC(window); HFONT font; // Windows Font ID HFONT oldfont; // Used For Good House Keeping list = glGenLists(96); // Storage For 96 Characters font = CreateFont( -12, // Height Of Font 0, // Width Of Font 0, // Angle Of Escapement 0, // Orientation Angle FW_BOLD, // Font Weight FALSE, // Italic FALSE, // Underline FALSE, // Strikeout ANSI_CHARSET, // Character Set Identifier OUT_TT_PRECIS, // Output Precision CLIP_DEFAULT_PRECIS, // Clipping Precision ANTIALIASED_QUALITY, // Output Quality FF_DONTCARE|DEFAULT_PITCH, // Family And Pitch "Courier New"); // Font Name oldfont = (HFONT)SelectObject(hDC, font); // Selects The Font We Want wglUseFontBitmaps(hDC, 32, 96, list); // Builds 96 Characters Starting At Character 32 SelectObject(hDC, oldfont); // Selects The Font We Want DeleteObject(font); initialised = true; DebugOutputFile::write("Successfully loaded font.\n"); } And is called via the following function: void Font::drawText(char *text, int x, int y){ if(!initialised) Dialog::errorBox("Font not initialised before use\n"); glLoadIdentity(); glColor3f(1.0f,1.0f,1.0f); glRasterPos2i(400,400); glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits glListBase(list - 32); // Sets The Base Character to 32 glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text glPopAttrib(); } Only the image shows up when the program runs, the text is no where to be seen. Is there something I've missed? If any of you could help me out here, it would be greatly appreciated :) Thanks for your time.
  11. Not sure if this is the right way to display codeso ill give it a shot. int initGL( GLvoid ) { /* Enable smooth shading */ glShadeModel( GL_SMOOTH ); /* Set the background black */ glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); /* Depth buffer setup */ glClearDepth( 1.0f ); /* Enables Depth Testing */ glEnable( GL_DEPTH_TEST ); /* The Type Of Depth Test To Do */ glDepthFunc( GL_LEQUAL ); /* Really Nice Perspective Calculations */ glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); buildFont( ); return( TRUE ); } EDIT: Didnt quite work as i expected, trying to get it to show it in a window with syntax highlighting.
  12. Vsync was off. If my app was doing nothing and using all cpu, thats pretty silly. Doesn't leave any room for actual calculations in the game. As for vysnc, I have the refresh rate override, so it would be capped at 100, it never _usually_ goes above 95. EDIT: After compiling the New source code for the app, my computer runs it for about 2 seconds, then quits. Also, theres a segfault somewhere oO Fixed the segfault, the App still runs at 100 fps in fullscreen mode (with vysnc off) I have a 3800 dual core, this shouldn't be happening (it maxes out 1 core at 95FPS). [Edited by - Mogthew on February 20, 2007 6:31:24 PM]
  13. The array has to be Unicode size for some reason, as pressing any of the arrow keys results in some value around 275. Fixed some memory leaks, but that's not where the performance degrading is happening. Even with all those problems, when I cover certain parts of the window (with other windows) the framerate jumps up to about 2k. The performance should still be way above what it is now. Thanks again for the heads up again, I didn't know that the TTF_Render_Text_solid() actually created a new copy of the surface, but come to think of it, makes alot of sense.
  14. My pc should run it fine, it's still fairly new. I'm kinda new so I don't know exactly how to put the code snippets in without just pasting them, so bare with me. Also this code is kinda messy, hadn't planned on cleaning it up for a bit, as it is still my first SDL app. #include "SDL/SDL.h" #include <string> #include <SDL/SDL_image.h> #include <SDL/SDL_ttf.h> #include <SDL/SDL_rotozoom.h> #include <windows.h> #include <cstdlib> #import "HRTimer.cpp" #import "Entity.cpp" #import "map.cpp" #import <fstream.h> //very messy I know. void getAndProcessEvents(); void render(); void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination ); void apply_surface( int x, int y,int width, int height, SDL_Surface* source, SDL_Surface* destination ); void itoa(int x, char **pointer); void update(); SDL_Surface *load_image( std::string filename ) ; SDL_Surface *backgrounds; SDL_Surface *screen; SDL_Surface *tile; SDL_Event event; int xOffset = 0; int yOffset = 0; bool quit = false; int fpsMain = 0; SDL_Color textColor = { 255, 255, 255 }; TTF_Font* font = NULL; SDL_Surface *framerate = NULL; bool *keyArray; SDL_Surface *temp = NULL; char *fpschar; ofstream *log_file; int main( int argc, char* args[] ) { temp = new SDL_Surface(); log_file = new ofstream("log_file.txt"); int width = 256; int height = 256; char *pathArray[width]; *pathArray = new char[width]; for(int x = 0;x < height;x++) pathArray[x] = (char*)malloc(sizeof(char)*width); FILE *fp = fopen("out.txt","r"); char c; int x = 0; for(int x = 0;x < height;x++) for(int y = 0;(c = (char)fgetc(fp)) != EOF && y < width;y++) pathArray[x][y] = c; Map *map = new Map(pathArray,height, width); keyArray = new bool[65536]; // dont quit without reason :) if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 ) { return 1; } if( TTF_Init() == -1 ) { return false; } screen = SDL_SetVideoMode( 800, 600, 32,SDL_FULLSCREEN | SDL_HWSURFACE | SDL_DOUBLEBUF ); temp = SDL_CreateRGBSurface( SDL_HWSURFACE, 800, 600, 32, 0, 0, 0,0); HRTimer *hr = new HRTimer(); double fpsTime =hr->currentTimeMS(); double baseTime = fpsTime; int fps = 0; font = TTF_OpenFont( "lazy.ttf", 32); backgrounds = load_image("background.png"); tile = load_image("tile.jpg"); while( quit == false ) { if(hr->currentTimeMS() - fpsTime > 1000){ fpsMain = fps; fps = 0; fpsTime = hr->currentTimeMS(); itoa(fpsMain, &fpschar); framerate = TTF_RenderText_Solid( font, fpschar, textColor ); *log_file << fpsMain; } //While there's an event to handle //update(); render(); getAndProcessEvents(); // commented out all the sleep functions so it runs as fast as possible. //double sleepTime = (baseTime+2.09999) - hr->currentTimeMS(); //if(sleepTime > 0) // Sleep(sleepTime); baseTime+=2.09999; fps++; } log_file->close(); return 0; } void getAndProcessEvents(){ while( SDL_PollEvent( &event ) ) { if( event.type == SDL_QUIT ) { quit = true; } if(event.type == SDL_KEYDOWN){ int keyCode = event.key.keysym.sym; keyArray[keyCode] = true; } if(event.type == SDL_KEYUP){ int keyCode = event.key.keysym.sym; keyArray[keyCode] = false; } } if(keyArray[SDLK_LEFT]) xOffset--; if(keyArray[SDLK_RIGHT]) xOffset+=2; if(keyArray[SDLK_UP]) yOffset--; if(keyArray[SDLK_DOWN]) yOffset++; if(keyArray[SDLK_ESCAPE]) quit = true; } void render(){ SDL_Rect rect; rect.x = 450; rect.y = 450; //SDL_Rect offset; //offset.w = 50; //offset.h = 50; /*for(int x = -1;x < 17;x++) for(int y = -1;y < 13;y++){ offset.x = x*50 + (xOffset%50); offset.y = y*50 + (yOffset%50); SDL_BlitSurface( tile, NULL, temp, &offset ); }*/ //SDL_Rect rect; rect.x = 450; rect.y = 450; rect.w = 40; rect.h = 40; SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, 0, 0,0xFF)); SDL_BlitSurface( framerate, NULL,screen, &rect ); SDL_Flip(screen); } SDL_Surface *load_image( std::string filename ) { SDL_Surface* loadedImage = NULL; SDL_Surface* optimizedImage = NULL; loadedImage = IMG_Load( filename.c_str() ); if( loadedImage != NULL ) { optimizedImage = SDL_DisplayFormat( loadedImage ); SDL_FreeSurface( loadedImage ); if(optimizedImage != NULL){ Uint32 colorkey = SDL_MapRGB( optimizedImage->format, 0, 0xFF, 0xFF ); SDL_SetColorKey( optimizedImage, SDL_RLEACCEL | SDL_SRCCOLORKEY, colorkey ); } } return optimizedImage; } void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination ) { SDL_Rect offset; offset.x = x; offset.y = y; SDL_BlitSurface( source, NULL, destination, &offset ); } void itoa(int x, char **pointer){ if(x == 0){ *pointer = new char[2]; pointer[0][0] = '0'; pointer[0][1] = '\0'; return; } int tempy = x; int length = 0; while(tempy != 0){ tempy/=10; length++; } *pointer = new char[length+1]; for(int i = length-1;x != 0;i--){ pointer[0][i] = x%10 +48; x/=10; } // patch it up :) pointer[0][length] = '\0'; return; } // lol ignore this. void update(){ for(int x = 0;x < 1000;x++){ for(int y = 0;y < 1000;y++){ int temp = x*y; temp+=50000; } } }
  15. I just tested it in fullscreen and the same thing happened, 90 FPS. This is so frustrating, it should work without any issues at all. My pc shouldn't be struggling to get 100fps in software mode when its doing nothing. It still uses all my CPU as well. Looks like I'll have to move onto something else which is annoying because I thought SDL would be good. Thanks for the heads up on the Software in windowed mode thingy though, I didn't know about that.