Advertisement Jump to content
  • Advertisement

rethan

Member
  • Content Count

    101
  • Joined

  • Last visited

Community Reputation

149 Neutral

About rethan

  • Rank
    Member
  1. rethan

    Fixing time step

    Well, here are some specific examples: - if you want to do 30 physics ticks per second, your physics tick function should take (much) less than 1/30 seconds to complete, otherwise you'll start to stutter because you are doing physics all the time and you'll fall behind when rendering frames. - If you want to do 30 physics ticks per second and your physics tick function takes 1/60 seconds, then you can draw as many frames that can fit in the other 1/60 seconds. So if your draw function is slow, you'll stutter, but if it's fast that will help smooth out the fast moving objects that get interpolated via "extra_time". If during play there is a hickup (some other process hogs the cpu, some single frame took way long to render than usual etc) and you need to catch up on some physics ticks, you'd end up doing a number of catchup physics ticks before rendering again (which will cause things to jump to the user). This is a case you may want to plan for by limiting the number of catchup physics ticks to run, and/or by limiting the wall clock time that the physics is allowed to take to catch up etc. So worst cases: - if your physics takes a long time, your game will become sluggish/slow (the FPS becomes choppy, the game looks like it's in slow-mo). - if your graphics takes a long time, your game will become unresponsive (things happen that the user can't react to properly).
  2. rethan

    Fixing time step

    You basically decouple rendering from the physics tick. The basic idea is: Example, you want to do 20 physics ticks per second, render as fast as possible: 20 ticks per second means you want the time between ticks to be 1 sec / 20 ticks/sec = 0.05 seconds or 50 ms - keep track of when the last time you did a physics update. (Time A) - the next physics tick should then happen at (Time A + Time between ticks) So you'd have a while loop that does something like [source lang="cpp"] while (play_game) { current_time = getthesystemtime(); while (last_physics_tick + time_between_physics_ticks > current_time) { do_physics_tick(current_time); last_physics_tick += time_between_physics_ticks; } // Here you want to draw a frame based on the current physics state // but the frame would only look accurate if past_physics_tick == current_time, // so what you want to do is interpolate movement of objects here by: extra_time = current_time - last_physics_tick. // aka you want to show things as they currently look, which is // last_physics_tick + extra_time (= current_time) // So, this call should draw the frame given the current physics state // and interpolate the position (or whatever) of the objects based on say // the latest velocity of the last tick. draw_frame(extra_time); } [/source] Hope that helps!
  3. Won't that make you start littering item management code with conditionals? I assume it depends on how complicated your item system is and how well this maps to tracking quests. DrEvil/Khatharr any write-ups on this method you could point us to? Thanks!
  4. Immediate mode UI (as linked above) is fairly straight forward and easy to get started in, you may also want to read up on retained mode UIs, both have their benefits and drawbacks depending on your particular use case.
  5. rethan

    Fixing time step

    Yep, even if the time steps don't vary that much between two computers, small discrepancies when doing floating point math will accumulate and after some time the two simulations will get out of sync (and the problem only gets worst as time goes on.) In fact, with varying time steps, the same computer running with the same inputs can (most likely will) produce different results, which can be problematic when hunting bugs etc. And yes, L. Spiro's has some great resources
  6. Ultimately the "ideal" game loop depends on the game but my personal take: I agree with bollµ that #1 is by far easier to code and gives good results (I do this myself as well). And sure, as L. Spiro points out you will realistically get around 29.99 fps or below if you lock at 30fps, but I don't believe this is such a huge problem in practice, and even then the fluctuations in real FPS should mostly be minor (IMO much less so than the fluctuations you will get if you allow rendering as fast as possible) L. Spiro, you do point out some very good things to keep in mind when implementing this in your writeup (which I think got for any loop implementation), namely to make sure to get the current time only once per tick, storing time values in 64 bit ints, and making sure you always pass/use the same duration/time lapse for each tick to be consistent. (You may also want to talk about how to avoid wrap around timer issues by checking difference between times instead of checking absolute times too!) I think the major problem with #3 is just getting it right. It is extremely, extremely easy to botch this, and if you go this route, you will need to decide which parts/objects that get drawn should be interpolated to take advantage of the extra fps (only fast moving objects, or all objects, what's the cutoff? other graphical variances like color changing etc?). And the other moral dilemma you will have to consider with this option is that what the user sees may not match the physics, aka hitboxes that don't correspond to what is shown visually which can be frustrating. That said, if this is done correctly, this does give awesome results and is pretty much required for networked games anyways which need prediction to visually smooth things out to begin with. But hey, when in doubt, write both and compare yourself
  7. rethan

    Death-less punishment mechanic?

    Not sure what the exact style of the player/monster but, the AI monster could "eat" you and either spit-launch you back to an earlier place/checkpoint, or move around and poop you out elsewhere (adds some comedy) Or, he could knock you off/push you around/make your life hard unless you do something like use energy somehow to distract it/send it scurrying off (so basically you have to sacrifice energy for some peace and quiet.) Hope that helps.
  8. rethan

    Two free models available for download

    I like the hammer bot
  9. rethan

    How many of you use C for game programming?

    I use C for almost all of my programming because I like the simplicity of C over C++. I also agree with previous posters that some C++isms make the code harder to read/follow but that's probably because I don't code in C++ much. I have yet to come across a problem that just cannot be coded in C, and any extra bit you may need to get something working in C that is "easier" in C++ seems to me is gained back in the clarity of the language.
  10. If you're trying to make a minecraft clone with an earth instead of a flat map, then height maps may not be of much use I think.
  11. Perhaps you've visited here: http://vterrain.org/Implementation/Libs/triangulate.html Yes, triangulation isn't as easy as it seems at first, so I personally use the (OpenGL) glu lib's triangulation functions and haven't had any problems (it supports holes etc).
  12. rethan

    3d array in 1d array

    How are you using IX in code? You may want to not have a semicolon at the end, i'd do: #define IX(x,y,z) ((x) + ((y) * (N)) + ((z) * (N) * (N)) ) (And I add more ()'s just because I'm paranoid)
  13. rethan

    French Burqa Ban

    Quote:Original post by Yann L Quote:Original post by rethan Also FYI, I've seen quite a few "King France" and "President France" - you guys do realize that France is a country, and Nicolas Sarkozy is the current President of it, right? Well, sometimes you have to wonder. Sarkozy does act a little like a King, if you ask me. Not sure what you mean here. Specifically how do you see him acting like a King, vis-a-vis other Presidents of Westernized nations?
  14. rethan

    French Burqa Ban

    I remember a (seemingly odd, at first) statistic that most women that do wear the burqa in "Western" countries do so of their own free will. Another interesting tidbit to help drive this home, is that it is the women themselves that police each other in Islamic countries. If you look at news feeds where Westerners are jailed for wearing too little, you'll notice a common thread that it is women and not men that are primarily offended and report the incidents: http://www.dailymail.co.uk/news/worldnews/article-1300477/Briton-held-wearing-bikini-Dubai-shopping-mall.html At any rate, aren't there bigger injustices of religious intolerance to be bothered about than a politically secular country banning outrageous religious garb that make the wearer look like a walking piece of black furniture, void of humanity? Also FYI, I've seen quite a few "King France" and "President France" - you guys do realize that France is a country, and Nicolas Sarkozy is the current President of it, right?
  15. rethan

    Cheating Dilema

    I guess we/I don't know anything about your setup and what you are using to code your game, so can you perhaps elaborate on why you think this would cause serious lag? I have a hard time believing that handling "reveal card" queries from clients will be a network bottleneck.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!