Bladeren bron

* libee/sprite.c:

+ Made sprite loading more robust.
  * src/explosions.c:
    + No longer use ee_putchar etc. to draw our sprites, but use
      ee_draw_sprite().
  * data/:
    + Drew explosion_medium and explosion_small sprites.


git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@140 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 21 jaren geleden
bovenliggende
commit
99ed8ee84e
5 gewijzigde bestanden met toevoegingen van 120 en 118 verwijderingen
  1. +10
    -1
      data/Makefile.am
  2. +60
    -0
      data/explosion_medium
  3. +32
    -0
      data/explosion_small
  4. +8
    -6
      libee/sprite.c
  5. +10
    -111
      src/explosions.c

+ 10
- 1
data/Makefile.am Bestand weergeven

@@ -1 +1,10 @@
EXTRA_DIST = foo_fighter bar_fighter bar_boss baz_fighter item_gem item_heart
EXTRA_DIST = \
foo_fighter \
bar_fighter \
bar_boss \
baz_fighter \
explosion_medium \
explosion_small \
item_gem \
item_heart \
$(NULL)

+ 60
- 0
data/explosion_medium Bestand weergeven

@@ -0,0 +1,60 @@
1 1 0 0
+
d
1 1 0 0
o
d
3 2 1 1
_
)_(
d
ddd
3 3 1 1
._,
)_(
' `
ddd
ddd
ddd
3 3 1 1
.v,
> <
'^`
ddd
ddd
ddd
5 3 2 1
_\~/_
> <
~/_\~
fffff
fffff
fffff
5 3 2 1
_\~/_
> <
~/_\~
ddddd
ddddd
ddddd
5 3 2 1
_\ /_
~/ \~
fffff
fffff
fffff
5 3 2 1
_\ /_

~/ \~
ddddd
ddddd
ddddd
5 3 2 1
. ' ,

' . `
eeeee
eeeee
eeeee

+ 32
- 0
data/explosion_small Bestand weergeven

@@ -0,0 +1,32 @@
1 1 0 0
+
d
1 1 0 0
o
d
3 2 1 1
_
)_(
d
ddd
3 3 1 1
._,
)_(
' `
ddd
ddd
ddd
3 3 1 1
.v,
> <
'^`
ddd
ddd
ddd
3 3 1 1
. ,

' `
ddd
ddd
ddd

+ 8
- 6
libee/sprite.c Bestand weergeven

@@ -88,24 +88,26 @@ struct ee_sprite *ee_load_sprite(const char *file)

for(y = 0; y < h; y++)
{
memset(buf, ' ', w);
buf[w] = '\0';
if(!fgets(buf, BUFSIZ, fd))
goto failed;

for(x = 0; x < w; x++)
for(x = 0; x < w && buf[x] && buf[x] != '\r' && buf[x] != '\n'; x++)
frame->chars[w * y + x] = buf[x];

for(; x < w; x++)
frame->chars[w * y + x] = ' ';
}

for(y = 0; y < h; y++)
{
memset(buf, ' ', w);
buf[w] = '\0';
if(!fgets(buf, BUFSIZ, fd))
goto failed;

for(x = 0; x < w; x++)
for(x = 0; x < w && buf[x] && buf[x] != '\r' && buf[x] != '\n'; x++)
frame->color[w * y + x] = buf[x] - 'a';

for(; x < w; x++)
frame->color[w * y + x] = ' ' - 'a';
}

continue;


+ 10
- 111
src/explosions.c Bestand weergeven

@@ -29,6 +29,9 @@
static void draw_small_explosion(int x, int y, int frame);
static void draw_medium_explosion(int x, int y, int frame);

struct ee_sprite *medium_sprite;
struct ee_sprite *small_sprite;

void init_explosions(game *g, explosions *ex)
{
int i;
@@ -37,6 +40,9 @@ void init_explosions(game *g, explosions *ex)
{
ex->type[i] = EXPLOSION_NONE;
}

medium_sprite = ee_load_sprite("data/explosion_medium");
small_sprite = ee_load_sprite("data/explosion_small");
}

void add_explosion(game *g, explosions *ex, int x, int y, int vx, int vy, int type)
@@ -137,120 +143,13 @@ void update_explosions(game *g, explosions *ex)

static void draw_small_explosion(int x, int y, int frame)
{
switch(frame)
{
case 6:
ee_color(EE_YELLOW);
ee_goto(x, y);
ee_putchar('+');
break;
case 5:
ee_color(EE_YELLOW);
ee_goto(x, y);
ee_putchar('o');
break;
case 4:
ee_color(EE_YELLOW);
ee_goto(x, y-1);
ee_putchar('_');
ee_goto(x-1, y);
ee_putstr(")_(");
break;
case 3:
ee_color(EE_YELLOW);
ee_goto(x-1, y-1);
ee_putstr("._,");
ee_goto(x-1, y);
ee_putstr(")_(");
ee_goto(x-1, y+1);
ee_putstr("\' `");
break;
case 2:
ee_color(EE_YELLOW);
ee_goto(x-1, y-1);
ee_putstr(".v,");
ee_goto(x-1, y);
ee_putstr("> <");
ee_goto(x-1, y+1);
ee_putstr("\'^`");
break;
case 1:
ee_color(EE_WHITE);
ee_goto(x-1, y-1);
ee_putstr(". ,");
ee_goto(x-1, y);
ee_putstr(" ");
ee_goto(x-1, y+1);
ee_putstr("\' `");
break;
}
ee_set_sprite_frame(small_sprite, 6 - frame);
ee_draw_sprite(x, y, small_sprite);
}

static void draw_medium_explosion(int x, int y, int frame)
{
ee_color(EE_YELLOW);

switch(frame)
{
case 10:
ee_goto(x, y);
ee_putchar('+');
break;
case 9:
ee_goto(x, y);
ee_putchar('o');
break;
case 8:
ee_goto(x, y-1);
ee_putchar('_');
ee_goto(x-1, y);
ee_putstr(")_(");
break;
case 7:
ee_goto(x-1, y-1);
ee_putstr("._,");
ee_goto(x-1, y);
ee_putstr(")_(");
ee_goto(x-1, y+1);
ee_putstr("\' `");
break;
case 6:
ee_goto(x-1, y-1);
ee_putstr(".v,");
ee_goto(x-1, y);
ee_putstr("> <");
ee_goto(x-1, y+1);
ee_putstr("\'^`");
break;
case 5:
ee_color(EE_RED);
case 4:
ee_goto(x-2, y-1);
ee_putstr("_\\~/_");
ee_goto(x-2, y);
ee_putstr("> <");
ee_goto(x-2, y+1);
ee_putstr("~/_\\~");
break;
case 3:
ee_color(EE_RED);
case 2:
ee_goto(x-2, y-1);
ee_putstr("_\\ /_");
ee_goto(x-2, y);
ee_putstr("_ _");
ee_goto(x-2, y+1);
ee_putstr(" / \\ ");
break;
case 1:
ee_color(EE_WHITE);
ee_goto(x-2, y-1);
ee_putstr(". \' ,");
ee_goto(x-2, y);
ee_putstr(" ");
ee_goto(x-2, y+1);
ee_putstr("\' . `");
break;
}
ee_set_sprite_frame(medium_sprite, 10 - frame);
ee_draw_sprite(x, y, medium_sprite);
}


Laden…
Annuleren
Opslaan