Mercurial > repos > genjam1
comparison src/main.c @ 21:bb7dfb42b320
Small refactor to object placement. Add spawn point object
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 12 Jan 2014 23:53:18 -0800 |
parents | 51a0972fcf76 |
children | b725a715b358 |
comparison
equal
deleted
inserted
replaced
20:51a0972fcf76 | 21:bb7dfb42b320 |
---|---|
40 0x00000001, | 40 0x00000001, |
41 0x00000112, | 41 0x00000112, |
42 | 42 |
43 }; | 43 }; |
44 | 44 |
45 #define EMPTY 0 | |
46 #define WALL 'O'-32 + TILE_FONTINDEX | |
47 #define TOWER TILE_ATTR_FULL(1, 0, 0, 0, 'T'-32 + TILE_FONTINDEX) | |
48 #define GOAL TILE_ATTR_FULL(1, 0, 0, 0, 'G'-32 + TILE_FONTINDEX) | |
49 | |
50 u16 countdown; | 45 u16 countdown; |
51 | 46 |
52 int cursor_x = 0; // tiles | 47 int cursor_x = 0; // tiles |
53 int cursor_y = 0; // tiles | 48 int cursor_y = 0; // tiles |
54 int pixels_per_tile = 8; | 49 int pixels_per_tile = 8; |
77 if (went_down & BUTTON_RIGHT) { | 72 if (went_down & BUTTON_RIGHT) { |
78 cursor_x += cursor_width; | 73 cursor_x += cursor_width; |
79 } | 74 } |
80 if (went_down & BUTTON_A && !running) { | 75 if (went_down & BUTTON_A && !running) { |
81 //u16 type_to_place = EMPTY; | 76 //u16 type_to_place = EMPTY; |
82 u16 type_to_place = WALL; | 77 place_object(WALL, cursor_x, cursor_y); |
83 tilemap[cursor_x + (cursor_y ) * 40] = type_to_place; | |
84 tilemap[cursor_x + 1 + (cursor_y ) * 40] = type_to_place; | |
85 tilemap[cursor_x + (cursor_y + 1) * 40] = type_to_place; | |
86 tilemap[cursor_x + 1 + (cursor_y + 1) * 40] = type_to_place; | |
87 gen_distances(38, 14); | 78 gen_distances(38, 14); |
88 if (distances[122/16] == 0xFFFF) | 79 if (distances[122/16] == 0xFFFF) |
89 { | 80 { |
90 tilemap[cursor_x + (cursor_y ) * 40] = 0; | 81 place_object(EMPTY, cursor_x, cursor_y); |
91 tilemap[cursor_x + 1 + (cursor_y ) * 40] = 0; | |
92 tilemap[cursor_x + (cursor_y + 1) * 40] = 0; | |
93 tilemap[cursor_x + 1 + (cursor_y + 1) * 40] = 0; | |
94 } | 82 } |
95 } | 83 } |
96 if (went_down & BUTTON_START) | 84 if (went_down & BUTTON_START) |
97 { | 85 { |
98 running = 1; | 86 running = 1; |
114 { | 102 { |
115 tilemap[i] = WALL; | 103 tilemap[i] = WALL; |
116 tilemap[i+1] = WALL; | 104 tilemap[i+1] = WALL; |
117 } | 105 } |
118 */ | 106 */ |
119 | 107 place_object(GOAL, 38, 14); |
120 tilemap[38 + 14*40] = GOAL; | 108 place_object(SPAWN, 0, 14); |
121 tilemap[39 + 14*40] = GOAL; | 109 gen_distances(38, 14); |
122 tilemap[38 + 15*40] = GOAL; | |
123 tilemap[39 + 15*40] = GOAL; | |
124 for (i = 0; i < MAX_SPRITE; i++) | 110 for (i = 0; i < MAX_SPRITE; i++) |
125 { | 111 { |
126 spriteDefCache[i].posx = -0x80; | 112 spriteDefCache[i].posx = -0x80; |
127 } | 113 } |
128 gen_distances(38, 14); | |
129 //print_distances(); | 114 //print_distances(); |
130 for (;;) | 115 for (;;) |
131 { | 116 { |
132 VDP_waitVSync(); | 117 VDP_waitVSync(); |
133 VDP_updateSprites(); | 118 VDP_updateSprites(); |
140 { | 125 { |
141 if (countdown) | 126 if (countdown) |
142 --countdown; | 127 --countdown; |
143 else if (cur_creeps < 4) | 128 else if (cur_creeps < 4) |
144 { | 129 { |
145 spawn_creep(CREEP_NORMAL, 4, 122); | 130 spawn_creep(CREEP_NORMAL, 0+4, 14*8+4); |
146 countdown = 300; | 131 countdown = 300; |
147 } | 132 } |
148 update_creeps(); | 133 update_creeps(); |
149 } | 134 } |
150 } | 135 } |