# HG changeset patch # User Thinker K.F. Li # Date 1221329877 -28800 # Node ID 3895d2224e67639075bf2546f2255714e0f94f7d # Parent 1909d53071ab6455e94c06dca19d73d91aa7d1cc Tank diff -r 1909d53071ab -r 3895d2224e67 examples/calculator/calculator_scr.svg --- a/examples/calculator/calculator_scr.svg Sun Sep 14 01:10:49 2008 +0800 +++ b/examples/calculator/calculator_scr.svg Sun Sep 14 02:17:57 2008 +0800 @@ -2,7 +2,7 @@ + + inkscape:window-width="1440" + inkscape:window-height="860" + inkscape:window-x="0" + inkscape:window-y="21" + showgrid="false" /> @@ -119,7 +125,7 @@ inkscape:groupmode="layer" id="layer1"> clr $@ + echo "#define __SVGS_H_" >> $@ + echo >> $@ + for H in $(SVGHS); do \ + echo "#include \"$$H\"" >> $@; \ + done + echo >> $@ + echo "#endif /* __SVGS_H_ */" >> $@ + +.for SVG in $(SVGS) +$(SVG:C/\.svg/.o/): $(SVG:C/.svg/.c/) + $(CC) $(CFLAGS) -c -o $@ $(.ALLSRC) + +$(SVG:C/\.svg/.mb/): $(SVG) + $(SVG2CODE) $(SVG) $@ + +$(SVG:C/\.svg/.h/): $(SVG:C/\.svg/.mb/) + $(M4) $(M4FLAGS) mb_c_header.m4 $(.ALLSRC) > $@ + +$(SVG:C/\.svg/.c/): $(SVG:C/\.svg/.mb/) + $(M4) $(M4FLAGS) mb_c_source.m4 $(.ALLSRC) > $@ + +.endfor + +clean: + @for f in svgs.h $(SVGHS) $(SVGCS) $(SVGOS) $(MBS) \ + *~ *.core tank tank_main.o; do \ + if [ -e $$f ]; then \ + echo "delete $$f"; rm -f $$f; \ + fi; \ + done diff -r 1909d53071ab -r 3895d2224e67 examples/tank/brick.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/tank/brick.svg Sun Sep 14 02:17:57 2008 +0800 @@ -0,0 +1,163 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff -r 1909d53071ab -r 3895d2224e67 examples/tank/bullet.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/tank/bullet.svg Sun Sep 14 02:17:57 2008 +0800 @@ -0,0 +1,88 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + diff -r 1909d53071ab -r 3895d2224e67 examples/tank/bush.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/tank/bush.svg Sun Sep 14 02:17:57 2008 +0800 @@ -0,0 +1,109 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff -r 1909d53071ab -r 3895d2224e67 examples/tank/mud.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/tank/mud.svg Sun Sep 14 02:17:57 2008 +0800 @@ -0,0 +1,184 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff -r 1909d53071ab -r 3895d2224e67 examples/tank/rock.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/tank/rock.svg Sun Sep 14 02:17:57 2008 +0800 @@ -0,0 +1,132 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff -r 1909d53071ab -r 3895d2224e67 examples/tank/tank1.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/tank/tank1.svg Sun Sep 14 02:17:57 2008 +0800 @@ -0,0 +1,151 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff -r 1909d53071ab -r 3895d2224e67 examples/tank/tank2.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/tank/tank2.svg Sun Sep 14 02:17:57 2008 +0800 @@ -0,0 +1,151 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff -r 1909d53071ab -r 3895d2224e67 examples/tank/tank_en.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/tank/tank_en.svg Sun Sep 14 02:17:57 2008 +0800 @@ -0,0 +1,151 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff -r 1909d53071ab -r 3895d2224e67 examples/tank/tank_main.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/tank/tank_main.c Sun Sep 14 02:17:57 2008 +0800 @@ -0,0 +1,109 @@ +#include +#include "svgs.h" + +enum { MUD, ROC, BRI, BSH }; + +static char map[12][16] = { + { MUD, MUD, MUD, MUD, MUD, MUD, MUD, MUD, + MUD, MUD, MUD, MUD, MUD, MUD, MUD, MUD}, + { MUD, ROC, ROC, ROC, MUD, BSH, BSH, ROC, + BSH, ROC, MUD, BSH, BSH, ROC, ROC, MUD}, + { MUD, MUD, BRI, MUD, MUD, MUD, MUD, MUD, + MUD, MUD, MUD, BRI, MUD, MUD, BSH, MUD}, + { BRI, MUD, MUD, MUD, MUD, MUD, BRI, MUD, + BRI, MUD, MUD, MUD, MUD, MUD, MUD, MUD}, + { MUD, MUD, BRI, MUD, BRI, BSH, BRI, BRI, + BRI, BRI, BSH, ROC, ROC, MUD, BRI, MUD}, + { MUD, BRI, BRI, MUD, BRI, MUD, BRI, MUD, + ROC, MUD, MUD, MUD, MUD, MUD, MUD, MUD}, + { MUD, MUD, MUD, MUD, MUD, MUD, MUD, MUD, + MUD, MUD, MUD, BRI, BRI, BRI, BRI, MUD}, + { MUD, BRI, MUD, BRI, BRI, MUD, BRI, BRI, + BSH, BRI, MUD, MUD, MUD, MUD, MUD, MUD}, + { MUD, BRI, MUD, MUD, MUD, MUD, MUD, MUD, + MUD, MUD, MUD, BRI, BRI, MUD, BRI, BRI}, + { MUD, BRI, MUD, BRI, BRI, MUD, BRI, BRI, + BRI, BRI, MUD, BRI, MUD, MUD, MUD, MUD}, + { MUD, BSH, MUD, BRI, MUD, MUD, BRI, MUD, + MUD, BRI, MUD, MUD, MUD, BRI, BRI, MUD}, + { MUD, MUD, MUD, MUD, MUD, MUD, BRI, MUD, + MUD, BRI, MUD, BRI, MUD, MUD, MUD, MUD} +}; + +typedef struct _tank_rt tank_rt_t; + +struct _tank_rt { + tank1_t *tank1; + tank2_t *tank2; + tank_en_t *tank_en; + void *map[12][16]; + X_MB_runtime_t *mb_rt; +}; + +#define CHANGE_POS(g, x, y) do { \ + (g)->root_coord->matrix[0] = 1.0; \ + (g)->root_coord->matrix[2] = x; \ + (g)->root_coord->matrix[4] = 1.0; \ + (g)->root_coord->matrix[5] = y; \ + rdman_coord_changed(rdman, (g)->root_coord); \ + } while(0) + +void +initial_tank(tank_rt_t *tank_rt, X_MB_runtime_t *mb_rt) { + redraw_man_t *rdman; + mud_t *mud; + brick_t *brick; + rock_t *rock; + bush_t *bush; + int i, j; + + rdman = mb_rt->rdman; + + tank_rt->mb_rt = mb_rt; + for(i = 0; i < 12; i++) { + for(j = 0; j < 16; j++) { + switch(map[i][j]) { + case MUD: + mud = mud_new(rdman); + CHANGE_POS(mud, j * 50, i * 50); + tank_rt->map[i][j] = (void *)mud; + break; + case BRI: + brick = brick_new(rdman); + CHANGE_POS(brick, j * 50, i * 50); + tank_rt->map[i][j] = (void *)brick; + break; + case ROC: + rock = rock_new(rdman); + CHANGE_POS(rock, j * 50, i * 50); + tank_rt->map[i][j] = (void *)rock; + break; + case BSH: + bush = bush_new(rdman); + CHANGE_POS(bush, j * 50, i * 50); + tank_rt->map[i][j] = (void *)bush; + break; + } + } + } + + tank_rt->tank1 = tank1_new(rdman); + tank_rt->tank2 = tank2_new(rdman); + CHANGE_POS(tank_rt->tank2, 50, 0); + tank_rt->tank_en = tank_en_new(rdman); + CHANGE_POS(tank_rt->tank_en, 100, 0); +} + +int +main(int argc, char *const argv[]) { + X_MB_runtime_t rt; + tank_rt_t tank_rt; + + X_MB_init(":0.0", 800, 600, &rt); + + initial_tank(&tank_rt, &rt); + + X_MB_handle_connection(&rt); + + X_MB_destroy(&rt); +} diff -r 1909d53071ab -r 3895d2224e67 src/redraw_man.c --- a/src/redraw_man.c Sun Sep 14 01:10:49 2008 +0800 +++ b/src/redraw_man.c Sun Sep 14 02:17:57 2008 +0800 @@ -43,7 +43,7 @@ for(i = 1; i < num; i++) { val = *(unsigned int *)(elms[i] + off); - for(j = i; j > 0; j--) { + for(j = i - 1; j > 0; j--) { if(*(unsigned int *)(elms[j - 1] + off) <= val) break; elms[j] = elms[j - 1];