Rev 5229 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5229 | Rev 5231 | ||
---|---|---|---|
1 | #include "cell.h" |
1 | #include "cell.h" |
2 | 2 | ||
3 | __u8 tile_draw(tile* t) |
3 | __u8 tile_draw(tile* t) |
4 | { |
4 | { |
5 | if (t->value) |
5 | if (t->value) |
6 | { |
6 | { |
7 | __u32 bg_color = 0; |
7 | __u32 bg_color = 0; |
8 | __u32 txt_color = 0; |
8 | __u32 txt_color = 0; |
9 | switch (t->value) |
9 | switch (t->value) |
10 | { |
10 | { |
11 | case 0 : bg_color = CELL_COLOR; break; |
11 | case 0 : bg_color = CELL_COLOR; break; |
12 | case 2 : bg_color = 0xEEE4DA; txt_color = 0x776E65; break; |
12 | case 2 : bg_color = 0xEEE4DA; txt_color = 0x776E65; break; |
13 | case 4 : bg_color = 0xEDE0C8; txt_color = 0x776E65; break; |
13 | case 4 : bg_color = 0xEDE0C8; txt_color = 0x776E65; break; |
14 | case 8 : bg_color = 0xF2B179; txt_color = 0xF9F6F2; break; |
14 | case 8 : bg_color = 0xF2B179; txt_color = 0xF9F6F2; break; |
15 | case 16 : bg_color = 0xF59563; txt_color = 0xF9F6F2; break; |
15 | case 16 : bg_color = 0xF59563; txt_color = 0xF9F6F2; break; |
16 | case 32 : bg_color = 0xF67C5F; txt_color = 0xF9F6F2; break; |
16 | case 32 : bg_color = 0xF67C5F; txt_color = 0xF9F6F2; break; |
17 | case 64 : bg_color = 0xF65E3B; txt_color = 0xF9F6F2; break; |
17 | case 64 : bg_color = 0xF65E3B; txt_color = 0xF9F6F2; break; |
18 | case 128 : bg_color = 0xEDCF72; txt_color = 0xF9F6F2; break; |
18 | case 128 : bg_color = 0xEDCF72; txt_color = 0xF9F6F2; break; |
19 | case 256 : bg_color = 0xEDCC61; txt_color = 0xF9F6F2; break; |
19 | case 256 : bg_color = 0xEDCC61; txt_color = 0xF9F6F2; break; |
20 | case 512 : bg_color = 0xEDC850; txt_color = 0xF9F6F2; break; |
20 | case 512 : bg_color = 0xEDC850; txt_color = 0xF9F6F2; break; |
21 | case 1024 : bg_color = 0xEDC53F; txt_color = 0xF9F6F2; break; |
21 | case 1024 : bg_color = 0xEDC53F; txt_color = 0xF9F6F2; break; |
22 | case 2048 : bg_color = 0xEDC22E; txt_color = 0xF9F6F2; break; |
22 | case 2048 : bg_color = 0xEDC22E; txt_color = 0xF9F6F2; break; |
23 | default : bg_color = 0x3C3A32; txt_color = 0xF9F6F2; break; |
23 | default : bg_color = 0x3C3A32; txt_color = 0xF9F6F2; break; |
24 | } |
24 | } |
25 | 25 | ||
26 | rect* begin = &t->cell; |
26 | rect* begin = &t->cell; |
27 | rect* end = &t->transition; |
27 | rect* end = &t->transition; |
28 | 28 | ||
29 | if (rect_transform(begin,end,t->ani_step)) |
29 | if (rect_transform(begin,end,t->ani_step)) |
30 | t->animate = false; |
30 | t->animate = false; |
31 | 31 | ||
32 | rect_draw(begin,bg_color); |
32 | canvas_draw_rect(begin,bg_color); |
33 | rect_draw_value(begin,t->value,txt_color); |
33 | canvas_draw_value(begin,t->value,txt_color); |
34 | 34 | ||
35 | if (t->merged) |
35 | if (t->merged) |
36 | { |
36 | { |
37 | if (rect_transform(&t->merged_rect,end,t->ani_step) && |
37 | if (rect_transform(&t->merged_rect,end,t->ani_step) && |
38 | (t->animate == false)) |
38 | (t->animate == false)) |
39 | { |
39 | { |
40 | t->animate = true; |
40 | t->animate = true; |
41 | t->merged = false; |
41 | t->merged = false; |
42 | t->value *= 2; |
42 | t->value *= 2; |
43 | } |
43 | } |
44 | 44 | ||
45 | rect_draw(&t->merged_rect,bg_color); |
45 | canvas_draw_rect(&t->merged_rect,bg_color); |
46 | rect_draw_value(&t->merged_rect,t->value,txt_color); |
46 | canvas_draw_value(&t->merged_rect,t->value,txt_color); |
47 | } |
47 | } |
48 | } |
48 | } |
49 | 49 | ||
50 | return t->animate; |
50 | return t->animate; |
51 | } |
51 | } |
52 | 52 | ||
53 | __u8 tile_mergeable(tile* from, tile* to) |
53 | __u8 tile_mergeable(tile* from, tile* to) |
54 | { |
54 | { |
55 | return (from && !from->merged && |
55 | return (from && !from->merged && |
56 | to && !to->merged && |
56 | to && !to->merged && |
57 | (from->value == to->value)); |
57 | (from->value == to->value)); |
58 | } |
58 | } |