Fixed minor oversight (updating input on client-side)

This commit is contained in:
Barra Ó Catháin 2023-07-09 01:30:58 +01:00
parent c106094540
commit dcccf78b04
2 changed files with 10 additions and 3 deletions

View File

@ -44,6 +44,11 @@ side prediction described in the second article. I'd imagine there's still a lot
more to deal with, but we'll see how much of a difference this makes to how it more to deal with, but we'll see how much of a difference this makes to how it
feels. I'll report back. feels. I'll report back.
** Entry 04: Whoops, little oversight!
I didn't make the client update it's own input in the state constantly, so there
wasn't the required "single-player" feeling in the client. Not exactly what
we're going for, here!
* Notes On Techniques: * Notes On Techniques:
** Entry 00: Where I'm Learning All This From: ** Entry 00: Where I'm Learning All This From:
I'm using a series of articles from gabrielgambetta.com, which seem to be well I'm using a series of articles from gabrielgambetta.com, which seem to be well

View File

@ -91,11 +91,13 @@ void * networkHandler(void * parameters)
} }
} }
void * gameThreadHandler(void * arguments) void * gameThreadHandler(void * parameters)
{ {
struct threadParameters * arguments = parameters;
while (true) while (true)
{ {
doGameTick(arguments); updateInput(arguments->state, arguments->message);
doGameTick(arguments->state);
usleep(15625); usleep(15625);
} }
} }
@ -258,7 +260,7 @@ int main(int argc, char ** argv)
parameters.message = clientInput; parameters.message = clientInput;
parameters.state = currentState; parameters.state = currentState;
pthread_create(&graphicsThread, NULL, graphicsThreadHandler, &parameters); pthread_create(&graphicsThread, NULL, graphicsThreadHandler, &parameters);
pthread_create(&gameThread, NULL, gameThreadHandler, currentState); pthread_create(&gameThread, NULL, gameThreadHandler, &parameters);
pthread_create(&networkThread, NULL, networkHandler, &parameters); pthread_create(&networkThread, NULL, networkHandler, &parameters);
while (continueRunning) while (continueRunning)