Browse Source

* src/weapons.c:

+ Use ee_draw_ellipse() instead of ee_draw_circle() to draw the nuke.
  * src/player.c:
    + Use ee_draw_sprite() to draw our ship.


git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@150 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 21 years ago
parent
commit
4177c26c2c
6 changed files with 43 additions and 51 deletions
  1. +1
    -0
      data/Makefile.am
  2. +7
    -0
      data/ship_green
  3. +4
    -4
      src/collide.c
  4. +16
    -16
      src/main.c
  5. +6
    -26
      src/player.c
  6. +9
    -5
      src/weapons.c

+ 1
- 0
data/Makefile.am View File

@@ -8,6 +8,7 @@ EXTRA_DIST = \
explosion_small \ explosion_small \
item_gem \ item_gem \
item_heart \ item_heart \
ship_green \
weapon_bomb \ weapon_bomb \
weapon_fragbomb \ weapon_fragbomb \
$(NULL) $(NULL)

+ 7
- 0
data/ship_green View File

@@ -0,0 +1,7 @@
6 3 2 1
/\
(())
I<__>I
cc
cddc
cccccc

+ 4
- 4
src/collide.c View File

@@ -278,18 +278,18 @@ void collide_player_tunnel(game *g, player *p, tunnel *t, explosions *ex)
return; return;
} }


if(p->x <= t->left[p->y])
if(p->x - 2 <= t->left[p->y])
{ {
p->x += 3; p->x += 3;
p->vx = 2; p->vx = 2;
add_explosion(g, ex, p->x+1, p->y-1, 0, 0, EXPLOSION_SMALL);
add_explosion(g, ex, p->x-1, p->y, 0, 0, EXPLOSION_SMALL);
p->life -= 180; p->life -= 180;
} }
else if(p->x + 5 >= t->right[p->y])
else if(p->x + 3 >= t->right[p->y])
{ {
p->x -= 3; p->x -= 3;
p->vx = -2; p->vx = -2;
add_explosion(g, ex, p->x+4, p->y-1, 0, 0, EXPLOSION_SMALL);
add_explosion(g, ex, p->x+2, p->y, 0, 0, EXPLOSION_SMALL);
p->life -= 180; p->life -= 180;
} }
} }


+ 16
- 16
src/main.c View File

@@ -124,10 +124,10 @@ static void start_game (game *g)
g->p->vx = -2; g->p->vx = -2;
break; break;
case 'j': case 'j':
if(g->p->y < g->h - 2) g->p->y += 1;
if(g->p->y < g->h - 3) g->p->y += 1;
break; break;
case 'k': case 'k':
if(g->p->y > 1) g->p->y -= 1;
if(g->p->y > 2) g->p->y -= 1;
break; break;
case 'l': case 'l':
g->p->vx = 2; g->p->vx = 2;
@@ -136,43 +136,43 @@ static void start_game (game *g)
if(g->p->special >= COST_NUKE) if(g->p->special >= COST_NUKE)
{ {
g->p->special -= COST_NUKE; g->p->special -= COST_NUKE;
add_weapon(g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, 0, WEAPON_NUKE);
add_weapon(g, g->wp, g->p->x << 4, g->p->y << 4, 0, 0, WEAPON_NUKE);
} }
break; break;
case 'f': case 'f':
if(g->p->special >= COST_FRAGBOMB) if(g->p->special >= COST_FRAGBOMB)
{ {
g->p->special -= COST_FRAGBOMB; g->p->special -= COST_FRAGBOMB;
add_weapon(g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, -16, WEAPON_FRAGBOMB);
add_weapon(g, g->wp, g->p->x << 4, g->p->y << 4, 0, -16, WEAPON_FRAGBOMB);
} }
break; break;
case 'b': case 'b':
if(g->p->special >= COST_BEAM) if(g->p->special >= COST_BEAM)
{ {
g->p->special -= COST_BEAM; g->p->special -= COST_BEAM;
add_weapon(g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, 0, WEAPON_BEAM);
add_weapon(g, g->wp, g->p->x << 4, g->p->y << 4, 0, 0, WEAPON_BEAM);
} }
break; break;
case ' ': case ' ':
if(g->p->weapon == 0) if(g->p->weapon == 0)
{ {
g->p->weapon = 4; g->p->weapon = 4;
add_weapon(g, g->wp, g->p->x << 4, g->p->y << 4, 0, -32, WEAPON_LASER);
add_weapon(g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 0, -32, WEAPON_LASER);
add_weapon(g, g->wp, (g->p->x - 2) << 4, g->p->y << 4, 0, -32, WEAPON_LASER);
add_weapon(g, g->wp, (g->p->x + 3) << 4, g->p->y << 4, 0, -32, WEAPON_LASER);
/* Extra schtuph */ /* Extra schtuph */
add_weapon(g, g->wp, g->p->x << 4, g->p->y << 4, -24, -16, WEAPON_SEEKER);
add_weapon(g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 24, -16, WEAPON_SEEKER);
add_weapon(g, g->wp, (g->p->x - 2) << 4, g->p->y << 4, -24, -16, WEAPON_SEEKER);
add_weapon(g, g->wp, (g->p->x + 3) << 4, g->p->y << 4, 24, -16, WEAPON_SEEKER);
/* More schtuph */ /* More schtuph */
add_weapon(g, g->wp, (g->p->x + 1) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER);
add_weapon(g, g->wp, (g->p->x + 4) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER);
/* Even more schtuph */
add_weapon(g, g->wp, (g->p->x - 1) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER);
add_weapon(g, g->wp, (g->p->x + 2) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER); add_weapon(g, g->wp, (g->p->x + 2) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER);
add_weapon(g, g->wp, (g->p->x + 3) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER);
/* Even more schtuph */
add_weapon(g, g->wp, g->p->x << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER);
add_weapon(g, g->wp, (g->p->x + 1) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER);
/* Extra schtuph */ /* Extra schtuph */
add_weapon(g, g->wp, g->p->x << 4, g->p->y << 4, -32, 0, WEAPON_SEEKER);
add_weapon(g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 32, 0, WEAPON_SEEKER);
add_weapon(g, g->wp, (g->p->x - 2) << 4, g->p->y << 4, -32, 0, WEAPON_SEEKER);
add_weapon(g, g->wp, (g->p->x + 3) << 4, g->p->y << 4, 32, 0, WEAPON_SEEKER);
/* MORE SCHTUPH! */ /* MORE SCHTUPH! */
add_weapon(g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, -16, WEAPON_BOMB);
add_weapon(g, g->wp, g->p->x << 4, g->p->y << 4, 0, -16, WEAPON_BOMB);
} }
break; break;
} }


