summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHermet Park <hermet@hermet.pe.kr>2016-02-13 14:51:09 +0900
committerHermet Park <hermet@hermet.pe.kr>2016-02-13 14:51:09 +0900
commit45e4eedb76811f03381a555bb627b0e71a5e3189 (patch)
treeae8d6d727d9043a385236fd84135cfa875fd5c4b
parent91fff6852b2748e71bb51531e1e615d58fc28d06 (diff)
display a total score when game is over.v1.0.0
-rw-r--r--data/theme/etypers.edc50
-rw-r--r--src/bin/etypers.c26
2 files changed, 65 insertions, 11 deletions
diff --git a/data/theme/etypers.edc b/data/theme/etypers.edc
index 350a15c..3c86424 100644
--- a/data/theme/etypers.edc
+++ b/data/theme/etypers.edc
@@ -140,7 +140,7 @@ collections {
140 rel1.to: "level"; 140 rel1.to: "level";
141 } 141 }
142 } 142 }
143 part { name: "correct"; 143 part { name: "accuracy";
144 type: TEXT; 144 type: TEXT;
145 scale: 1; 145 scale: 1;
146 description { state: "default" 0.0; 146 description { state: "default" 0.0;
@@ -157,7 +157,7 @@ collections {
157 rel1.relative: 0 1; 157 rel1.relative: 0 1;
158 } 158 }
159 } 159 }
160 part { name: "correct_value"; 160 part { name: "accuracy_value";
161 type: TEXT; 161 type: TEXT;
162 scale: 1; 162 scale: 1;
163 description { state: "default" 0.0; 163 description { state: "default" 0.0;
@@ -172,7 +172,7 @@ collections {
172 align: 0 0 ; 172 align: 0 0 ;
173 rel1.relative: 1 0; 173 rel1.relative: 1 0;
174 rel1.offset: 5 0; 174 rel1.offset: 5 0;
175 rel1.to: "correct"; 175 rel1.to: "accuracy";
176 } 176 }
177 } 177 }
178 part { name: "input_clipper"; 178 part { name: "input_clipper";
@@ -230,7 +230,7 @@ collections {
230 size: 30; 230 size: 30;
231 min: 0 0; 231 min: 0 0;
232 max: 1 0; 232 max: 1 0;
233 align: 0.5 0.5; 233 align: 0.5 0.4;
234 text: "Game Over"; 234 text: "Game Over";
235 } 235 }
236 color: 0 0 0 0; 236 color: 0 0 0 0;
@@ -241,6 +241,44 @@ collections {
241 color: 100 100 100 255; 241 color: 100 100 100 255;
242 } 242 }
243 } 243 }
244 text { "total_score";
245 scale: 1;
246 desc { "default";
247 text {
248 font: "Sans:style=Bold";
249 size: 20;
250 min: 0 0;
251 max: 1 0;
252 align: 0.5 0.5;
253 text: "Your score: 100";
254 }
255 color: 0 0 0 0;
256 align: 0.5 0.5;
257 }
258 desc { "gameover";
259 inherit: "default" 0.0;
260 color: 100 100 100 255;
261 }
262 }
263 text { "exit_guide";
264 scale: 1;
265 desc { "default";
266 text {
267 font: "Sans:style=Bold";
268 size: 12;
269 min: 0 0;
270 max: 1 0;
271 align: 0.5 0.6;
272 text: "Press ESC key";
273 }
274 color: 0 0 0 0;
275 align: 0.5 0.6;
276 }
277 desc { "gameover";
278 inherit: "default" 0.0;
279 color: 100 100 100 255;
280 }
281 }
244 } 282 }
245 programs { 283 programs {
246 program { name: "sky_anim1"; 284 program { name: "sky_anim1";
@@ -290,6 +328,8 @@ collections {
290 action: STATE_SET "gameover" 0.0; 328 action: STATE_SET "gameover" 0.0;
291 target: "effect_overlay"; 329 target: "effect_overlay";
292 target: "gameover"; 330 target: "gameover";
331 target: "total_score";
332 target: "exit_guide";
293 transition: LINEAR 1.0; 333 transition: LINEAR 1.0;
294 } 334 }
295 program { name: "gamereset"; 335 program { name: "gamereset";
@@ -299,6 +339,8 @@ collections {
299 target: "effect_overlay"; 339 target: "effect_overlay";
300 target: "effect_overlay"; 340 target: "effect_overlay";
301 target: "gameover"; 341 target: "gameover";
342 target: "total_score";
343 target: "exit_guide";
302 } 344 }
303 } 345 }
304 } 346 }
diff --git a/src/bin/etypers.c b/src/bin/etypers.c
index bad7531..bd27730 100644
--- a/src/bin/etypers.c
+++ b/src/bin/etypers.c
@@ -35,6 +35,7 @@ typedef struct _AppData
35 float hit_try_cnt; 35 float hit_try_cnt;
36 float text_scale; 36 float text_scale;
37 unsigned long combo; 37 unsigned long combo;
38 unsigned long accuracy;
38 Evas_Coord bound_w; 39 Evas_Coord bound_w;
39 Evas_Coord bound_h; 40 Evas_Coord bound_h;
40 Evas_Coord_Rectangle defense_rect; 41 Evas_Coord_Rectangle defense_rect;
@@ -333,7 +334,7 @@ game_reset(AppData *appdata)
333 elm_object_text_set(appdata->entry, ""); 334 elm_object_text_set(appdata->entry, "");
334 elm_object_part_text_set(appdata->ly, "level_value", "1"); 335 elm_object_part_text_set(appdata->ly, "level_value", "1");
335 elm_object_part_text_set(appdata->ly, "score_value", "0"); 336 elm_object_part_text_set(appdata->ly, "score_value", "0");
336 elm_object_part_text_set(appdata->ly, "correct_value", "100%"); 337 elm_object_part_text_set(appdata->ly, "accuracy_value", "100%");
337 338
338 remove_all_enemies(appdata); 339 remove_all_enemies(appdata);
339 reset_defense_wall(appdata); 340 reset_defense_wall(appdata);
@@ -344,6 +345,7 @@ game_reset(AppData *appdata)
344 appdata->hit_cnt = 0.0f; 345 appdata->hit_cnt = 0.0f;
345 appdata->hit_try_cnt = 0.0f; 346 appdata->hit_try_cnt = 0.0f;
346 appdata->combo = 0; 347 appdata->combo = 0;
348 appdata->accuracy = 100;
347} 349}
348 350
349static void 351static void
@@ -351,6 +353,15 @@ game_over(AppData *appdata)
351{ 353{
352 ecore_animator_freeze(appdata->animator); 354 ecore_animator_freeze(appdata->animator);
353 elm_object_signal_emit(appdata->ly, "elm,state,gameover", "etypers"); 355 elm_object_signal_emit(appdata->ly, "elm,state,gameover", "etypers");
356
357 //score
358 double score = ((double) appdata->score) * appdata->level *
359 ((double) appdata->accuracy);
360
361 char buf[1024];
362 snprintf(buf, sizeof(buf), "%d", (int) score);
363
364 elm_object_part_text_set(appdata->ly, "total_score", buf);
354 appdata->state = GameOver; 365 appdata->state = GameOver;
355} 366}
356 367
@@ -518,15 +529,17 @@ combo(AppData *appdata, Enemy *enemy, int combo)
518} 529}
519 530
520static void 531static void
521update_correctness(AppData *appdata, Eina_Bool hit) 532update_accuracy(AppData *appdata, Eina_Bool hit)
522{ 533{
523 appdata->hit_try_cnt += 1.0f; 534 appdata->hit_try_cnt += 1.0f;
524 if (hit) appdata->hit_cnt += 1.0f; 535 if (hit) appdata->hit_cnt += 1.0f;
525 536
526 char buf[10]; 537 char buf[10];
527 int correctness = (int) ((appdata->hit_cnt / appdata->hit_try_cnt) * 100.0f); 538 int accuracy = (int) ((appdata->hit_cnt / appdata->hit_try_cnt) * 100.0f);
528 snprintf(buf, sizeof(buf), "%3d%%", correctness); 539 snprintf(buf, sizeof(buf), "%3d%%", accuracy);
529 elm_object_part_text_set(appdata->ly, "correct_value", buf); 540 elm_object_part_text_set(appdata->ly, "accuracy_value", buf);
541
542 appdata->accuracy = accuracy;
530} 543}
531 544
532static void 545static void
@@ -570,7 +583,7 @@ enemies_kill(AppData *appdata, Evas_Object *obj, const char *input_text,
570 appdata->combo = 0; 583 appdata->combo = 0;
571 } 584 }
572 585
573 update_correctness(appdata, hit); 586 update_accuracy(appdata, hit);
574 587
575 elm_object_text_set(obj, NULL); 588 elm_object_text_set(obj, NULL);
576 589
@@ -1014,7 +1027,6 @@ app_init(AppData *appdata)
1014 defense_wall_init(appdata); 1027 defense_wall_init(appdata);
1015 1028
1016 appdata->state = Ready; 1029 appdata->state = Ready;
1017 appdata->level = 1;
1018 appdata->bound_w = DEFAULT_WIN_W; 1030 appdata->bound_w = DEFAULT_WIN_W;
1019 appdata->bound_h = DEFAULT_WIN_H; 1031 appdata->bound_h = DEFAULT_WIN_H;
1020 1032