161 static Spaceship *create_spaceship(void) { |
161 static Spaceship *create_spaceship(void) { |
162 AscSceneNode *sprite = asc_sprite( |
162 AscSceneNode *sprite = asc_sprite( |
163 .name = "Player", |
163 .name = "Player", |
164 .texture = TEXTURE_SHIP, |
164 .texture = TEXTURE_SHIP, |
165 // TODO: introduce a function to set the position of a space ship |
165 // TODO: introduce a function to set the position of a space ship |
166 .x = game_field_tile_size * 8 - game_field_tile_size / 2, |
166 .x = game_field_tile_size * 8, |
167 .y = game_field_tile_size * 12 - game_field_tile_size / 2, |
167 .y = game_field_tile_size * 12, |
168 .width = game_field_tile_size, |
168 .width = game_field_tile_size, |
169 .height = game_field_tile_size, |
169 .height = game_field_tile_size, |
170 .origin_x = game_field_tile_size / 2, |
170 .origin_x = game_field_tile_size / 2, |
171 .origin_y = game_field_tile_size / 2, |
171 .origin_y = game_field_tile_size / 2, |
172 ); |
172 ); |
182 AscSceneNode *gamefield = asc_scene_node_empty(); |
182 AscSceneNode *gamefield = asc_scene_node_empty(); |
183 for (unsigned x = 0; x < game_field_size; x+=game_field_tile_size) { |
183 for (unsigned x = 0; x < game_field_size; x+=game_field_tile_size) { |
184 for (unsigned y = 0; y < game_field_size; y+=game_field_tile_size) { |
184 for (unsigned y = 0; y < game_field_size; y+=game_field_tile_size) { |
185 AscSceneNode *tile = asc_rectangle( |
185 AscSceneNode *tile = asc_rectangle( |
186 .x = x, .y = y, .filled = true, .thickness = 1, |
186 .x = x, .y = y, .filled = true, .thickness = 1, |
|
187 .origin_x = game_field_tile_size / 2, .origin_y = game_field_tile_size / 2, |
187 .width = game_field_tile_size, .height = game_field_tile_size, |
188 .width = game_field_tile_size, .height = game_field_tile_size, |
188 .color = ASC_RGB(0, 128, 255), |
189 .color = ASC_RGB(0, 128, 255), |
189 .border_color = ASC_RGB(64, 196, 255), |
190 .border_color = ASC_RGB(64, 196, 255), |
190 ); |
191 ); |
191 asc_scene_node_link(gamefield, tile); |
192 asc_scene_node_link(gamefield, tile); |
245 .projection_update_func = asc_camera_ortho_update_size |
246 .projection_update_func = asc_camera_ortho_update_size |
246 ); |
247 ); |
247 asc_scene_init(MAIN_SCENE, |
248 asc_scene_init(MAIN_SCENE, |
248 .type = ASC_CAMERA_ORTHO, |
249 .type = ASC_CAMERA_ORTHO, |
249 .ortho.rect = ASC_RECT( |
250 .ortho.rect = ASC_RECT( |
250 -game_field_tile_size/2, |
251 -game_field_tile_size, |
251 -game_field_tile_size/2, |
252 -game_field_tile_size, |
252 game_field_size+game_field_tile_size, |
253 game_field_size+game_field_tile_size, |
253 game_field_size+game_field_tile_size |
254 game_field_size+game_field_tile_size |
254 ), |
255 ), |
255 .viewport_clear = true, |
256 .viewport_clear = true, |
256 .clear_color = ASC_RGB(0, 128, 90), |
257 .clear_color = ASC_RGB(0, 128, 90), |