1 | |
---|
2 | #include <stdlib.h> |
---|
3 | |
---|
4 | #include "common.h" |
---|
5 | |
---|
6 | void init_bonus( game *g, bonus *bo ) |
---|
7 | { |
---|
8 | int i; |
---|
9 | |
---|
10 | for( i = 0; i < BONUS; i++ ) |
---|
11 | { |
---|
12 | bo->type[i] = BONUS_NONE; |
---|
13 | } |
---|
14 | } |
---|
15 | |
---|
16 | void draw_bonus( game *g, bonus *bo ) |
---|
17 | { |
---|
18 | int i; |
---|
19 | |
---|
20 | for( i = 0; i < BONUS; i++ ) |
---|
21 | { |
---|
22 | switch( bo->type[i] ) |
---|
23 | { |
---|
24 | case BONUS_GREEN: |
---|
25 | gfx_color( (bo->n[i]/2 % 3) ? GREEN : WHITE ); |
---|
26 | gfx_goto( bo->x[i]+1, bo->y[i]-1 ); |
---|
27 | gfx_putchar( '_' ); |
---|
28 | gfx_goto( bo->x[i], bo->y[i] ); |
---|
29 | gfx_putstr( "/ \\" ); |
---|
30 | gfx_goto( bo->x[i], bo->y[i]+1 ); |
---|
31 | gfx_putstr( "\\_/" ); |
---|
32 | gfx_color( WHITE ); |
---|
33 | gfx_goto( bo->x[i]+1, bo->y[i] ); |
---|
34 | gfx_putchar( 'g' ); |
---|
35 | break; |
---|
36 | case BONUS_LIFE: |
---|
37 | gfx_color( (bo->n[i] % 3) ? RED : WHITE ); |
---|
38 | gfx_goto( bo->x[i]+1, bo->y[i]-1 ); |
---|
39 | gfx_putchar( '_' ); |
---|
40 | gfx_goto( bo->x[i]+3, bo->y[i]-1 ); |
---|
41 | gfx_putchar( '_' ); |
---|
42 | gfx_goto( bo->x[i], bo->y[i] ); |
---|
43 | gfx_putstr( "( ' )" ); |
---|
44 | gfx_goto( bo->x[i]+1, bo->y[i]+1 ); |
---|
45 | gfx_putstr( "`v'" ); |
---|
46 | gfx_color( WHITE ); |
---|
47 | gfx_goto( bo->x[i]+3, bo->y[i] ); |
---|
48 | gfx_putchar( '^' ); |
---|
49 | break; |
---|
50 | case BONUS_NONE: |
---|
51 | break; |
---|
52 | } |
---|
53 | } |
---|
54 | } |
---|
55 | |
---|
56 | void update_bonus( game *g, bonus *bo ) |
---|
57 | { |
---|
58 | int i; |
---|
59 | |
---|
60 | for( i = 0; i < BONUS; i++ ) |
---|
61 | { |
---|
62 | switch( bo->type[i] ) |
---|
63 | { |
---|
64 | case BONUS_GREEN: |
---|
65 | bo->n[i]++; |
---|
66 | bo->y[i]++; |
---|
67 | if( bo->y[i] > g->h ) |
---|
68 | { |
---|
69 | bo->type[i] = BONUS_NONE; |
---|
70 | } |
---|
71 | break; |
---|
72 | case BONUS_LIFE: |
---|
73 | bo->n[i]++; |
---|
74 | bo->y[i]++; |
---|
75 | if( bo->y[i] > g->h ) |
---|
76 | { |
---|
77 | bo->type[i] = BONUS_NONE; |
---|
78 | } |
---|
79 | break; |
---|
80 | case BONUS_NONE: |
---|
81 | break; |
---|
82 | } |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | void add_bonus( game *g, bonus *bo, int x, int y, int type ) |
---|
87 | { |
---|
88 | int i; |
---|
89 | |
---|
90 | for( i = 0; i < BONUS; i++ ) |
---|
91 | { |
---|
92 | if( bo->type[i] == BONUS_NONE ) |
---|
93 | { |
---|
94 | bo->type[i] = type; |
---|
95 | bo->x[i] = x; |
---|
96 | bo->y[i] = y; |
---|
97 | bo->n[i] = 0; |
---|
98 | break; |
---|
99 | } |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|