瀏覽代碼

* 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 年之前
父節點
當前提交
4177c26c2c
共有 6 個檔案被更改,包括 43 行新增51 行删除
  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 查看文件

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

+ 7
- 0
data/ship_green 查看文件

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

+ 4
- 4
src/collide.c 查看文件

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

if(p->x <= t->left[p->y])
if(p->x - 2 <= t->left[p->y])
{
p->x += 3;
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;
}
else if(p->x + 5 >= t->right[p->y])
else if(p->x + 3 >= t->right[p->y])
{
p->x -= 3;
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;
}
}


+ 16
- 16
src/main.c 查看文件

@@ -124,10 +124,10 @@ static void start_game (game *g)
g->p->vx = -2;
break;
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;
case 'k':
if(g->p->y > 1) g->p->y -= 1;
if(g->p->y > 2) g->p->y -= 1;
break;
case 'l':
g->p->vx = 2;
@@ -136,43 +136,43 @@ static void start_game (game *g)
if(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;
case 'f':
if(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;
case 'b':
if(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;
case ' ':
if(g->p->weapon == 0)
{
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 */
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 */
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 + 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 */
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! */
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;
}


+ 6
- 26
src/player.c 查看文件

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

#include "common.h"

struct ee_sprite *ship_sprite;

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

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

ship_sprite = ee_load_sprite("data/ship_green");

return p;
}

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

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

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

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

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

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

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

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


+ 9
- 5
src/weapons.c 查看文件

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

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->n[i]--;
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 */
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_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_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…
取消
儲存