diff --git a/obj/maths.c.o b/obj/maths.c.o index 633ee2c..e1d7802 100644 Binary files a/obj/maths.c.o and b/obj/maths.c.o differ diff --git a/obj/wings.c.o b/obj/wings.c.o index 5cbedda..4d31c64 100644 Binary files a/obj/wings.c.o and b/obj/wings.c.o differ diff --git a/src/maths.c b/src/maths.c index a20ed9d..65953ee 100644 --- a/src/maths.c +++ b/src/maths.c @@ -4,14 +4,15 @@ float fcos(unsigned char x) { + char n = 1; float cos[4] = {1.0, 0.707106, 0.0, -0.707106}; while(x >= 4) { - x-=4; + x -= 4; + n = -n; } - - return cos[x]; + return (n*cos[x]); } float fsin(unsigned char x) diff --git a/src/wings.c b/src/wings.c index ed08aa3..340cad8 100644 --- a/src/wings.c +++ b/src/wings.c @@ -9,8 +9,8 @@ #include "stdio.h" #include "stdlib.h" -#define SIZE_MAP_X 256 -#define SIZE_MAP_Y 256 +#define MAP_SIZE_X 256 +#define MAP_SIZE_Y 256 #define MAX_PLANES 2 @@ -49,16 +49,6 @@ void init() } } -void AI() // iA start -{ - unsigned char i; - - for(i = 1; i < MAX_PLANES; i++) - { - - } -} - void infos() { unsigned int key = 0; @@ -112,34 +102,40 @@ int menu() void *update_frame() { static unsigned char i,j; - static short decalx = 0; - static short decaly = 0; + static char decalx = -1; + static char decaly = 0; dclear(); - //dprint(1, 1, "s:%d l:%d", planes[0].reload, planes[0].life); + dprint(1, 1, "s:%d l:%d", planes[0].reload, planes[0].life); + dprint(1, 10, "(%d,%d)", decalx, decaly); + + decalx = decaly = 0; switch(planes[0].dir) { - case 0 : decalx--; break; - case 1 : decalx--; decaly++; break; - case 2 : decaly++; break; - case 3 : decalx++; decaly++; break; - case 4 : decalx++; break; - case 5 : decalx++; decaly--; break; - case 6 : decaly--; break; - case 7 : decalx--; decaly--; break; + case 0 : decalx = -1; break; + case 1 : decalx = -1; decaly = 1; break; + case 2 : decaly = 1; break; + case 3 : decalx = 1; decaly = 1; break; + case 4 : decalx = 1; break; + case 5 : decalx = 1; decaly = -1; break; + case 6 : decaly = -1; break; + case 7 : decalx = -1; decaly = -1; break; } - dimage_part(planes[0].x, planes[0].y, &plane, 16*planes[0].dir, 0, 16, 16); - - for(i = 1; i < MAX_PLANES; i++) + for(i = 0; i < MAX_PLANES; i++) { - dimage_part(planes[i].x + decalx, planes[i].y + decaly, &plane, 16*planes[i].dir, 0, 16, 16); - //dimage(planes[i].x + decalx, planes[i].y + decaly, &plane); - + if(i > 0) + { + planes[i].x += decalx; + planes[i].y += decaly; + } + + dimage_part(planes[i].x, planes[i].y, &plane, 16*planes[i].dir, 0, 16, 16); } - dprint(1,10, "(x,y)(%d,%d)", planes[1].x + decalx, planes[1].y + decaly); + + //dprint(1,10, "(x,y)(%d,%d)", planes[1].x + decalx, planes[1].y + decaly); dimage(10 + decalx, 10 + decaly, &cloud); @@ -151,19 +147,22 @@ void *update_frame() planes[i].y + 4 - (planes[i].missiles[j].distance + 15) * fsin(planes[i].missiles[j].dir), &missiles, 8 * planes[i].missiles[j].dir, 0, 8, 8); - planes[i].missiles[j].distance++; + planes[i].missiles[j].distance ++; } } dupdate(); + return; } +#define MAX_KEYS 4 + int game() { unsigned char fire = 0; // fire disable unsigned char sum = 0; - int keys[3]; + int keys[MAX_KEYS]; unsigned char i; unsigned char j; @@ -175,16 +174,16 @@ int game() timer_t *timer = NULL; timer = timer_create(40, 0); - timer_attach(timer, &update_frame, NULL); + timer_attach(timer, update_frame, NULL); timer_start(timer); while(1) { - multigetkey(keys, 3, 0); + multigetkey(keys, MAX_KEYS, 0); sum = 0; - for(i = 0; i < 3; i++) + for(i = 0; i < MAX_KEYS; i++) { switch(keys[i]) { @@ -199,7 +198,7 @@ int game() if(planes[0].reload > 0) { fire = 1; - // planes[0].reload = planes[0].reload - 1; + //planes[0].reload = planes[0].reload - 1; } break; // fire enable } diff --git a/wings.bin b/wings.bin index 69dbcb6..9361343 100755 Binary files a/wings.bin and b/wings.bin differ diff --git a/wings.elf b/wings.elf index a9eff59..1bea00a 100755 Binary files a/wings.elf and b/wings.elf differ diff --git a/wings.g1a b/wings.g1a index 99bc7f0..e46300a 100644 Binary files a/wings.g1a and b/wings.g1a differ