Revision 192
added zoom/scale
proj.c | ||
---|---|---|
17 | 17 |
#include "sprite.h" |
18 | 18 |
#include "rectangle.h" |
19 | 19 |
#include "font.h" |
20 |
#include "ent.h" |
|
20 | 21 |
|
21 |
#ifdef DIOGO |
|
22 |
#include "shooter.h" |
|
23 |
#endif |
|
22 |
#include "crosshair.h" |
|
23 |
#include "shooter.h" |
|
24 |
#include "pistol.h" |
|
25 |
#include "nothing.h" |
|
24 | 26 |
|
25 |
#ifdef TELMO |
|
26 |
#include "crosshair.h" |
|
27 |
#include "shooter.h" |
|
28 |
#endif |
|
29 |
|
|
30 | 27 |
int main(int argc, char* argv[]) { |
31 | 28 |
|
32 | 29 |
lcf_set_language("EN-US"); |
... | ... | |
46 | 43 |
|
47 | 44 |
int r; |
48 | 45 |
|
46 |
font_t *consolas = font_ctor("/home/lcom/labs/proj/font/Consolas/xpm2"); |
|
47 |
if(consolas == NULL){ printf("Failed to load consolas\n"); return 1; } |
|
48 |
|
|
49 | 49 |
/// subscribe interrupts |
50 | 50 |
if (subscribe_all()) { return 1; } |
51 | 51 |
|
... | ... | |
56 | 56 |
return 1; |
57 | 57 |
} |
58 | 58 |
|
59 |
font_t *consolas = font_ctor("/home/lcom/labs/proj/font/xpm2"); |
|
60 |
|
|
61 | 59 |
/// Load stuff |
60 |
basic_sprite_t *bsp_crosshair = NULL; |
|
61 |
basic_sprite_t *bsp_shooter = NULL; |
|
62 |
basic_sprite_t *bsp_pistol = NULL; |
|
63 |
basic_sprite_t *bsp_nothing = NULL; |
|
64 |
sprite_t *sp_crosshair = NULL; |
|
62 | 65 |
{ |
63 | 66 |
graph_clear_screen(); |
64 | 67 |
text_t *txt = text_ctor(consolas, "Loading..."); |
65 | 68 |
text_draw(txt); |
66 | 69 |
text_dtor(txt); |
67 | 70 |
graph_draw(); |
71 |
|
|
72 |
bsp_crosshair = get_crosshair(); if(bsp_crosshair == NULL) printf("Failed to get crosshair\n"); |
|
73 |
bsp_shooter = get_shooter (); if(bsp_shooter == NULL) printf("Failed to get shooter\n"); |
|
74 |
bsp_pistol = get_pistol (); if(bsp_pistol == NULL) printf("Failed to get pistol\n"); |
|
75 |
bsp_nothing = get_nothing (); if(bsp_nothing == NULL) printf("Failed to get nothing\n"); |
|
76 |
|
|
77 |
sp_crosshair = sprite_ctor(bsp_crosshair); if(sp_crosshair == NULL) printf("Failed to get crosshair sprite\n"); |
|
68 | 78 |
} |
79 |
|
|
69 | 80 |
#ifdef DIOGO |
70 | 81 |
graph_clear_screen(); |
71 | 82 |
|
... | ... | |
96 | 107 |
#endif |
97 | 108 |
|
98 | 109 |
#ifdef TELMO |
99 |
sprite_t *crosshair = get_crosshair(); |
|
100 |
sprite_t *shooter1 = get_shooter(); |
|
101 |
sprite_set_pos(shooter1, graph_get_XRes()/2, graph_get_YRes()/2); |
|
102 |
sprite_set_scale(shooter1, 4); |
|
110 |
ent_set_scale(2.0); |
|
111 |
|
|
112 |
ent_t *shooter1 = ent_ctor(bsp_shooter, bsp_pistol); if(shooter1 == NULL) printf("Failed to get shooter1\n"); |
|
113 |
ent_set_pos(shooter1, 0, 0); |
|
114 |
ent_set_origin(ent_get_x(shooter1)-ent_get_XLength()/2.0, |
|
115 |
ent_get_y(shooter1)-ent_get_YLength()/2.0); |
|
116 |
|
|
117 |
ent_t *shooter2 = ent_ctor(bsp_shooter, bsp_nothing); |
|
118 |
ent_set_pos(shooter2, -50, -50); |
|
119 |
|
|
103 | 120 |
graph_clear_screen(); |
104 |
sprite_draw(crosshair);
|
|
105 |
sprite_draw(shooter1);
|
|
121 |
ent_draw(shooter1);
|
|
122 |
sprite_draw(sp_crosshair);
|
|
106 | 123 |
graph_draw(); |
107 | 124 |
#endif |
108 | 125 |
|
... | ... | |
133 | 150 |
uint32_t refresh_count_value = sys_hz() / REFRESH_RATE; |
134 | 151 |
if (no_interrupts % refresh_count_value == 0) { |
135 | 152 |
update_movement(shooter1); |
136 |
sprite_set_pos(crosshair, get_mouse_X(), get_mouse_Y()); |
|
153 |
ent_set_origin(ent_get_x(shooter1)-ent_get_XLength()/2.0, |
|
154 |
ent_get_y(shooter1)-ent_get_YLength()/2.0); |
|
155 |
|
|
156 |
sprite_set_pos(sp_crosshair, get_mouse_X(), get_mouse_Y()); |
|
137 | 157 |
double angle = get_mouse_angle(shooter1); |
138 |
sprite_set_angle(shooter1, angle - M_PI_2);
|
|
158 |
ent_set_angle(shooter1, angle - M_PI_2);
|
|
139 | 159 |
graph_clear_screen(); |
140 |
sprite_draw(crosshair); |
|
141 |
sprite_draw(shooter1); |
|
160 |
ent_draw(shooter2); |
|
161 |
ent_draw(shooter1); |
|
162 |
sprite_draw(sp_crosshair); |
|
142 | 163 |
graph_draw(); |
143 | 164 |
} |
144 | 165 |
} |
... | ... | |
181 | 202 |
#endif |
182 | 203 |
} |
183 | 204 |
|
184 |
font_dtor(consolas); |
|
205 |
#ifdef TELMO |
|
206 |
ent_dtor(shooter1); shooter1 = NULL; |
|
207 |
#endif |
|
185 | 208 |
|
209 |
basic_sprite_dtor(bsp_crosshair); bsp_crosshair = NULL; |
|
210 |
basic_sprite_dtor(bsp_shooter ); bsp_shooter = NULL; |
|
211 |
sprite_dtor (sp_crosshair ); sp_crosshair = NULL; |
|
212 |
font_dtor (consolas ); consolas = NULL; |
|
213 |
|
|
186 | 214 |
// Unsubscribe interrupts |
187 | 215 |
if (unsubscribe_all()) { |
188 | 216 |
if (cleanup()) |
Also available in: Unified diff