Last change
on this file since 20 was
20,
checked in by Sam Hocevar, 20 years ago
|
- real Debian package files.
- two new types of aliens. only one rules.
- removed gfx_write in favor of gfx_putchar and gfx_putstr.
- added bonuses at alien death. they do nothing yet.
- seeker missiles. 'b' to test.
- weapon resolution is now 16*char. needs to be generalized.
- fixed the supernova bugs. center could collide with the tunnel, and
the last frame was badly displayed.
- lots of cleanups everywhere.
|
File size:
1.1 KB
|
Line | |
---|
1 | |
---|
2 | #include <stdlib.h> |
---|
3 | |
---|
4 | #include "common.h" |
---|
5 | |
---|
6 | /* Init tunnel */ |
---|
7 | player * create_player( game *g ) |
---|
8 | { |
---|
9 | player *p = malloc(sizeof(player)); |
---|
10 | |
---|
11 | p->x = g->w / 2; |
---|
12 | p->y = g->h - 2; |
---|
13 | p->dir = 0; |
---|
14 | p->weapon = 0; |
---|
15 | p->nuke = 0; |
---|
16 | |
---|
17 | return p; |
---|
18 | } |
---|
19 | |
---|
20 | void free_player( player *p ) |
---|
21 | { |
---|
22 | free( p ); |
---|
23 | } |
---|
24 | |
---|
25 | void draw_player( game *g, player *p ) |
---|
26 | { |
---|
27 | gfx_goto( p->x + 2, p->y - 2 ); |
---|
28 | gfx_color( GREEN ); |
---|
29 | gfx_putstr( "/\\" ); |
---|
30 | gfx_goto( p->x + 1, p->y - 1 ); |
---|
31 | gfx_putchar( '(' ); |
---|
32 | gfx_color( YELLOW ); |
---|
33 | gfx_putstr( "()" ); |
---|
34 | gfx_color( GREEN ); |
---|
35 | gfx_putchar( ')' ); |
---|
36 | gfx_goto( p->x, p->y ); |
---|
37 | gfx_color( GREEN ); |
---|
38 | gfx_putstr( "I<__>I" ); |
---|
39 | } |
---|
40 | |
---|
41 | void update_player( game *g, player *p ) |
---|
42 | { |
---|
43 | if( p->weapon ) |
---|
44 | { |
---|
45 | p->weapon--; |
---|
46 | } |
---|
47 | |
---|
48 | if( p->nuke ) |
---|
49 | { |
---|
50 | p->nuke--; |
---|
51 | } |
---|
52 | |
---|
53 | if( p->dir < 0 ) |
---|
54 | { |
---|
55 | if( p->dir == -3 && p->x > -2 ) p->x -= 1; |
---|
56 | else if( p->x > -1 ) p->x -= 1; |
---|
57 | |
---|
58 | p->dir++; |
---|
59 | } |
---|
60 | else if( p->dir > 0 ) |
---|
61 | { |
---|
62 | if( p->dir == 3 && p->x < g->w - 8 ) p->x += 1; |
---|
63 | else if( p->x < g->w - 7 ) p->x += 1; |
---|
64 | p->dir--; |
---|
65 | } |
---|
66 | } |
---|
67 | |
---|
Note: See
TracBrowser
for help on using the repository browser.