From 883f2bd40ea8c71766cbc92a45bb45b32e8e2639 Mon Sep 17 00:00:00 2001 From: EvanR Date: Thu, 27 May 2010 16:32:58 -0500 Subject: [PATCH] Fixed function prototypes. --- Makefile | 2 +- audio.h | 8 +++--- boot.h | 18 ++++++------- camera.h | 4 +-- console.h | 6 ++--- gameover.h | 4 +-- inner.c | 86 ++++++++++++++++++++++---------------------------------------- input.h | 2 +- kernel.h | 6 ++--- list.h | 2 +- music.h | 6 ++--- rng.h | 6 ++--- seq.h | 8 +++--- stage.h | 4 +-- text.h | 2 +- transfer.h | 12 ++++----- util.h | 2 +- video.h | 18 ++++++------- zip.h | 2 +- 19 files changed, 86 insertions(+), 112 deletions(-) diff --git a/Makefile b/Makefile index 756e20d..69b548a 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ SRC=video.c audio.c input.c kernel.c main.c gameover.c \ intro.c title.c splash.c inner.c \ synth.c seq.c midi.c orc.c dsp.c \ rng.c util.c list.c zip.c \ - hud.c camera.c + hud.c camera.c testplayer.c OBJ:=$(SRC:.c=.o) CC=gcc LIBS=-lSDL -lGL -lm -lz diff --git a/audio.h b/audio.h index 80c7e5b..2c47d95 100644 --- a/audio.h +++ b/audio.h @@ -26,8 +26,8 @@ #define BUFFER_SIZE 1024 -void audio_lock(); -void audio_unlock(); +void audio_lock(void); +void audio_unlock(void); -int audio_peak_level(); -int audio_rms_level(); +int audio_peak_level(void); +int audio_rms_level(void); diff --git a/boot.h b/boot.h index c4fc2f6..132de3c 100644 --- a/boot.h +++ b/boot.h @@ -1,15 +1,15 @@ -void stage_init(); +void stage_init(void); -void seq_init(); -void synth_init(); +void seq_init(void); +void synth_init(void); -void audio_init(); -void audio_quit(); +void audio_init(void); +void audio_quit(void); -void graphics_init(); +void graphics_init(void); -void loader_init(); -void loader_quit(); +void loader_init(void); +void loader_quit(void); -void text_init(); +void text_init(void); diff --git a/camera.h b/camera.h index 3dfce3a..bfed1db 100644 --- a/camera.h +++ b/camera.h @@ -1,4 +1,4 @@ -int camera_x(); -int camera_y(); +int camera_x(void); +int camera_y(void); void point_camera(int x, int y); diff --git a/console.h b/console.h index 838f935..dad264b 100644 --- a/console.h +++ b/console.h @@ -22,9 +22,9 @@ evanrinehart@gmail.com */ -void console_clear(); -void console_update(); +void console_clear(void); +void console_update(void); void console_scroll(int n); void console_printf(const char* format, ...); -void console_draw(); +void console_draw(void); diff --git a/gameover.h b/gameover.h index 0cf6231..eb122f2 100644 --- a/gameover.h +++ b/gameover.h @@ -22,5 +22,5 @@ evanrinehart@gmail.com */ -void game_is_over(); /* cause an event to end the program */ -int is_game_over(); /* was game_is_over executed */ +void game_is_over(void); /* cause an event to end the program */ +int is_game_over(void); /* was game_is_over executed */ diff --git a/inner.c b/inner.c index fea7e14..c64642f 100644 --- a/inner.c +++ b/inner.c @@ -20,17 +20,10 @@ #include -int cx = 0; -int cy = 0; -int cvx = 0; -int cvy = 0; +#include -int dummy_gfx = 0; - -int px = 50; -int py = 50; -int pvx = 0; -int pvy = 0; +//typedef struct player player; +static player* pl = NULL; static void update(){ /* @@ -39,34 +32,36 @@ static void update(){ dispatch collision events execute spawn and delete events */ - cx += cvx; - cy += cvy; - - int colxx; - int colyy; - int colx; - int coly; - - px += pvx; - colx = stage_xcollide(px*1024, py*1024, 8*1024, 8*1024, pvx, &colxx); - if(colx){ - px = pvx > 0 ? colxx/1024 - 8 - 1 : colxx/1024 + 1; - } - - py += pvy; - coly = stage_ycollide(px*1024, py*1024, 8*1024, 8*1024, pvy, &colyy); - if(coly){ - py = pvy > 0 ? colyy/1024 - 8 - 1: colyy/1024 + 1; + + int xx; + int yy; + + int x0 = pl->x; + int y0 = pl->y; + int x1; + int y1; + + update_player(pl); + x1 = pl->x; + y1 = pl->y; + + if(stage_xcollide(x0, y0, pl->w, pl->h, x1-x0, &xx)){ + collide_x(pl, xx); + x1 = pl->x; } - point_camera(cx, cy); + if(stage_ycollide(x1, y0, pl->w, pl->h, y1-y0, &yy)){ + collide_y(pl, yy); + } + } static void draw(){ - stage_draw_bg(cx, cy); + stage_draw_bg(0, 0); //entity_draw_visible(cx, cy); - stage_draw_fg(cx, cy); - draw_gfx(dummy_gfx,px,py,16,0,8,8); + stage_draw_fg(0, 0); +// draw_gfx(dummy_gfx,px,py,16,0,8,8); + draw_player(pl); //hud_draw(cx, cy); } @@ -77,34 +72,12 @@ static void press(input in){ game_is_over(); return; } - //printf("press: %s\n", input_str(in)); - - switch(in.button){ - case LEFT_BUTTON: pvx += -1; break; - case RIGHT_BUTTON: pvx += 1; break; - case UP_BUTTON: pvy += -1; break; - case DOWN_BUTTON: pvy += 1; break; - default: break; - } - /* - send input events - */ + player_press(pl, in.button); } static void release(input in){ - //printf("release: %s\n", input_str(in)); - - /* - send input events - */ - switch(in.button){ - case LEFT_BUTTON: pvx -= -1; break; - case RIGHT_BUTTON: pvx -= 1; break; - case UP_BUTTON: pvy -= -1; break; - case DOWN_BUTTON: pvy -= 1; break; - default: break; - } + player_release(pl, in.button); } void setup_inner(){ @@ -112,6 +85,7 @@ void setup_inner(){ console_clear(); set_handler(update, draw, press, release); + pl = mk_test_player(16*3,4*16); unload_zone(); int x = load_zone("woods"); diff --git a/input.h b/input.h index f4944d7..68a1ca6 100644 --- a/input.h +++ b/input.h @@ -63,7 +63,7 @@ typedef struct { void input_init(const char* filename); void save_input(const char* filename); -input get_input(); +input get_input(void); void remap_last_input(enum input_button, int player); void print_last_raw(char* buf, int size); diff --git a/kernel.h b/kernel.h index cebea05..38a450c 100644 --- a/kernel.h +++ b/kernel.h @@ -22,7 +22,7 @@ evanrinehart@gmail.com */ -void draw(); -void update(); -void initialize(); +void draw(void); +void update(void); +void initialize(int argc, char* argv[]); diff --git a/list.h b/list.h index 6d6f9b7..4972f6c 100644 --- a/list.h +++ b/list.h @@ -6,7 +6,7 @@ struct list { typedef int (*compare_func)(void* v1, void* v2); -list* empty(); +list* empty(void); void push(list* L, void* item); void* pop(list* L); void append(list* L, void* item); diff --git a/music.h b/music.h index 2e40643..7c50c61 100644 --- a/music.h +++ b/music.h @@ -30,17 +30,17 @@ typedef enum { int music_load(string filename, mus_id id); void music_unload(mus_id id); -mus_id music_current(); +mus_id music_current(void); void music_play(mus_id id); void music_stop(mus_id id); -void music_pause(); +void music_pause(void); void music_volume(int precent); void music_fadeout(int seconds); void music_print(mus_id id); -void music_debug(); +void music_debug(void); /* the music player diff --git a/rng.h b/rng.h index e737359..27b5907 100644 --- a/rng.h +++ b/rng.h @@ -9,10 +9,10 @@ This software comes with no warranty. 2. Modifications must retain this license, at least in spirit. */ -unsigned zrand(); +unsigned zrand(void); void zseed(unsigned data[], unsigned carry); void zread(unsigned data[], unsigned* carry); -void zreset(); +void zreset(void); void zsrand(unsigned s); -void zsrand_u(); +void zsrand_u(void); diff --git a/seq.h b/seq.h index 5766524..cb95dd4 100644 --- a/seq.h +++ b/seq.h @@ -32,11 +32,11 @@ event* seq_get_immediate(); /***/ void seq_instant(int type, int chan, int val1, int val2); -void seq_clear(); +void seq_clear(void); void seq_load(list* events); void seq_seek(list* target); -list* seq_tell(); -void seq_enable(); -void seq_disable(); +list* seq_tell(void); +void seq_enable(void); +void seq_disable(void); void seq_append(event* e); diff --git a/stage.h b/stage.h index 7e091a0..b909ba0 100644 --- a/stage.h +++ b/stage.h @@ -22,8 +22,8 @@ int load_zone(string filename); -void unload_zone(); -void stage_debug(); +void unload_zone(void); +void stage_debug(void); void switch_stage(string id); diff --git a/text.h b/text.h index b847d93..57ac40f 100644 --- a/text.h +++ b/text.h @@ -22,5 +22,5 @@ /* text */ -void text_init(); +void text_init(void); int load_font(string filename); diff --git a/transfer.h b/transfer.h index d095924..6de6634 100644 --- a/transfer.h +++ b/transfer.h @@ -1,11 +1,11 @@ -void setup_inner(); -void setup_splash(); -void setup_intro(); -void setup_title(); +void setup_inner(void); +void setup_splash(void); +void setup_intro(void); +void setup_title(void); void set_handler( - void (*update)(), - void (*draw)(), + void (*update)(void), + void (*draw)(void), void (*press)(input in), void (*release)(input in) ); diff --git a/util.h b/util.h index ab8bd66..2f58c90 100644 --- a/util.h +++ b/util.h @@ -36,7 +36,7 @@ int unicode_getc(char* str, utf32* u); void rand_reset(unsigned s); int randi(int a, int b); -double randf(); +double randf(void); char* path_ending(char* path); diff --git a/video.h b/video.h index 0058b48..9f4b5ec 100644 --- a/video.h +++ b/video.h @@ -34,27 +34,27 @@ void video_init(int argc, char* argv[]); -void video_quit(); +void video_quit(void); -int since(); /* ms since last time since() was called */ +int since(void); /* ms since last time since() was called */ void delay(int ms); /* wait ms ms */ -void update_video(); -void clear_video(); +void update_video(void); +void clear_video(void); /* gfx control */ int load_gfx(const char* filename); void draw_gfx(int gfxid, int x, int y, int X, int Y, int W, int H); void draw_gfx_raw(int gfxid, int x, int y, int X, int Y, int W, int H); -void clear_gfx(); +void clear_gfx(void); void gfx_dimensions(int gfxid, int* w, int* h); void screen_dimensions(int* w, int* h); void draw_black_rect(int x, int y, int w, int h); -void fps_update(); -void fps_draw(); -int get_fps(); +void fps_update(void); +void fps_draw(void); +int get_fps(void); -void load_panic_gfx(); +void load_panic_gfx(void); void map_pixel(int mx, int my, int *x, int *y); diff --git a/zip.h b/zip.h index 24e581e..a285b8f 100644 --- a/zip.h +++ b/zip.h @@ -34,4 +34,4 @@ zip_dir* zip_opendir(zip_archive* arc, const char* path); char* zip_readdir(zip_dir* dir); void zip_closedir(zip_dir* dir); -char* zip_geterror(); +char* zip_geterror(void); -- 2.11.4.GIT