116 .text = "Score: 0" |
116 .text = "Score: 0" |
117 ); |
117 ); |
118 asc_ui_add_node(node); |
118 asc_ui_add_node(node); |
119 } |
119 } |
120 |
120 |
121 static void create_spaceship(void) { |
121 static AscSceneNode *create_spaceship(void) { |
122 AscSceneNode *sprite = asc_sprite( |
122 AscSceneNode *sprite = asc_sprite( |
123 .name = "Player", |
123 .name = "Player", |
124 .texture = TEXTURE_SHIP, |
124 .texture = TEXTURE_SHIP, |
125 .x = 250, |
125 .x = 250, |
126 .y = 300, |
126 .y = 300, |
127 .width = 64, |
127 .width = 64, |
128 .height = 64 |
128 .height = 64 |
129 ); |
129 ); |
130 asc_scene_add_node(MAIN_SCENE, sprite); |
130 asc_scene_add_node(MAIN_SCENE, sprite); |
131 |
131 return sprite; |
132 // TODO: return something |
|
133 } |
132 } |
134 |
133 |
135 static asc_rect update_viewport_for_window_resize(asc_vec2u window_size) { |
134 static asc_rect update_viewport_for_window_resize(asc_vec2u window_size) { |
136 // Compute scaling and offsets |
135 // Compute scaling and offsets |
137 unsigned viewport_size, offset_x = 0, offset_y = 0; |
136 unsigned viewport_size, offset_x = 0, offset_y = 0; |
192 // create UI elements |
191 // create UI elements |
193 create_fps_counter(); |
192 create_fps_counter(); |
194 create_score_counter(); |
193 create_score_counter(); |
195 |
194 |
196 // create spaceship |
195 // create spaceship |
197 create_spaceship(); |
196 AscSceneNode *spaceship = create_spaceship(); |
198 |
197 |
199 // Main Loop |
198 // Main Loop |
200 do { |
199 do { |
201 // quit application on any error |
200 // quit application on any error |
202 if (asc_has_error()) { |
201 if (asc_has_error()) { |
205 asc_active_window->window); |
204 asc_active_window->window); |
206 asc_clear_error(); |
205 asc_clear_error(); |
207 asc_context_quit(); |
206 asc_context_quit(); |
208 } |
207 } |
209 |
208 |
|
209 // player rotation |
|
210 if (asc_key_pressed(ASC_KEY(LEFT))) { |
|
211 asc_transform_roll_origin(spaceship->transform, asc_rad(-90), ASC_VEC3F(32, 32, 0)); |
|
212 asc_node_update_transform(spaceship); |
|
213 } |
|
214 |
210 // debug-key for clearing the shader registry |
215 // debug-key for clearing the shader registry |
211 if (asc_key_pressed(ASC_KEY(S))) { |
216 if (asc_key_pressed(ASC_KEY(S))) { |
212 asc_shader_clear_registry(); |
217 asc_shader_clear_registry(); |
213 asc_dprintf("Shader cache cleared."); |
218 asc_dprintf("Shader cache cleared."); |
214 } |
219 } |