Auriya

Members
  • Content count

    49
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Auriya

  • Rank
    Member
  1. ---------------------------------------------- Edit: Nevermind, solved it. In case anyone ever stumbles on the same problem: Apparently GetTickCount() is unreliable, it's best to use QueryPerformanceCounter() or QueryPerformanceFrequency() instead. ---------------------------------------------- Hello again everyone! I'm here again with a (hopefully) small issue I'm having. I'm having some choppyness in my game project, using C++ and SFML as library for graphics. I wasn't sure where the choppyness came from, it could have been the forced vsync by calling UseVerticalSync( true );, or limiting the frames to 60 by calling SetFramerateLimit( 60 );. I read a lot about game loops lately, about fixing your timestep and interpolation. I have given it a try several times but kept getting stuck and it not working properly. However today I thought I'd put together a very bare project displaying nothing but 1 scrolling sprite. Did that, and added a "Constant Game Speed independent of Variable FPS" game loop going at 60 frames per second. I was surprised to find that, having the exact same choppyness my game project had. So here I am again, hoping that one of the pros/gurus could once again point out what I'm perhaps doing wrong. This is the source of the small sample I put together that has the choppyness. int main() { // Create main window sf::RenderWindow App(sf::VideoMode( 800, 600 ), "Interpolation Test"); const int TICKS_PER_SECOND = 60; const int SKIP_TICKS = 1000 / TICKS_PER_SECOND; const int MAX_FRAMESKIP = 5; DWORD next_game_tick = GetTickCount(); int loops; float interpolation; // Create the Image/Sprite sf::Sprite sprite; sf::Image spriteImage; spriteImage.LoadFromFile( "data/images/entity.png" ); sprite.SetImage( spriteImage ); // Set the sprite's variables float spritevelx = 0; float spritevely = 0; float spriteposx = 0; float spriteposy = 400; float speed = 2; spritevelx = speed; // Start game loop while (App.IsOpened()) { // Get Input const sf::Input& Input = App.GetInput(); left_pressed = Input.IsKeyDown(sf::Key::Left); right_pressed = Input.IsKeyDown(sf::Key::Right); up_pressed = Input.IsKeyDown(sf::Key::Up); down_pressed = Input.IsKeyDown(sf::Key::Down); z_pressed = Input.IsKeyDown(sf::Key::Z); z_released = Input.IsKeyDown(sf::Key::Z); x_pressed = Input.IsKeyDown(sf::Key::X); // Process events sf::Event Event; while (App.GetEvent(Event)) { // Close window : exit if( Event.Type == sf::Event::Closed ){ App.Close(); } } // The Loop where we do the movement of the sprite (and or other logic/ai/movement/etc) loops = 0; while( GetTickCount() > next_game_tick && loops < MAX_FRAMESKIP) { // Determine whether to bounce back or not if( ( spriteposx + spriteImage.GetWidth() ) >= 800 ) { //spritevelx = -speed; spriteposx = 0; } if( spriteposx <= 0 ) { //spritevelx = speed; } // Move the sprite further and set it's position spriteposx += spritevelx; sprite.SetPosition( spriteposx, spriteposy ); next_game_tick += SKIP_TICKS; loops++; } interpolation = float( GetTickCount() + SKIP_TICKS - next_game_tick ) / float( SKIP_TICKS ); // Draw the sprite (as often as we can, like the guide says?) sprite.SetPosition( ( spriteposx + ( interpolation * speed ) ), spriteposy ); App.Draw( sprite ); // Show the buffer App.Display(); // Clear screen App.Clear(); } return EXIT_SUCCESS; } The sprite I used is a simple blue square block included below; Edit: Changed TICKS_PER_SECOND to 60, it was set to 200 when I was testing something quick, forgot to change it back before pasting it in here. [Edited by - Auriya on December 31, 2010 12:55:07 AM]
  2. Hey! I think this is the wrong section to ask for ideas.. You may get better replies here; http://www.gamedev.net/community/forums/forum.asp?forum_id=32 Also, I'm not sure if I'm a tad on my toes here or not, or too paranoid, since I know this is not 4chan. But key words you used in your topic's title/body in combination with your username kinda suggests you may not be serious/trolling about your post. "mmo" in combination with "13 years old" as well as "halo" by someone called "kakorot" (thinking of dbz -> vegeta -> over 9000,) just..sounds weird, I don't mean to offend or anything, don't get me wrong. I could be totally wrong. But if you're serious, I would not start with an "mmo", but rather something a little simpler, like tetris, pong or the sort. (Plus, mmo's topics are more at home in the networking board?) Ofcourse I'm not taking into account how far your skills are either. If you know enough to start with UDK, then that's great! Good luck!
  3. Yeah, I know this one which is widely used by some game developers; LightWeight Java Game Library (http://lwjgl.org/) Minecraft was built with it. Hope this helps! ;]
  4. Solved! ..I think. At least it seems to be so far. I'm gonna throw some more at it to see if it holds up or not.. Added: SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); to the initialization and it seems to have no more problems at all. This apparently turns on Vsync for the app/game or something in that direction? I came across it in another thread here: http://www.gamedev.net/community/forums/topic.asp?topic_id=529217 If anyone else knows something, please do let me know! Thanks for all the help! ~j
  5. Hey! As far as I know glClear clears the screen, so using it after swapping buffers should (I think) be okay, but just in case I moved it to right before drawing, but sadly that didn't help. Fullscreen also doesn't seem to help, I see the same thing as in Windowed mode. I do notice that without the 60fps code in place, on Windows it keeps to 60fps (which I think my screen is set to as well,) however on OSX it seems to go haywire over hundreds of fps. Though even without the fps code and vsync on on my windows computer, the occasional flickering/hang/glitch(?) still seems to happen every now and then, but not as constantly as it does on OSX. Very strange..I'm really puzzled by this and have no idea what I have to do to solve it.. Thanks you though, I'm really grateful for the help! :) Big update: This is very strange. I moved the line: currentTick = SDL_GetTicks(); All the way below to right before the FPS capping, and printf'd the current FPS and it seems that now, instead of being capped at 63fps, it is now properly capped at 60fps, which seems to get rid of the glitch. However it very often jumps to 61fps, which makes the line/glitch come back until it drops down to 60fps again..so clearly it's the game sometimes refreshing faster than my screen? Since previously when I had the glitch heavily it was running at 63fps (even though I told it to cap it at 60) due to having misplaced the line of code. Does that mean I simply have to find a good way to cap the FPS or something else? Is there a different way to go besides VSync? Sorry for the questions, I'm just very curious as well as anxious about a solution. Thanks so far! ~j [Edited by - Auriya on August 23, 2010 12:28:27 PM]
  6. Thank you very much for looking into it! I really wonder what I must've done wrong..I'm quite new to OpenGL, sorry if it's something I should've seen coming!
  7. Hey! I have Forced VSync on on my Windows computer through the NVidia Panel (GT 130M - 1GB) and that seemed to have slightly helped, it's not very noticeable when scrolling from left to right, but when scrolling to the bottom left (from top left) it seems to be quite visible quite a bit. Though on OSX I'd have to check whether VSync is on or not.
  8. Hello again everyone! I've been learning OpenGL to use with SDL because I'm starting to build up confidence for 3d. But for now, I'm still sticking to 2D, and I've noticed that the CPU usage is tremendously less than SDL-Only when I use SDL with OpenGL, so I like it very much! However, as I've put together a quick 2d scrolling map which seems to work very well so far, but there's a minor glitch I'm haunted by. I first thought it might have been the video card not refreshing fast enough, but the other computer seemed to have a pretty similar glitch. On Windows it seems as if the scrolling is skipping 1~2pixel(s) each second or so, and on OSX it looks a tad worse (see video and screenshot) as the glitch seems to quickly go from the bottom of the game-screen to the top and then disappear. I have linked to my source code below. The reason I'm not including snippets of code is because I have no idea where I should be looking to perhaps fix this..I tried to mess about with the drawing code and the map-loop-tile-by-tile-drawing (drawMap()) but nothing helped. If anyone has enough free time and could maybe look at the source to help me out I'd be eternally grateful! If not, thanks anyway! Every tip is very welcome! Small update: In the video the scrolling seems choppy (as if it get stuck or lags heavily) at around the end of the video but it's not. It's going very smooth. Update#2: Also, when I scroll, it seems to become a tad blurry or fuzzy, is that supposed to happen? Source: http://bluemelody.info/src.zip Screenshot: http://i37.tinypic.com/2ahryfn.png Video: http://www.youtube.com/watch?v=kWoPrWn5c8Q (Taken with a cam because onscreen recorders didn't seem to somehow notice the glitch(?)) (Sorry for the very rushed post..I have to get to work in a couple so I'm gonna grab some breakfast quick. I'll be watching the thread and updating it if I forgot to include anything..) Thanks in advance all, cheers! ~j [Edited by - Auriya on August 23, 2010 1:02:41 PM]
  9. (C/C++) Inheritance/public problems

    Quote:Original post by SiCrane Your problem now isn't multiple inclusion, it's circular inclusion. Read this and pay attention to problem 2. Thank you, that link helped me lots! A friend of mine already slammed some logic into me with "Idiot, your mom can't inherit from you as you have inherited from her. Your problem right there." Quote:Original post by DevFred This is screaming "anti-pattern". What are you trying to achieve with your globals.h? In previous games I included all my .h files into globals and included into main (and other files that needed certain files,) should I find myself lucky my games didn't create a black hole or something? If this is a bad idea I'll have to [really] go back and change the code in those games! ( Edit: Sorry for the late reply, ISP found it funny to break irrelevant things during maintenance. )
  10. (C/C++) Inheritance/public problems

    Quote:Original post by Juanxo hey auriya. The errors that you have are cause you need to include class headers in order to use objects of this class. You just need to add this below #include "globals.h": #include "playernpcs.h" (in ItemDatabase.h) #include "ItemDatabase.h" (in PlayerNPCs.h) Hey! I have included both header files into globals.h, which are included into both header classes. Globals.h: http://pastie.org/private/ekqfkldbpmrqch7hxtsdxg Could that be the cause? (Multiple inclusions? I heard about it but I was told #ifndef, #define and #endif takes care of that..) ~J
  11. (C/C++) Inheritance/public problems

    Well, I only recently started looking into inheritance as I understood they came in very handy. I didn't see that part, nor knew that wouldn't work, my bad. I removed the inheritances: PlayerNPCS.h: http://pastie.org/private/cnt7qlmrkzpweesffkvdmw ItemDatabase.h: http://pastie.org/private/aik4hatqq6yy1o0fdsra 2 errors: http://i49.tinypic.com/vy2rkz.png It still says that the clas(ses) are undefined, I'm really missing something big here huh? Basically anything in the files now is nothing I haven't done before and had working (except for the inheritance part which was something new I was trying out.) Sorry if it's quite a stupid thing I'm missing, I don't consider myself out of beginner-stage just yet. Thanks for the help so far! ~j
  12. Hello everyone! I've been dangling between Windows' Visual Studio 2010 and Mac OS X' Xcode trying to get this to work. At first I thought it was Xcode (since I mainly develop on Mac OS X,) but as I've seen Visual Studio react the same I'm certain it's my code..even though I followed a couple of guides on inheritance very well. These are the errors I'm getting: http://i46.tinypic.com/30c22kp.png Global.h http://pastie.org/private/ekqfkldbpmrqch7hxtsdxg ItemDatabase.h http://pastie.org/private/haitralizords0eryua PlayerNPCS.h http://pastie.org/private/8a0grvqrd9pgx7r5qqca The main.cpp simply contains an int main() including the globals.h Now, I have been doing web development for the past 2 years (needed to get a development machine together,) so I'm rusty on C/C++. I thought I'd greatly refresh my memory and start working towards fulltime game development again as I finally find myself have more free time. In any case, sorry to drift off. Does anyone perhaps see what I'm doing wrong? To learn about inheritance I read and followed several articles including the first place I usually check, cplusplus.com; http://www.cplusplus.com/doc/tutorial/inheritance/ But obviously I'm probably doing something wrong lol.. Any help is appreciated, thanks all! :) ~J Edit: P.S. I hope I included enough information..if not, please let me know and I'll include anything else that's needed. :)
  13. Platformer - map[100][1000] too much?

    Hello! Wow, so many information, thank you very much! I will look into them and see how it goes. I will definitely read up on std::vector as I used it many times before without actually completely understanding it.. The game already only draws whatever is around the player ;] Thank you for the quick replies everyone, I really I love this place, it's full of knowledge! ;D
  14. Platformer - map[100][1000] too much?

    Hey! Well, I've just checked out how big 2500 would be, and it indeed looked quite big, but after having tried out map[1000][100] it was perfect. The tile size is 32x32, so now the map will be about 32000x3200, which in the game resolution (800x640 - windowed) is a good 40 game-screens in width. Trying again.. 100*1000 being 100,000, that * 2 is 200,000 in bytes, which is a rough 200kb..? And the tiles are stored in a single surface, then the integers that represent that tile are pulled from the file map.dat which contains the whole map's integers with spaces in between each integer. This is the example test tileset I'm using right now; http://bluemelody.info/skitch/wind_tileset_testroom-20100413-230340.png And the map: http://bluemelody.info/skitch/map.txt (I'm guessing that showing is the quickest and most clear way rather than trying to explain in the finest details which I'm not very good at. ;p ) Anyway I'll change the title of the topic too to reflect the change. Thanks for the quick reply! ;]
  15. Edit: in my next post you can see that I actually changed 2500 to 1000 since 2500 appeared to be a bit too big. Hello everyone! ;] Wow, I haven't been on here for so long! I've come with a rather beginner question since I'm still widely exploring the possibilities and limits for game development. Right now I'm using SDL and am working on a Platformer. My maps exist of separate arrays, map[100][100] and collission[100][100], but after creating the map editor I found that [100][100] is actually too small. It would only be about 5 screens in width. While in height it's perfect, in width it is not. So I was wondering if it would be too much to make the map [2500][100], that way the level width is 32*2500 instead of the previous 32*100. (32 being the tile size in width and height.) I know 2500 sounds a lot bigger than 100, but it seems to be more than fit for the long levels I'll be making, only if it's possible though- which is why I'm here. ;] Please let me know if this is too crazy and what I could do best. And I've read that I could've also made a tile class which holds properties like 'destroyable', 'solid'/etc, but since I'm this far into the project already- and it's gonna be a quite simple one I decided to move on with what I already had, which is an array (with the same width and height as the map) which holds the data for solid blocks. (+ the fact that I don't have THAT much experience in game development so it'd be something I'm gonna try for my next project.) --- Edit: Hm, now I think about it, 2500 may actually be big, but then I'm wondering. How would a platformer pull off long levels? I'll take any information I can get. I was told 2500 would be just fine, but he's quite a..beginner himself too, so I thought I'd come ask here. ;] [Edited by - Auriya on April 13, 2010 3:34:48 PM]