34 struct tile
* undo
; /* writes to undo */
35 struct tile
* redo
; /* writes to redo */
42 /* application state variables */
43 int toggle_background
= 1;
44 int toggle_bgtiles
= 1;
45 int toggle_fgtiles
= 1;
46 int toggle_shapes
= 0;
50 static int camera_x
= 0;
51 static int camera_y
= 0;
53 const char shapechars
[20] = "Mmw12345678abcd";
55 char my_file
[256] = "";
56 char my_file_old
[256] = "";
57 char bgimage_file
[256] = "";
58 char fgtiles_file
[256] = "";
59 char bgtiles_file
[256] = "";
60 char zone_path
[256] = "";
67 int select_enable
= 0;
73 struct tile
* raw_tiles
= NULL
;
77 int show_favorites
= 0;
78 int bg_favorites
[7] = {0,1,2,3,4,5,6};
79 int fg_favorites
[7] = {0,1,2,3,4,5,6};
84 int eyedrop_enable
= 0;
90 int background_dialog
= 0;
91 int tileset_dialog
= 0;
93 int save_as_dialog
= 0;
95 int confirm_save_dialog
= 0;
102 int tile_panel_set
= 0;
103 int tile_panel_page
= 0;
104 int tile_panel_offset
= 0;
106 char save_as_buf
[256] = "";
108 char open_buf
[256] = "";
110 char generic_buf
[256] = "";
113 char gfx_path_buf
[256] = "";
114 char stage_path_buf
[256] = "";
120 void update_window_name(){
122 SDL_WM_SetCaption("unnamed", NULL
);
125 SDL_WM_SetCaption(my_file
, NULL
);
130 void select_bgfile(char* path
){
131 strcpy(bgimage_file
, path
);
134 void set_zone_path(char* path
){
135 strncpy(zone_path
, path
, 256);
137 if(zone_path
[strlen(zone_path
)-1] != '/'){
138 strncat(zone_path
, "/", 256);
143 int file_exists(char* path
){
144 FILE* f
= fopen(path
, "r");
154 char* compute_stage_path(char* stage
){
155 strcpy(stage_path_buf
, zone_path
);
156 strcat(stage_path_buf
, "stages/");
157 strcat(stage_path_buf
, stage
);
158 return stage_path_buf
;
161 char* compute_gfx_path(char* gfxfile
){
162 strcpy(gfx_path_buf
, zone_path
);
163 strcat(gfx_path_buf
, "gfx/");
164 strcat(gfx_path_buf
, gfxfile
);
169 void reload_graphics_work(char* what
, int* var
, char* filename
){
170 char* path
= compute_gfx_path(filename
);
171 if(filename
[0] == 0){
173 console_printf("blank filename for %s", what
);
175 else if(!file_exists(path
)){
176 console_printf("file not found %s", path
);
180 *var
= load_bitmap(path
);
182 console_printf("error loading %s", path
);
187 void reload_graphics(){
191 shapes
= load_bitmap("gfx/shapes.tga");
192 tools
= load_bitmap("gfx/tools.tga");
195 reload_graphics_work("background", &bgimage
, bgimage_file
);
196 reload_graphics_work("bg tileset", &bgtiles
, bgtiles_file
);
197 reload_graphics_work("fg tileset", &fgtiles
, fgtiles_file
);
204 /* base access methods */
205 struct tile
* initialize_raw(int w
, int h
){
208 struct tile blank
= {'0', 0, 0};
209 struct tile
* ptr
= malloc(w
*h
*sizeof(struct tile
));
212 *(ptr
+ i
+ j
*w
) = blank
;
225 raw_tiles
= initialize_raw(20, 15);
236 update_window_name();
239 struct tile
raw_read(int x
, int y
){
240 struct tile blank
= {'0', 0, 0};
241 if(x
< 0 || y
< 0 || x
>= raw_w
|| y
>= raw_h
){
245 return *(raw_tiles
+ x
+ raw_w
*y
);
250 int new_w
= raw_w
* 3;
251 int new_h
= raw_h
* 3;
252 struct tile
* new_tiles
= initialize_raw(new_w
, new_h
);
258 for(j
=raw_h
; j
<2*raw_h
; j
++){
259 for(i
=raw_w
; i
<2*raw_w
; i
++){
260 ptr
= new_tiles
+ i
+ j
*(3*raw_w
);
261 t
= raw_read(i
-raw_w
, j
-raw_h
);
271 raw_tiles
= new_tiles
;
274 int out_of_bounds(int x
, int y
){
275 if(x
< 0 || y
< 0 || x
>= raw_w
|| y
>= raw_h
)
281 void detect_size(int* w
, int* h
){
282 //see the minimum size necessary for the area
286 void raw_write(int x
, int y
, int layer
, int value
){
287 while(out_of_bounds(x
, y
)){
294 //shift x y by expand shift
295 //shift x and y by origin
297 struct tile
* ptr
= raw_tiles
+ x
+ raw_w
*y
;
309 void draw_background(){
311 gfx_dimensions(bgimage
, &W
, &H
);
312 draw_gfx_raw(bgimage
, 0, 0, 0, 0, W
, H
);
316 int x0
= camera_x
+ origin_x
;
317 int y0
= camera_y
+ origin_y
;
326 if(toggle_background
)
329 for(j
=0; j
<(15+5); j
++){
331 for(i
=0; i
<(20+8); i
++){
337 draw_gfx_raw(bgtiles
, i
*16, j
*16, gx
, gy
, 16, 16);
341 draw_gfx_raw(fgtiles
, i
*16, j
*16, gx
, gy
, 16, 16);
342 gy
= 16*(t
.shape
/ 16);
343 gx
= 16*(t
.shape
% 16);
345 draw_gfx_raw(shapes
, i
*16, j
*16, gx
, gy
, 16, 16);
351 /* determine an optimal size for the stage */
352 void raw_optimize(int* ox
, int* oy
, int* ow
, int* oh
){
362 for(i
=0; i
<(raw_w
*raw_h
); i
++){
365 fg
= raw_tiles
[i
].fg
;
366 bg
= raw_tiles
[i
].bg
;
367 shape
= raw_tiles
[i
].shape
;
368 if((fg
!= 0 || bg
!= 0 || shape
!= '0')){
370 if(x
> xmax
) xmax
= x
;
371 if(x
< xmin
) xmin
= x
;
372 if(y
> ymax
) ymax
= y
;
373 if(y
< ymin
) ymin
= y
;
377 if(ymax
- ymin
+ 1 <= 15) *oh
= 15;
378 else *oh
= (ymax
- ymin
+ 1);
380 if(xmax
- xmin
+ 1 <= 20) *ow
= 20;
381 else *ow
= (xmax
- xmin
+ 1);
393 int raw_save(char* path
){
394 /* save current stage to a stage file */
395 /* overwrites if already exists, no confirmation */
399 struct tile
* ptr
= raw_tiles
;
401 int opt_x
, opt_y
, opt_w
, opt_h
;
404 FILE* f
= fopen(path
, "w");
406 console_printf("error saving file");
410 raw_optimize(&opt_x
, &opt_y
, &opt_w
, &opt_h
);
412 fprintf(f
, "%d %d %d %d\n", opt_w
, opt_h
, origin_x
-opt_x
, origin_y
-opt_y
);
413 fprintf(f
, "%s\n", bgimage_file
);
414 fprintf(f
, "%s\n", fgtiles_file
);
415 fprintf(f
, "%s\n", bgtiles_file
);
417 for(i
=0; i
<(raw_w
*raw_h
); i
++){
418 x
= (i
% raw_w
) - origin_x
;
419 y
= (i
/ raw_w
) - origin_y
;
422 shape
= ptr
[i
].shape
;
424 if(fg
!= 0 || bg
!= 0 || shape
!= '0'){
425 fprintf(f
, "%d %d %d %d %c\n", x
, y
, fg
, bg
, shape
);
434 void save(char* stagename
){
435 char* path
= compute_stage_path(stagename
);
436 if(raw_save(path
) < 0){
437 console_printf("%s NOT saved", stagename
);
440 console_printf("%s saved", stagename
);
445 int raw_open(char* stagename
){
450 char file1
[256] = "";
451 char file2
[256] = "";
452 char file3
[256] = "";
453 struct tile
* new_tiles
= NULL
;
455 char* path
= compute_stage_path(stagename
);
457 r
= loader_open(path
);
459 console_printf("Can't open %s", path
);
463 if(loader_scanline(r
, "%d %d %d %d", &w
, &h
, &ox
, &oy
) < 4){
464 printf("scan error\n");
470 loader_readline(r
, file1
, 256) ||
471 loader_readline(r
, file2
, 256) ||
472 loader_readline(r
, file3
, 256)
474 printf("scan error\n");
479 new_tiles
= initialize_raw(w
, h
);
480 while(loader_scanline(r
, "%d %d %d %d %c", &x
, &y
, &fg
, &bg
, &shape
) == 5){
481 ptr
= new_tiles
+ (x
+ox
) + (y
+oy
)*w
;
487 /* load the graphics */
488 path
= compute_gfx_path(file1
);
489 if(file1
[0] != 0 && file_exists(path
)) bgimage
= load_bitmap(path
);
492 path
= compute_gfx_path(file2
);
493 if(file2
[0] != 0 && file_exists(path
)) bgtiles
= load_bitmap(path
);
496 path
= compute_gfx_path(file3
);
497 if(file3
[0] != 0 && file_exists(path
)) fgtiles
= load_bitmap(path
);
506 raw_tiles
= new_tiles
;
508 strcpy(bgimage_file
, file1
);
509 strcpy(bgtiles_file
, file2
);
510 strcpy(fgtiles_file
, file3
);
512 strcpy(my_file
, stagename
);
522 struct undo_step
* undo_stack
;
523 struct undo_step
* undo_ptr
;
525 /* undo operations */
527 //do the undo_ptr->undo operations
528 //move undo_ptr down one
532 //if at top of stack, do nothing
534 //do the undo_ptr->redo operations
535 //move undo_ptr up one
538 void undo_record(struct edit
* edits
){
539 //eliminate undo_ptr->redo and all previous edit structs
540 //change the undo_stack
542 //store the edits in undo_ptr->redo
543 //calculate the undo operation XXX
544 //push a new edit struct
546 //store the undo operation in undo_ptr->undo
553 /* medium level editting commands */
554 void write_one_tile(int x
, int y
, int layer
, int value
){
555 //write x y layer value
558 void write_many_tiles(struct edit
* edits
){
563 void edit_one_tile(int x
, int y
, int layer
, int value
){
565 //create a tile struct
569 void edit_many_tiles(struct edit
* edits
){
574 void add_to_clipboard(struct edit
* edits
){
575 //makes a tile struct and appends to clipboard
578 void clear_clipboard(){
579 //clear the clipboard
582 struct tile
* read_tile(int x
, int y
){
589 /* high level gui commands */
597 int value
= brush_tile
;
598 int layer
= brush_layer
;
600 if(layer
== 1) favs
= bg_favorites
;
601 if(layer
== 2) favs
= fg_favorites
;
604 if(favs
[i
] == value
){
624 void start_box(int x
, int y
){
628 void move_box(int x
, int y
){
640 void append_to_box(int x
, int y
){
644 struct tile
* box_select(){
649 void move_paste(int x
, int y
){
674 void draw_tile_panel(){
680 draw_black_rect(0,0,9*16,20*16);
681 draw_gfx_raw(tools
, 0, 14*16, 4*16, 0, 16, 16);
682 draw_gfx_raw(tools
, 16, 14*16, 5*16, 0, 16, 16);
683 draw_gfx_raw(tools
, 2*16, 14*16, 6*16, 0, 16, 16);
684 draw_gfx_raw(tools
, 7*16, 14*16, 7*16, 0, 16, 16);
686 if(tile_panel_page
== 0) tile_panel_offset
= 0;
687 if(tile_panel_page
== 1) tile_panel_offset
= 112;
688 if(tile_panel_page
== 2) tile_panel_offset
= 144;
690 if(tile_panel_set
== 0) gfx
= fgtiles
;
691 if(tile_panel_set
== 1) gfx
= bgtiles
;
693 for(i
=0; i
<112; i
++){
694 j
= i
+ tile_panel_offset
;
697 gx
= 16*((j
%8) + (j
/128)*8);
698 gy
= 16*((j
/8) % (128/8));
700 draw_gfx_raw(gfx
, x
, y
, gx
, gy
, 16, 16);
708 draw_black_rect(16, 16, 17*16, 11*16);
710 /* fg tile tool and favorites */
711 draw_gfx_raw(tools
, 2*16, 2*16, 0, 0, 16, 16);
714 gx
= 16*(fg_favorites
[i
] % 16);
715 gy
= 16*(fg_favorites
[i
] / 16);
716 draw_gfx_raw(fgtiles
, 16*(i
+4), 2*16, gx
, gy
, 16, 16);
719 /* bg tile tool and favorites */
720 draw_gfx_raw(tools
, 2*16, 4*16, 16, 0, 16, 16);
723 gx
= 16*(bg_favorites
[i
] % 16);
724 gy
= 16*(bg_favorites
[i
] / 16);
725 draw_gfx_raw(bgtiles
, 16*(i
+4), 4*16, gx
, gy
, 16, 16);
730 gx
= 16*(shapechars
[i
] % 16);
731 gy
= 16*(shapechars
[i
] / 16);
732 draw_gfx_raw(shapes
, 16*(i
+2), 6*16, gx
, gy
, 16, 16);
735 draw_gfx_raw(tools
, 2*16, 8*16, 2*16, 0, 16, 16);
736 draw_gfx_raw(tools
, 4*16, 8*16, 3*16, 0, 16, 16);
752 console_printf("save as: %s", save_as_buf
);
756 console_printf("open file: %s", open_buf
);
768 if(brush_layer
== 1){
769 console_printf("bg tileset: %s", generic_buf
);
771 else if(brush_layer
== 2){
772 console_printf("fg tileset: %s", generic_buf
);
776 if(background_dialog
){
777 console_printf("background image: %s", generic_buf
);
781 console_printf("path to zone: %s", generic_buf
);
795 /* dialog input handlers */
796 void pixel_to_tile(int mx
, int my
, int* x
, int* y
){
797 map_pixel(mx
, my
, x
, y
);
802 void zone_press(SDLKey key
, Uint16 c
){
804 if(generic_buf
[0] == 0){
805 console_printf("No name? Nevermind then.");
808 set_zone_path(generic_buf
);
809 console_printf("zone set to %s", zone_path
);
823 generic_buf
[generic_ptr
] = 0;
829 if(generic_ptr
< 255){
830 generic_buf
[generic_ptr
] = c
;
832 generic_buf
[generic_ptr
] = 0;
838 void tileset_press(SDLKey key
, Uint16 c
){
840 if(generic_buf
[0] == 0){
841 console_printf("No name? Nevermind then.");
844 char* path
= compute_gfx_path(generic_buf
);
845 int gfx
= load_bitmap(path
);
847 console_printf("file not found");
850 if(brush_layer
== 1){
851 strcpy(bgtiles_file
, generic_buf
);
852 bgtiles
= load_bitmap(path
);
854 else if(brush_layer
== 2){
855 strcpy(fgtiles_file
, generic_buf
);
856 fgtiles
= load_bitmap(path
);
872 generic_buf
[generic_ptr
] = 0;
878 if(generic_ptr
< 255){
879 generic_buf
[generic_ptr
] = c
;
881 generic_buf
[generic_ptr
] = 0;
886 void background_press(SDLKey key
, Uint16 c
){
888 if(generic_buf
[0] == 0){
889 console_printf("No name? Nevermind then.");
892 char* path
= compute_gfx_path(generic_buf
);
893 int gfx
= load_bitmap(path
);
895 console_printf("file not found");
898 strcpy(bgimage_file
, generic_buf
);
899 bgimage
= load_bitmap(path
);
904 background_dialog
= 0;
909 background_dialog
= 0;
914 generic_buf
[generic_ptr
] = 0;
920 if(generic_ptr
< 255){
921 generic_buf
[generic_ptr
] = c
;
923 generic_buf
[generic_ptr
] = 0;
929 int tile_panel_click(int mx
, int my
){
932 pixel_to_tile(mx
, my
, &x
, &y
);
953 if(y
>= 0 && y
< 14){
955 i
= x
+ y
*8 + tile_panel_offset
;
956 brush_tile
= (i
%8) + (i
/8)*16 + (i
/128)*8;
965 void tile_panel_press(SDLKey key
, Uint16 c
){
978 void tools_press(SDLKey key
, Uint16 c
){
982 void tools_click(int mx
, int my
){
986 pixel_to_tile(mx
, my
, &x
, &y
);
994 if(x
>= 4 && x
<= 10){
998 brush_tile
= fg_favorites
[x
-4];
1009 if(x
>= 4 && x
<= 10){
1013 brush_tile
= bg_favorites
[x
-4];
1019 if(x
>= 2 && x
<= 16){
1022 brush_tile
= shapechars
[x
-2];
1028 printf("big eraser\n");
1032 console_printf("eyedropper\n");
1040 void open_press(SDLKey key
, Uint16 c
){
1044 if(open_buf
[0] == 0){
1045 console_printf("No name? Nevermind then.");
1048 if(raw_open(open_buf
) < 0){
1049 console_printf("ERROR when opening %s", open_buf
);
1052 console_printf("%s opened", open_buf
);
1053 update_window_name();
1068 open_buf
[open_ptr
] = 0;
1073 open_buf
[open_ptr
] = c
;
1075 open_buf
[open_ptr
] = 0;
1081 void confirm_save_press(SDLKey key
, Uint16 c
){
1082 if(c
== 'y' || c
== 'Y'){
1083 console_printf("You're the boss. Overwriting %s", my_file
);
1085 update_window_name();
1088 strcpy(my_file
, my_file_old
); /* ! */
1089 console_printf("Operation cancelled");
1092 confirm_save_dialog
= 0;
1095 void save_as_press(SDLKey key
, Uint16 c
){
1100 if(save_as_buf
[0] == 0){
1101 console_printf("No name? Nevermind then.");
1104 strcpy(my_file_old
, my_file
); /* ! */
1105 strcpy(my_file
, save_as_buf
); /* ! */
1107 /* see if file exists */
1108 path
= compute_stage_path(save_as_buf
);
1109 if(file_exists(path
)){
1110 console_printf("ALERT: really overwrite %s? (Y/N)", my_file
);
1111 confirm_save_dialog
= 1;
1114 update_window_name();
1128 if(save_as_ptr
> 0){
1130 save_as_buf
[save_as_ptr
] = 0;
1134 if(save_as_ptr
< 255){
1135 save_as_buf
[save_as_ptr
] = c
;
1137 save_as_buf
[save_as_ptr
] = 0;
1142 void quit_press(SDLKey key
, Uint16 c
){
1143 if(c
== 'y' || c
== 'Y'){
1147 console_printf("OK");
1157 void keydown(SDLKey key
, SDLMod mod
, Uint16 c
){
1160 save_as_press(key
, c
);
1165 if(confirm_save_dialog
){
1166 confirm_save_press(key
, c
);
1184 tools_press(key
, c
);
1190 tile_panel_press(key
, c
);
1195 tileset_press(key
, c
);
1200 if(background_dialog
){
1201 background_press(key
, c
);
1215 console_printf("undo"); break;
1218 console_printf("redo"); break;
1220 toggle_background
= !toggle_background
;
1221 console_printf("background %s", onoff(toggle_background
));
1224 toggle_bgtiles
= !toggle_bgtiles
;
1225 console_printf("bg tiles %s", onoff(toggle_bgtiles
));
1228 toggle_fgtiles
= !toggle_fgtiles
;
1229 console_printf("fg tiles %s", onoff(toggle_fgtiles
));
1232 toggle_shapes
= !toggle_shapes
;
1233 console_printf("shapes %s", onoff(toggle_shapes
));
1236 if(mod
& (KMOD_LCTRL
|KMOD_RCTRL
)){
1237 if(my_file
[0] == 0){
1256 console_printf("eyedropper");
1260 console_printf("graphics reloaded");
1263 console_printf("name: %s", my_file
);
1264 console_printf("zone: %s", zone_path
);
1265 console_printf("size: %d x %d", raw_w
, raw_h
);
1266 console_printf("origin: %d x %d", origin_x
, origin_y
);
1267 console_printf("background: %s", bgimage_file
);
1268 console_printf("bg tileset: %s", bgtiles_file
);
1269 console_printf("fg tileset: %s", fgtiles_file
);
1273 console_printf("Really quit? (Y/N)");
1282 console_printf("arrow keys - move");
1283 console_printf("left mouse - draw");
1284 console_printf("right mouse - erase");
1285 console_printf("space - open toolbox");
1286 console_printf("ctrl+s - save");
1287 console_printf("w - save as");
1288 console_printf("o - open");
1289 console_printf("n - new file");
1290 console_printf("z - change zone");
1291 console_printf("l - reload graphics");
1292 console_printf("1 2 3 4 - toggle layers");
1293 console_printf("i - file info");
1294 console_printf("F1 h ? - this help");
1295 console_printf("ESCAPE q - quit / cancel");
1296 console_printf("F5 - select background");
1297 console_printf("F6 - select bg tileset");
1298 console_printf("F7 - select fg tileset");
1299 console_printf("e - choose eyedropper");
1300 console_printf("x - choose megaeraser (not yet)");
1303 background_dialog
= 1;
1313 case SDLK_LEFT
: camera_x
--; break;
1314 case SDLK_RIGHT
: camera_x
++; break;
1315 case SDLK_UP
: camera_y
--; break;
1316 case SDLK_DOWN
: camera_y
++; break;
1322 /* temporary controls */
1323 case SDLK_9
: brush_tile
--; brush_tile
%= 256; break;
1324 case SDLK_0
: brush_tile
++; brush_tile
%= 256; break;
1325 case SDLK_8
: brush_layer
= 2; break;
1326 case SDLK_7
: brush_layer
= 1; break;
1341 B - change background
1350 F2 - change fg tileset
1351 F3 - change bg tileset
1356 void translate_pointer(int mx
, int my
, int *x
, int *y
){
1358 map_pixel(mx
, my
, &a
, &b
);
1359 *x
= a
/16 + camera_x
+ origin_x
;
1360 *y
= b
/16 + camera_y
+ origin_y
;
1364 void mousedown(int mx
, int my
, int button
){
1366 hold LMB - draw single tiles / deselect
1367 shift LMB - start box select
1368 ctrl LMB - append single tiles to selection
1369 RMB - display tilesets
1370 hold MMB - choose where to paste (release to execute, esc to cancel)
1372 SDLMod mod
= SDL_GetModState();
1376 translate_pointer(mx
, my
, &x
, &y
);
1379 tools_click(mx
, my
);
1384 if(tile_panel_click(mx
, my
)){
1393 if(brush_layer
== 1){
1396 else if(brush_layer
== 2){
1399 else if(brush_layer
== 3){
1400 brush_tile
= t
.shape
;
1405 raw_write(x
, y
, brush_layer
, brush_tile
);
1410 else if(button
== 3){
1412 if(brush_layer
== 3){
1413 raw_write(x
, y
, 3, '0');
1416 raw_write(x
, y
, brush_layer
, 0);
1423 void mouseup(int x
, int y
, int button
){
1426 shift LMB - append box to selection
1440 void mousemove(int mx
, int my
, int xrel
, int yrel
){
1447 translate_pointer(mx
, my
, &x
, &y
);
1450 raw_write(x
, y
, brush_layer
, brush_tile
);
1454 if(brush_layer
== 3){
1455 raw_write(x
, y
, 3, '0');
1458 raw_write(x
, y
, brush_layer
, 0);
1467 if(SDL_WaitEvent(&e
) == 0){
1468 printf("SDL_WaitEvent encountered an error (%s)\n", SDL_GetError());
1473 case SDL_QUIT
: return 1;
1474 case SDL_KEYDOWN
: keydown(e
.key
.keysym
.sym
, e
.key
.keysym
.mod
, e
.key
.keysym
.unicode
); return 0;
1475 case SDL_MOUSEMOTION
:
1476 mousemove(e
.motion
.x
, e
.motion
.y
, e
.motion
.xrel
, e
.motion
.yrel
);
1478 case SDL_MOUSEBUTTONDOWN
: mousedown(e
.button
.x
, e
.button
.y
, e
.button
.button
); return 0;
1479 case SDL_MOUSEBUTTONUP
: mouseup(e
.button
.x
, e
.button
.y
, e
.button
.button
); return 0;
1480 case SDL_VIDEOEXPOSE
: redraw_all();
1492 int main(int argc
, char* argv
[]){
1493 video_init(argc
, argv
);
1497 raw_tiles
= initialize_raw(raw_w
, raw_h
);
1499 update_window_name();
1501 shapes
= load_bitmap("gfx/shapes.tga");
1502 tools
= load_bitmap("gfx/tools.tga");
1504 loader_data_mode(0);
1511 SDL_EnableUNICODE(1);
1512 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY
, SDL_DEFAULT_REPEAT_INTERVAL
);
1516 while(check_events() == 0 && panic_flag
== 0);