+ 6
- 26
src/player.c View File

@@ -26,13 +26,15 @@


#include "common.h" #include "common.h"


struct ee_sprite *ship_sprite;

/* Init tunnel */ /* Init tunnel */
player * create_player(game *g) player * create_player(game *g)
{ {
player *p = malloc(sizeof(player)); player *p = malloc(sizeof(player));


p->x = g->w / 2; p->x = g->w / 2;
p->y = g->h - 2;
p->y = g->h - 3;
p->vx = 0; p->vx = 0;
p->vy = 0; p->vy = 0;
p->weapon = 0; p->weapon = 0;
@@ -40,6 +42,8 @@ player * create_player(game *g)
p->life = MAX_LIFE; p->life = MAX_LIFE;
p->dead = 0; p->dead = 0;


ship_sprite = ee_load_sprite("data/ship_green");

return p; return p;
} }


@@ -51,25 +55,15 @@ void free_player(player *p)
void draw_player(game *g, player *p) void draw_player(game *g, player *p)
{ {
if(p->dead) if(p->dead)
{
return; return;
}


ee_color(EE_GREEN);
ee_putstr(p->x + 2, p->y - 2, "/\\");
ee_putchar(p->x + 1, p->y - 1, '(');
ee_putchar(p->x + 4, p->y - 1, ')');
ee_putstr(p->x, p->y, "I<__>I");
ee_color(EE_YELLOW);
ee_putstr(p->x + 2, p->y - 1, "()");
ee_draw_sprite(p->x, p->y, ship_sprite);
} }


void update_player(game *g, player *p) void update_player(game *g, player *p)
{ {
if(p->dead) if(p->dead)
{
return; return;
}


if(p->life <= 0) if(p->life <= 0)
{ {
@@ -80,40 +74,26 @@ void update_player(game *g, player *p)


/* Update weapon stats */ /* Update weapon stats */
if(p->weapon) if(p->weapon)
{
p->weapon--; p->weapon--;
}


if(p->special < MAX_SPECIAL) if(p->special < MAX_SPECIAL)
{
p->special++; p->special++;
}


/* Update life */ /* Update life */
if(p->life < MAX_LIFE) if(p->life < MAX_LIFE)
{
p->life++; p->life++;
}


/* Update coords */ /* Update coords */
p->x += p->vx; p->x += p->vx;


if(p->vx < 0) if(p->vx < 0)
{
p->vx++; p->vx++;
}
else if(p->vx > 0) else if(p->vx > 0)
{
p->vx--; p->vx--;
}


if(p->x < 1) if(p->x < 1)
{
p->x = 1; p->x = 1;
}
else if(p->x > g->w - 7) else if(p->x > g->w - 7)
{
p->x = g->w - 7; p->x = g->w - 7;
}
} }



+ 9
- 5
src/weapons.c View File

@@ -219,7 +219,7 @@ void update_weapons(game *g, weapons *wp)
break; break;


case WEAPON_BEAM: case WEAPON_BEAM:
wp->x[i] = (g->p->x + 2) << 4;
wp->x[i] = g->p->x << 4;
wp->y[i] = g->p->y << 4; wp->y[i] = g->p->y << 4;
wp->n[i]--; wp->n[i]--;
if(wp->n[i] < 0) if(wp->n[i] < 0)
@@ -447,11 +447,15 @@ static void draw_nuke(int x, int y, int frame)


/* Lots of duplicate pixels, but we don't care */ /* Lots of duplicate pixels, but we don't care */
ee_color(EE_BLUE); ee_color(EE_BLUE);
ee_draw_circle(x, y, r++, ':');
ee_draw_ellipse(x, y, r, r / 2, ':');
ee_draw_ellipse(x, y, r + 1, r / 2, ':');
ee_draw_ellipse(x, y, r + 2, r / 2, ':');
ee_color(EE_CYAN); ee_color(EE_CYAN);
ee_draw_circle(x, y, r++, '%');
ee_draw_ellipse(x, y, r + 2, r / 2 + 1, '%');
ee_draw_ellipse(x, y, r + 3, r / 2 + 1, '%');
ee_color(EE_WHITE); ee_color(EE_WHITE);
ee_draw_circle(x, y, r++, '#');
ee_draw_circle(x, y, r++, '#');
ee_draw_ellipse(x, y, r + 3, r / 2 + 2, '#');
ee_draw_ellipse(x, y, r + 4, r / 2 + 2, '#');
ee_draw_ellipse(x, y, r + 4, r / 2 + 3, '#');
} }



Loading…
Cancel
Save