Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 07 Mar 2002
Offline Last Active Yesterday, 09:13 PM

Posts I've Made

In Topic: A quick way to determine if 8 small integers are all equal to each other

Yesterday, 08:30 PM

For some "small integers" (like unsigned 8-bit integers), you can read them all in as a single large integer and then do

  return my_i64 == (((my_i64) & 0xffull) * 0x0101010101010101ull);

In Topic: How should my Networking class send and receive info from my other classes?

Yesterday, 07:54 AM

[DISCLAIMER: I have no actual experience with this, but I have thought about it over the years, and I am a fairly good thinker. :)]

Alberth is basically right.

A first iteration of your main loop may look like this:
  * collect actions from player and submit them to the network
  * collect actions from the AI and from the network
  * execute actions
  * display
Of course if you need to wait to get the actions from the network every frame, there will be lag. So some thought is needed to make things run smoothly.

One possible solution is to introduce a delay before the actions are executed. Divide time into "turns" and when the user tries to do something you just schedule that action for 3 turns later, say. As long as you manage to propagate that information using the network within the 3 turns, everything will run smoothly. I believe this is what StarCraft did.

Other games (e.g., FPS) require faster reaction to the player's inputs, so different solutions are needed. I believe a common approach for those games is having a server that keeps track of what the official state of the world is, and each player is running a client. The clients send the actions of each player to the server, and the server sends updates to the clients to keep their states as synchronized as possible. The clients will display the locations of objects using extrapolation, so things seem to move smoothly even if we haven't heard from the server for a few frames. Important events, like people getting hit by a bullet, only happen when the server says they happen.

The latter solution sounds like it's very hard to get right, but many games have managed to pull it off. If by the nature of your game you can get away with the former solution, I would go for that.

In Topic: 3d representations

20 October 2016 - 11:32 PM

Yeah thats basically what I mean although doesn't NURBS fall under high order surfaces?

Maybe. I'm not sure what "order" means in this context. Does it just mean "degree"?

In Topic: 3d representations

20 October 2016 - 03:48 AM

Off the top of my head: Voxels, metaballs, parametric equations, subdivision surfaces, NURBS. Is that the kind of thing you were looking for?

In Topic: c++, passing std::container without template

20 October 2016 - 01:29 AM

They are not polymorphic, so no. You either have to template or just write every allowed overload.

for(auto it=c.begin();it!=c.end();it++) {
can be
for(auto&& thing : c) {

You almost certainly mean this:
for(auto it=c.begin();it!=c.end();it++) {
can be
for(auto&& thing : c) {