diff --git a/netwar.c b/netwar.c
index b18f8ac9d7a5f288d546dcacbd8de65f30a3629e..a3236f122f95dd8ff4a6d58c3dcee5668fd856ac 100644 (file)
--- a/netwar.c
+++ b/netwar.c
static char * host = "localhost";
static char * nick = "Anonymous";
static char * host = "localhost";
static char * nick = "Anonymous";
-static uint16_t port = DEFAULT_PORT;
+static uint16_t port = PROTOCOL_PORT;
static SDL_Window * window;
static SDL_Renderer * renderer;
static SDL_Window * window;
static SDL_Renderer * renderer;
static void keyboardhandle() {
SDL_PumpEvents();
const Uint8 * key = SDL_GetKeyboardState(NULL);
static void keyboardhandle() {
SDL_PumpEvents();
const Uint8 * key = SDL_GetKeyboardState(NULL);
- if(key[SDL_SCANCODE_UP])
- cl_move(DOES_UP);
- if(key[SDL_SCANCODE_DOWN])
- cl_move(DOES_DOWN);
- if(key[SDL_SCANCODE_LEFT])
- cl_move(DOES_LEFT);
- if(key[SDL_SCANCODE_RIGHT])
- cl_move(DOES_RIGHT);
- if(key[SDL_SCANCODE_LCTRL])
- cl_move(DOES_FIRE);
+ cl_move((DoesBits) {
+ .up = key[SDL_SCANCODE_UP],
+ .down = key[SDL_SCANCODE_DOWN],
+ .left = key[SDL_SCANCODE_LEFT],
+ .right = key[SDL_SCANCODE_RIGHT],
+ .fire = key[SDL_SCANCODE_LCTRL],
+ });
}
int main(int argc, char ** argv) {
}
int main(int argc, char ** argv) {
cl_connect(host, port);
cl_connect(host, port);
- Uint32 lastTime = SDL_GetTicks();
- Uint32 currTime = SDL_GetTicks();
-
- while(cl_isrun()) {
+ while(cl_playerid >= 0) {
SDL_Event event;
while(SDL_PollEvent(&event))
if(event.type == SDL_QUIT)
goto cleanup;
SDL_Event event;
while(SDL_PollEvent(&event))
if(event.type == SDL_QUIT)
goto cleanup;
- cl_recv();
+ keyboardhandle();
- if(currTime - lastTime >= TICK_DELAY) {
- keyboardhandle();
- g_update();
- lastTime = SDL_GetTicks();
- }
- currTime = SDL_GetTicks();
+ cl_handle();
paintwindow();
paintwindow();