test/snake/snake.c

changeset 204
be5cf64b5c29
parent 200
cf0579d3bbc4
child 205
d1e44c861426
equal deleted inserted replaced
203:1883bdc4fb20 204:be5cf64b5c29
68 // TODO: this should be replaced with some sort of UI layout manager 68 // TODO: this should be replaced with some sort of UI layout manager
69 AscSceneNode *node = behavior->node; 69 AscSceneNode *node = behavior->node;
70 if (asc_test_flag(node->flags, ASC_SCENE_NODE_GRAPHICS_UPDATED) || asc_active_window->resized) { 70 if (asc_test_flag(node->flags, ASC_SCENE_NODE_GRAPHICS_UPDATED) || asc_active_window->resized) {
71 asc_vec2u bottom_right = asc_active_window->dimensions; 71 asc_vec2u bottom_right = asc_active_window->dimensions;
72 asc_vec2u text_size = ((AscText*)node)->dimension; 72 asc_vec2u text_size = ((AscText*)node)->dimension;
73 asc_transform new_transform; 73 asc_node_set_position2f(node, ASC_VEC2F(
74 asc_transform_identity(new_transform);
75 asc_transform_translate2f(new_transform, ASC_VEC2F(
76 (int) bottom_right.x - (int) text_size.width - 10, 74 (int) bottom_right.x - (int) text_size.width - 10,
77 (int) bottom_right.y - (int) text_size.height - 10 75 (int) bottom_right.y - (int) text_size.height - 10
78 )); 76 ));
79 asc_node_transform_set(node, new_transform);
80 } 77 }
81 } 78 }
82 79
83 static void scale_backdrop(AscBehavior *behavior) { 80 static void scale_backdrop(AscBehavior *behavior) {
84 // scale the backdrop to the size of the window 81 // scale the backdrop to the size of the window
123 .name = "Player", 120 .name = "Player",
124 .texture = TEXTURE_SHIP, 121 .texture = TEXTURE_SHIP,
125 .x = 250, 122 .x = 250,
126 .y = 300, 123 .y = 300,
127 .width = 64, 124 .width = 64,
128 .height = 64 125 .height = 64,
126 .origin_x = 32,
127 .origin_y = 32,
129 ); 128 );
130 asc_scene_add_node(MAIN_SCENE, sprite); 129 asc_scene_add_node(MAIN_SCENE, sprite);
131 return sprite; 130 return sprite;
132 } 131 }
133 132
206 asc_context_quit(); 205 asc_context_quit();
207 } 206 }
208 207
209 // player rotation 208 // player rotation
210 if (asc_key_pressed(ASC_KEY(LEFT))) { 209 if (asc_key_pressed(ASC_KEY(LEFT))) {
211 asc_transform_roll_origin(spaceship->transform, asc_rad(-90), ASC_VEC3F(32, 32, 0)); 210 asc_node_roll_deg(spaceship, -90);
212 asc_node_update_transform(spaceship); 211 asc_node_update_transform(spaceship);
213 } 212 }
214 213
215 // debug-key for clearing the shader registry 214 // debug-key for clearing the shader registry
216 if (asc_key_pressed(ASC_KEY(S))) { 215 if (asc_key_pressed(ASC_KEY(S))) {

mercurial