1 | /* |
---|
2 | * ttyvaders Textmode shoot'em up |
---|
3 | * Copyright (c) 2002 Sam Hocevar <sam@zoy.org> |
---|
4 | * All Rights Reserved |
---|
5 | * |
---|
6 | * $Id: bonus.c 88 2003-11-09 13:16:19Z sam $ |
---|
7 | * |
---|
8 | * This program is free software; you can redistribute it and/or modify |
---|
9 | * it under the terms of the GNU General Public License as published by |
---|
10 | * the Free Software Foundation; either version 2 of the License, or |
---|
11 | * (at your option) any later version. |
---|
12 | * |
---|
13 | * This program is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | * GNU General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU General Public License |
---|
19 | * along with this program; if not, write to the Free Software |
---|
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
21 | */ |
---|
22 | |
---|
23 | #include <stdlib.h> |
---|
24 | |
---|
25 | #include "common.h" |
---|
26 | |
---|
27 | void init_bonus(game *g, bonus *bo) |
---|
28 | { |
---|
29 | int i; |
---|
30 | |
---|
31 | for(i = 0; i < BONUS; i++) |
---|
32 | { |
---|
33 | bo->type[i] = BONUS_NONE; |
---|
34 | } |
---|
35 | } |
---|
36 | |
---|
37 | void draw_bonus(game *g, bonus *bo) |
---|
38 | { |
---|
39 | int i; |
---|
40 | |
---|
41 | for(i = 0; i < BONUS; i++) |
---|
42 | { |
---|
43 | switch(bo->type[i]) |
---|
44 | { |
---|
45 | case BONUS_GREEN: |
---|
46 | ee_color((bo->n[i]/2 % 3) ? EE_GREEN : EE_WHITE); |
---|
47 | ee_goto(bo->x[i]+1, bo->y[i]-1); |
---|
48 | ee_putchar('_'); |
---|
49 | ee_goto(bo->x[i], bo->y[i]); |
---|
50 | ee_putstr("/ \\"); |
---|
51 | ee_goto(bo->x[i], bo->y[i]+1); |
---|
52 | ee_putstr("\\_/"); |
---|
53 | ee_color(EE_WHITE); |
---|
54 | ee_goto(bo->x[i]+1, bo->y[i]); |
---|
55 | ee_putchar('g'); |
---|
56 | break; |
---|
57 | case BONUS_LIFE: |
---|
58 | ee_color((bo->n[i] % 3) ? EE_RED : EE_WHITE); |
---|
59 | ee_goto(bo->x[i]+1, bo->y[i]-1); |
---|
60 | ee_putchar('_'); |
---|
61 | ee_goto(bo->x[i]+3, bo->y[i]-1); |
---|
62 | ee_putchar('_'); |
---|
63 | ee_goto(bo->x[i], bo->y[i]); |
---|
64 | ee_putstr("( ' )"); |
---|
65 | ee_goto(bo->x[i]+1, bo->y[i]+1); |
---|
66 | ee_putstr("`v'"); |
---|
67 | ee_color(EE_WHITE); |
---|
68 | ee_goto(bo->x[i]+3, bo->y[i]); |
---|
69 | ee_putchar('^'); |
---|
70 | break; |
---|
71 | case BONUS_NONE: |
---|
72 | break; |
---|
73 | } |
---|
74 | } |
---|
75 | } |
---|
76 | |
---|
77 | void update_bonus(game *g, bonus *bo) |
---|
78 | { |
---|
79 | int i; |
---|
80 | |
---|
81 | for(i = 0; i < BONUS; i++) |
---|
82 | { |
---|
83 | switch(bo->type[i]) |
---|
84 | { |
---|
85 | case BONUS_GREEN: |
---|
86 | bo->n[i]++; |
---|
87 | bo->y[i]++; |
---|
88 | if(bo->y[i] > g->h) |
---|
89 | { |
---|
90 | bo->type[i] = BONUS_NONE; |
---|
91 | } |
---|
92 | break; |
---|
93 | case BONUS_LIFE: |
---|
94 | bo->n[i]++; |
---|
95 | bo->y[i]++; |
---|
96 | if(bo->y[i] > g->h) |
---|
97 | { |
---|
98 | bo->type[i] = BONUS_NONE; |
---|
99 | } |
---|
100 | break; |
---|
101 | case BONUS_NONE: |
---|
102 | break; |
---|
103 | } |
---|
104 | } |
---|
105 | } |
---|
106 | |
---|
107 | void add_bonus(game *g, bonus *bo, int x, int y, int type) |
---|
108 | { |
---|
109 | int i; |
---|
110 | |
---|
111 | for(i = 0; i < BONUS; i++) |
---|
112 | { |
---|
113 | if(bo->type[i] == BONUS_NONE) |
---|
114 | { |
---|
115 | bo->type[i] = type; |
---|
116 | bo->x[i] = x; |
---|
117 | bo->y[i] = y; |
---|
118 | bo->n[i] = 0; |
---|
119 | break; |
---|
120 | } |
---|
121 | } |
---|
122 | } |
---|
123 | |
---|