diff --git a/netwar.c b/netwar.c
index 2419456d87d0dea2265c5f9e47422286359258ab..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;
SDL_RenderDrawLines(renderer, pixship, count);
}
SDL_RenderDrawLines(renderer, pixship, count);
}
+ for(int i = 0; i < MAX_BULLETS; i++) {
+ if(g_bullet[i].owner == cl_playerid)
+ SDL_SetRenderDrawColor(renderer, 0x00, 0xFF, 0x00, 0x00);
+ else
+ SDL_SetRenderDrawColor(renderer, 0xFF, 0x00, 0x00, 0x00);
+
+ int x = g_bullet[i].x * WIDTH / 2;
+ int y = g_bullet[i].y * HEIGHT / 2;
+
+ if(g_bullet[i].live)
+ SDL_RenderDrawPoint(renderer, cx + x, cy + y);
+ }
+
SDL_RenderPresent(renderer);
}
static void keyboardhandle() {
SDL_PumpEvents();
const Uint8 * key = SDL_GetKeyboardState(NULL);
SDL_RenderPresent(renderer);
}
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;
- if(currTime - lastTime >= TICK_DELAY) {
- keyboardhandle();
- g_update();
- lastTime = SDL_GetTicks();
- }
- currTime = SDL_GetTicks();
+ keyboardhandle();
- cl_recv();
+ cl_handle();
paintwindow();
paintwindow();