103 asc_behavior_add(node, .func = update_fps_counter, .interval = asc_seconds(1)); |
103 asc_behavior_add(node, .func = update_fps_counter, .interval = asc_seconds(1)); |
104 asc_behavior_add(node, tie_fps_counter_to_corner); |
104 asc_behavior_add(node, tie_fps_counter_to_corner); |
105 asc_ui_add_node(node); |
105 asc_ui_add_node(node); |
106 } |
106 } |
107 |
107 |
|
108 static void update_score_counter(AscBehavior *behavior) { |
|
109 AscSceneNode *node = behavior->node; |
|
110 static unsigned test_score = 0; |
|
111 test_score += 100; |
|
112 asc_text_printf(node, "Score: %u", test_score); |
|
113 if (test_score > 9000) { |
|
114 asc_behavior_remove(behavior); |
|
115 } |
|
116 } |
|
117 |
108 static void create_score_counter(void) { |
118 static void create_score_counter(void) { |
109 asc_font(ASC_FONT_BOLD, 16); |
119 asc_font(ASC_FONT_BOLD, 16); |
110 asc_ink_rgb(0, 255, 0); |
120 asc_ink_rgb(0, 255, 0); |
111 AscSceneNode *node = asc_text( |
121 AscSceneNode *node = asc_text( |
112 .name = "Score Counter", |
122 .name = "Score Counter", |
113 .x = 10, .y = 10, |
123 .x = 10, .y = 10, |
114 .text = "Score: 0" |
124 .text = "Score: 0" |
115 ); |
125 ); |
|
126 // TODO: remove this test behavior |
|
127 asc_behavior_add(node, .func = update_score_counter, .interval = asc_milliseconds(250)); |
116 asc_ui_add_node(node); |
128 asc_ui_add_node(node); |
117 } |
129 } |
118 |
130 |
119 static void create_spaceship(void) { |
131 static void create_spaceship(void) { |
120 AscSceneNode *sprite = asc_sprite( |
132 AscSceneNode *sprite = asc_sprite( |