Procházet zdrojové kódy

* libee/graphics.c:

+ Moved ee_putstr() and ee_putchar() in here.
  * libee/ee.h:
    + Got rid of ee_goto().
    + Moved <slang.h> or <curses.h> into libee.
  * Replaced ee_goto()/ee_putstr() pairs with ee_putstr().
  * Ditto for ee_putchar().


git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@148 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam před 21 roky
rodič
revize
8471fc8c00
17 změnil soubory, kde provedl 264 přidání a 309 odebrání
  1. +1
    -0
      libee/Makefile.am
  2. +10
    -16
      libee/conic.c
  3. +6
    -24
      libee/ee.c
  4. +6
    -28
      libee/ee.h
  5. +93
    -0
      libee/graphics.c
  6. +6
    -0
      libee/io.c
  7. +14
    -12
      libee/line.c
  8. +6
    -0
      libee/math.c
  9. +8
    -2
      libee/sprite.c
  10. +7
    -4
      libee/triangle.c
  11. +10
    -10
      src/box.c
  12. +9
    -16
      src/overlay.c
  13. +5
    -10
      src/player.c
  14. +1
    -2
      src/starfield.c
  15. +6
    -40
      src/tunnel.c
  16. +56
    -112
      src/weapons.c
  17. +20
    -33
      test/demo.c

+ 1
- 0
libee/Makefile.am Zobrazit soubor

@@ -6,6 +6,7 @@ lib_LIBRARIES = libee.a
libee_a_SOURCES = \
ee.c \
ee.h \
graphics.c \
io.c \
math.c \
line.c \


+ 10
- 16
libee/conic.c Zobrazit soubor

@@ -22,6 +22,12 @@

#include "config.h"

#ifdef USE_SLANG
# include <slang.h>
#elif USE_NCURSES
# include <curses.h>
#endif

#include <stdlib.h>
#include <inttypes.h>

@@ -99,27 +105,15 @@ static void ellipsepoints(int xo, int yo, int x, int y, char c)
b |= 0x8;

if((b & (0x1|0x4)) == (0x1|0x4))
{
ee_goto(xo + x, yo + y);
ee_putchar(c);
}
ee_putchar(xo + x, yo + y, c);

if((b & (0x2|0x4)) == (0x2|0x4))
{
ee_goto(xo - x, yo + y);
ee_putchar(c);
}
ee_putchar(xo - x, yo + y, c);

if((b & (0x1|0x8)) == (0x1|0x8))
{
ee_goto(xo + x, yo - y);
ee_putchar(c);
}
ee_putchar(xo + x, yo - y, c);

if((b & (0x2|0x8)) == (0x2|0x8))
{
ee_goto(xo - x, yo - y);
ee_putchar(c);
}
ee_putchar(xo - x, yo - y, c);
}


+ 6
- 24
libee/ee.c Zobrazit soubor

@@ -22,6 +22,12 @@

#include "config.h"

#ifdef USE_SLANG
# include <slang.h>
#elif USE_NCURSES
# include <curses.h>
#endif

#include <stdlib.h>
#include <unistd.h>
#include <string.h>
@@ -127,28 +133,6 @@ int ee_get_height(void)
#endif
}

void ee_clear(void)
{
#if defined(USE_SLANG) || defined(USE_NCURSES)
/* We could use SLsmg_cls(), but drawing empty lines is much faster */
int x = ee_get_width(), y = ee_get_height();
char *empty_line = malloc((x + 1) * sizeof(char));

memset(empty_line, ' ', x);
empty_line[x] = '\0';

while(y--)
{
ee_goto(0, y);
ee_putstr(empty_line);
}

free(empty_line);
#else
/* Use dummy driver */
#endif
}

static int64_t local_time(void)
{
struct timeval tv;
@@ -166,8 +150,6 @@ void ee_refresh(void)
static int64_t local_clock = 0;
int64_t now;

ee_goto(0, 0);

if(!local_clock)
{
/* Initialize local_clock */


+ 6
- 28
libee/ee.h Zobrazit soubor

@@ -21,33 +21,7 @@
*/

/*
* Graphics primitives
*/
#ifdef USE_SLANG
# include <slang.h>
# define ee_color(x) SLsmg_set_color(x)
# define ee_goto(x,y) SLsmg_gotorc(y,x)
# define ee_putchar(x) SLsmg_write_char(x)
# define ee_putstr(x) SLsmg_write_string(x)
#elif USE_NCURSES
# define box box_divert
# include <curses.h>
# undef box
# define ee_color(x) attrset(COLOR_PAIR(x))
# define ee_goto(x,y) move(y,x)
# define ee_putchar(x) addch(x)
# define ee_putstr(x) addstr(x)
#else
# define ee_color(x) (void)(x)
# define ee_goto(x,y) do{ (void)(x); (void)(y); } while(0)
# define ee_putchar(x) (void)(x)
# define ee_putstr(x) (void)(x)
#endif

#define ee_putcharTO(x,y,c) do{ ee_goto(x,y); ee_putchar(c); }while(0)

/*
* Colours
* Colors
*/
#define EE_BLACK 1
#define EE_GREEN 2
@@ -72,12 +46,16 @@ int ee_init(void);
void ee_set_delay(int);
int ee_get_width(void);
int ee_get_height(void);
void ee_clear(void);
void ee_refresh(void);
void ee_end(void);

char ee_get_key(void);

void ee_color(int);
void ee_putchar(int, int, char);
void ee_putstr(int, int, char *);
void ee_clear(void);

void ee_draw_line(int, int, int, int, char);
void ee_draw_thin_line(int, int, int, int);
void ee_draw_circle(int, int, int, char);


+ 93
- 0
libee/graphics.c Zobrazit soubor

@@ -0,0 +1,93 @@
/*
* libee ASCII-Art library
* Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "config.h"

#ifdef USE_SLANG
# include <slang.h>
#elif USE_NCURSES
# include <curses.h>
#endif

#include <string.h>
#include <stdlib.h>

#include "ee.h"

void ee_color(int color)
{
#ifdef USE_SLANG
SLsmg_set_color(color);
#elif USE_NCURSES
attrset(COLOR_PAIR(color));
#else
/* Use dummy driver */
#endif
}

void ee_putchar(int x, int y, char c)
{
#ifdef USE_SLANG
SLsmg_gotorc(y,x);
SLsmg_write_char(c);
#elif USE_NCURSES
move(y,x);
addch(c);
#else
/* Use dummy driver */
#endif
}

void ee_putstr(int x, int y, char *s)
{
#ifdef USE_SLANG
SLsmg_gotorc(y,x);
SLsmg_write_string(s);
#elif USE_NCURSES
move(y,x);
addstr(s);
#else
/* Use dummy driver */
#endif
}

void ee_clear(void)
{
#if defined(USE_SLANG) || defined(USE_NCURSES)
/* We could use SLsmg_cls(), but drawing empty lines is much faster */
int x = ee_get_width(), y = ee_get_height();
char *empty_line = malloc((x + 1) * sizeof(char));

memset(empty_line, ' ', x);
empty_line[x] = '\0';

while(y--)
{
ee_putstr(0, y, empty_line);
}

free(empty_line);
#else
/* Use dummy driver */
#endif
}


+ 6
- 0
libee/io.c Zobrazit soubor

@@ -22,6 +22,12 @@

#include "config.h"

#ifdef USE_SLANG
# include <slang.h>
#elif USE_NCURSES
# include <curses.h>
#endif

#include "ee.h"

char ee_get_key(void)


+ 14
- 12
libee/line.c Zobrazit soubor

@@ -22,6 +22,12 @@

#include "config.h"

#ifdef USE_SLANG
# include <slang.h>
#elif USE_NCURSES
# include <curses.h>
#endif

#include <inttypes.h>
#include <stdlib.h>

@@ -196,8 +202,7 @@ static void draw_solid_line(struct line* s)

for(; dx>=0; dx--)
{
ee_goto(x1, y1);
ee_putchar(s->c);
ee_putchar(x1, y1, s->c);
if(delta > 0)
{
x1 += xinc;
@@ -219,8 +224,7 @@ static void draw_solid_line(struct line* s)

for(; dy >= 0; dy--)
{
ee_goto(x1, y1);
ee_putchar(s->c);
ee_putchar(x1, y1, s->c);
if(delta > 0)
{
x1 += xinc;
@@ -290,10 +294,9 @@ static void draw_thin_line(struct line* s)

for(; dx>=0; dx--)
{
ee_goto(x1, y1);
if(delta > 0)
{
ee_putchar(charmapy[1]);
ee_putchar(x1, y1, charmapy[1]);
x1++;
y1 += yinc;
delta += dpru;
@@ -302,9 +305,9 @@ static void draw_thin_line(struct line* s)
else
{
if(prev)
ee_putchar(charmapy[0]);
ee_putchar(x1, y1, charmapy[0]);
else
ee_putchar('-');
ee_putchar(x1, y1, '-');
x1++;
delta += dpr;
prev = 0;
@@ -319,18 +322,17 @@ static void draw_thin_line(struct line* s)

for(; dy >= 0; dy--)
{
ee_goto(x1, y1);
if(delta > 0)
{
ee_putchar(charmapx[0]);
ee_putchar(charmapx[1]);
ee_putchar(x1, y1, charmapx[0]);
ee_putchar(x1 + 1, y1, charmapx[1]);
x1++;
y1 += yinc;
delta += dpru;
}
else
{
ee_putchar('|');
ee_putchar(x1, y1, '|');
y1 += yinc;
delta += dpr;
}


+ 6
- 0
libee/math.c Zobrazit soubor

@@ -22,6 +22,12 @@

#include "config.h"

#ifdef USE_SLANG
# include <slang.h>
#elif USE_NCURSES
# include <curses.h>
#endif

#include <stdlib.h>

#include "ee.h"


+ 8
- 2
libee/sprite.c Zobrazit soubor

@@ -22,6 +22,12 @@

#include "config.h"

#ifdef USE_SLANG
# include <slang.h>
#elif USE_NCURSES
# include <curses.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -166,9 +172,9 @@ void ee_draw_sprite(int x, int y, struct ee_sprite *sprite)
int col = frame->color[frame->w * j + i];
if(col >= 0)
{
ee_goto(x + i - frame->dx, y + j - frame->dy);
ee_color(col);
ee_putchar(frame->chars[frame->w * j + i]);
ee_putchar(x + i - frame->dx, y + j - frame->dy,
frame->chars[frame->w * j + i]);
}
}
}


+ 7
- 4
libee/triangle.c Zobrazit soubor

@@ -22,6 +22,12 @@

#include "config.h"

#ifdef USE_SLANG
# include <slang.h>
#elif USE_NCURSES
# include <curses.h>
#endif

#include <stdlib.h>

#include "ee.h"
@@ -81,10 +87,7 @@ void ee_fill_triangle(int x1, int y1, int x2, int y2, int x3, int y3, char c)
if(xb > xmax) xb = xmax;

for(x = xa; x <= xb; x++)
{
ee_goto(x, y);
ee_putchar(c);
}
ee_putchar(x, y, c);
}
}


+ 10
- 10
src/box.c Zobrazit soubor

@@ -85,16 +85,16 @@ void draw_box(game *g, box *b)
ee_color(EE_YELLOW);

/* FIXME: use a font */
ee_goto(b->x - b->w / 2 + 12, b->y - b->h / 2 + 2);
ee_putstr("XXXX. .XXXX X X .XXXX .XXXX XXXX.");
ee_goto(b->x - b->w / 2 + 12, b->y - b->h / 2 + 3);
ee_putstr("X `X X' X X X X' X' X `X");
ee_goto(b->x - b->w / 2 + 12, b->y - b->h / 2 + 4);
ee_putstr("XXXX' XXXXX X X `XXX XXXX X X");
ee_goto(b->x - b->w / 2 + 12, b->y - b->h / 2 + 5);
ee_putstr("X' X' `X X. ,X `X X' X ,X");
ee_goto(b->x - b->w / 2 + 12, b->y - b->h / 2 + 6);
ee_putstr("X X X `XXXX XXXX' `XXXX XXXX'");
ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 2,
"XXXX. .XXXX X X .XXXX .XXXX XXXX.");
ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 3,
"X `X X' X X X X' X' X `X");
ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 4,
"XXXX' XXXXX X X `XXX XXXX X X");
ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 5,
"X' X' `X X. ,X `X X' X ,X");
ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 6,
"X X X `XXXX XXXX' `XXXX XXXX'");
}

void free_box(box *b)


+ 9
- 16
src/overlay.c Zobrazit soubor

@@ -33,8 +33,7 @@ void draw_status(game *g)

/* Draw life jauge */
ee_color(EE_GRAY);
ee_goto(4, 1);
ee_putstr(dots30);
ee_putstr(4, 1, dots30);

if(g->p->life > MAX_LIFE * 7 / 10)
{
@@ -49,19 +48,15 @@ void draw_status(game *g)
ee_color(EE_RED);
}

ee_goto(4, 1);
ee_putstr(dashes30 + (MAX_LIFE - g->p->life) * 30 / MAX_LIFE);
ee_putstr(4, 1, dashes30 + (MAX_LIFE - g->p->life) * 30 / MAX_LIFE);

ee_color(EE_WHITE);
ee_goto(1, 1);
ee_putstr("L |");
ee_goto(34, 1);
ee_putstr("|");
ee_putstr(1, 1, "L |");
ee_putstr(34, 1, "|");

/* Draw weapon jauge */
ee_color(EE_GRAY);
ee_goto(42, 1);
ee_putstr(dots30 + 10);
ee_putstr(42, 1, dots30 + 10);

if(g->p->special > MAX_SPECIAL * 9 / 10)
{
@@ -76,13 +71,11 @@ void draw_status(game *g)
ee_color(EE_BLUE);
}

ee_goto(42, 1);
ee_putstr(dashes30 + 10 + (MAX_SPECIAL - g->p->special) * 20 / MAX_SPECIAL);
ee_putstr(42, 1, dashes30 + 10
+ (MAX_SPECIAL - g->p->special) * 20 / MAX_SPECIAL);

ee_color(EE_WHITE);
ee_goto(39, 1);
ee_putstr("S |");
ee_goto(62, 1);
ee_putstr("|");
ee_putstr(39, 1, "S |");
ee_putstr(62, 1, "|");
}


+ 5
- 10
src/player.c Zobrazit soubor

@@ -55,18 +55,13 @@ void draw_player(game *g, player *p)
return;
}

ee_goto(p->x + 2, p->y - 2);
ee_color(EE_GREEN);
ee_putstr("/\\");
ee_goto(p->x + 1, p->y - 1);
ee_putchar('(');
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("()");
ee_color(EE_GREEN);
ee_putchar(')');
ee_goto(p->x, p->y);
ee_color(EE_GREEN);
ee_putstr("I<__>I");
ee_putstr(p->x + 2, p->y - 1, "()");
}

void update_player(game *g, player *p)


+ 1
- 2
src/starfield.c Zobrazit soubor

@@ -54,8 +54,7 @@ void draw_starfield(game *g, starfield *s)
if(s[i].x >= 0)
{
ee_color(s[i].c);
ee_goto(s[i].x, s[i].y);
ee_putchar(s[i].ch);
ee_putchar(s[i].x, s[i].y, s[i].ch);
}
}
}


+ 6
- 40
src/tunnel.c Zobrazit soubor

@@ -77,83 +77,49 @@ void draw_tunnel(game *g, tunnel *t)
for(i = 0; i < g->h ; i++)
{
if(t->left[i] <= -10)
{
continue;
}

if(i + 1 == g->h || t->left[i] > t->left[i+1])
{
c = (i == 0 || t->left[i] > t->left[i-1]) ? '>' : '/';
}
else
{
c = (i == 0 || t->left[i] > t->left[i-1]) ? '\\' : '<';
}

ee_goto(t->left[i] + 1, i);
ee_putchar(c);
ee_putchar(t->left[i] + 1, i, c);

if(i + 1 < g->h)
{
for(j = 1; j < t->left[i+1] - t->left[i]; j++)
{
ee_goto(t->left[i] + j + 1, i);
ee_putchar('_');
}
}
ee_putchar(t->left[i] + j + 1, i, '_');
}

/* Right border */
for(i = 0; i < g->h ; i++)
{
if(t->right[i] >= g->w + 10)
{
continue;
}

if(i + 1 == g->h || t->right[i] > t->right[i+1])
{
c = (i == 0 || t->right[i] > t->right[i-1]) ? '>' : '/';
}
else
{
c = (i == 0 || t->right[i] > t->right[i-1]) ? '\\' : '<';
}

if(i + 1 < g->h)
{
for(j = 1; j < t->right[i] - t->right[i+1]; j++)
{
ee_goto(t->right[i+1] + j - 1, i);
ee_putchar('_');
}
}
ee_putchar(t->right[i+1] + j - 1, i, '_');

ee_goto(t->right[i] - 1, i);
ee_putchar(c);
ee_putchar(t->right[i] - 1, i, c);
}

ee_color(EE_RED);

/* Left concrete */
for(i = 0; i < g->h ; i++)
{
for(j = 0 ; j <= t->left[i]; j++)
{
ee_goto(j, i);
ee_putchar('#');
}
}
ee_putchar(j, i, '#');

/* Right concrete */
for(i = 0; i < g->h ; i++)
{
for(j = t->right[i] ; j < g->w ; j++)
{
ee_goto(j, i);
ee_putchar('#');
}
}
ee_putchar(j, i, '#');
}

void update_tunnel(game *g, tunnel *t)


+ 56
- 112
src/weapons.c Zobrazit soubor

@@ -57,34 +57,24 @@ void draw_weapons(game *g, weapons *wp)
{
case WEAPON_LASER:
ee_color(EE_WHITE);
ee_goto(wp->x[i] >> 4, wp->y[i] >> 4);
ee_putchar('|');
ee_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '|');
ee_color(EE_CYAN);
ee_goto(wp->x[i] >> 4, (wp->y[i] >> 4) + 1);
ee_putchar('|');
ee_putchar(wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|');
break;
case WEAPON_SEEKER:
ee_color(EE_CYAN);
ee_goto(wp->x3[i] >> 4, wp->y3[i] >> 4);
ee_putchar('.');
ee_goto(wp->x2[i] >> 4, wp->y2[i] >> 4);
ee_putchar('o');
ee_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.');
ee_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, 'o');
ee_color(EE_WHITE);
ee_goto(wp->x[i] >> 4, wp->y[i] >> 4);
ee_putchar('@');
ee_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '@');
break;
case WEAPON_BOMB:
ee_color(EE_GRAY);
ee_goto((wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4);
ee_putchar('.');
ee_goto((wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4);
ee_putchar('.');
ee_goto((wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4);
ee_putchar('.');
ee_goto(wp->x3[i] >> 4, wp->y3[i] >> 4);
ee_putchar('.');
ee_goto(wp->x2[i] >> 4, wp->y2[i] >> 4);
ee_putchar('.');
ee_putchar((wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.');
ee_putchar((wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.');
ee_putchar((wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4, '.');
ee_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.');
ee_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, '.');
draw_bomb(wp->x[i] >> 4, wp->y[i] >> 4, wp->vx[i], wp->vy[i]);
break;
case WEAPON_FRAGBOMB:
@@ -367,131 +357,85 @@ static void draw_beam(int x, int y, int frame)
{
case 24:
ee_color(EE_WHITE);
ee_goto(x, y-3);
ee_putstr("__");
ee_goto(x-1, y-2);
ee_putchar('\'');
ee_goto(x+2, y-2);
ee_putchar('`');
ee_putstr(x, y-3, "__");
ee_putchar(x-1, y-2, '\'');
ee_putchar(x+2, y-2, '`');
break;
case 23:
ee_color(EE_CYAN);
ee_goto(x, y-3);
ee_putstr("__");
ee_putstr(x, y-3, "__");
ee_color(EE_WHITE);
ee_goto(x-2, y-2);
ee_putstr("-'");
ee_goto(x+2, y-2);
ee_putstr("`-");
ee_putstr(x-2, y-2, "-'");
ee_putstr(x+2, y-2, "`-");
break;
case 22:
ee_color(EE_CYAN);
ee_goto(x, y-3);
ee_putstr("__");
ee_goto(x-1, y-2);
ee_putchar('\'');
ee_goto(x+2, y-2);
ee_putchar('`');
ee_putstr(x, y-3, "__");
ee_putchar(x-1, y-2, '\'');
ee_putchar(x+2, y-2, '`');
ee_color(EE_WHITE);
ee_goto(x-3, y-2);
ee_putstr(",-");
ee_goto(x+3, y-2);
ee_putstr("-.");
ee_putstr(x-3, y-2, ",-");
ee_putstr(x+3, y-2, "-.");
break;
case 21:
ee_color(EE_CYAN);
ee_goto(x-1, y-3);
ee_putstr("____");
ee_goto(x-2, y-2);
ee_putchar('\'');
ee_goto(x+3, y-2);
ee_putchar('`');
ee_putstr(x-1, y-3, "____");
ee_putchar(x-2, y-2, '\'');
ee_putchar(x+3, y-2, '`');
ee_color(EE_WHITE);
ee_goto(x-4, y-2);
ee_putstr(",-");
ee_goto(x+4, y-2);
ee_putstr("-.");
ee_putstr(x-4, y-2, ",-");
ee_putstr(x+4, y-2, "-.");
break;
case 20:
ee_color(EE_WHITE);
ee_goto(x, y-3);
ee_putstr("%%");
ee_goto(x-4, y-2);
ee_putchar(',');
ee_goto(x+5, y-2);
ee_putchar('.');
ee_putstr(x, y-3, "%%");
ee_putchar(x-4, y-2, ',');
ee_putchar(x+5, y-2, '.');
ee_color(EE_CYAN);
ee_goto(x-1, y-3);
ee_putchar(':');
ee_goto(x+2, y-3);
ee_putchar(':');
ee_goto(x-3, y-2);
ee_putstr("-'");
ee_goto(x+3, y-2);
ee_putstr("`-");
ee_putchar(x-1, y-3, ':');
ee_putchar(x+2, y-3, ':');
ee_putstr(x-3, y-2, "-'");
ee_putstr(x+3, y-2, "`-");
break;
case 19:
ee_color(EE_WHITE);
ee_goto(x, y-4);
ee_putstr("%%");
ee_goto(x, y-3);
ee_putstr("##");
ee_putstr(x, y-4, "%%");
ee_putstr(x, y-3, "##");
ee_color(EE_CYAN);
ee_goto(x-1, y-4);
ee_putchar(':');
ee_goto(x+2, y-4);
ee_putchar(':');
ee_goto(x-1, y-3);
ee_putchar('%');
ee_goto(x+2, y-3);
ee_putchar('%');
ee_goto(x-4, y-2);
ee_putstr(",-'");
ee_goto(x+3, y-2);
ee_putstr("`-.");
ee_putchar(x-1, y-4, ':');
ee_putchar(x+2, y-4, ':');
ee_putchar(x-1, y-3, '%');
ee_putchar(x+2, y-3, '%');
ee_putstr(x-4, y-2, ",-'");
ee_putstr(x+3, y-2, "`-.");
ee_color(EE_BLUE);
ee_goto(x-2, y-3);
ee_putchar(':');
ee_goto(x+3, y-3);
ee_putchar(':');
ee_putchar(x-2, y-3, ':');
ee_putchar(x+3, y-3, ':');
break;
case 18:
default:
r = (18 - frame) * (18 - frame);
ee_color(EE_WHITE);
ee_goto(x-1, y-5-r);
ee_putstr(":%%:");
ee_goto(x-1, y-4-r);
ee_putstr("%##%");
ee_putstr(x-1, y-5-r, ":%%:");
ee_putstr(x-1, y-4-r, "%##%");
ee_color(EE_CYAN);
ee_goto(x-2, y-4-r);
ee_putchar(':');
ee_goto(x+3, y-4-r);
ee_putchar(':');
ee_goto(x-2, y-2);
ee_putchar('\'');
ee_goto(x+3, y-2);
ee_putchar('`');
ee_putchar(x-2, y-4-r, ':');
ee_putchar(x+3, y-4-r, ':');
ee_putchar(x-2, y-2, '\'');
ee_putchar(x+3, y-2, '`');
ee_color(EE_BLUE);
ee_goto(x-3, y-2);
ee_putchar(':');
ee_goto(x+4, y-2);
ee_putchar(':');
ee_putchar(x-3, y-2, ':');
ee_putchar(x+4, y-2, ':');
for(i = 0; i <= r; i++)
{
ee_color(EE_WHITE);
ee_goto(x-1, y-3-i);
ee_putstr((i+frame) % 5 ? "####" : "%%%%");
ee_putstr(x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%");
ee_color(EE_CYAN);
ee_goto(x-2, y-3-i);
ee_putchar('%');
ee_goto(x+3, y-3-i);
ee_putchar('%');
ee_putchar(x-2, y-3-i, '%');
ee_putchar(x+3, y-3-i, '%');
ee_color(EE_BLUE);
ee_goto(x-3, y-3-i);
ee_putchar(':');
ee_goto(x+4, y-3-i);
ee_putchar(':');
ee_putchar(x-3, y-3-i, ':');
ee_putchar(x+4, y-3-i, ':');
}
break;
}


+ 20
- 33
test/demo.c Zobrazit soubor

@@ -138,32 +138,20 @@ static void display_menu(void)
ee_draw_line(xo, 1, xo, yo, ':');
ee_draw_line(1, 1, xo, 1, '.');

ee_goto((xo - strlen("libee demo")) / 2, 3);
ee_putstr("libee demo");
ee_goto((xo - strlen("============")) / 2, 4);
ee_putstr("============");

ee_goto(4, 6);
ee_putstr("0: complete demo");
ee_goto(4, 7);
ee_putstr("1: dots demo");
ee_goto(4, 8);
ee_putstr("2: lines demo");
ee_goto(4, 9);
ee_putstr("3: thin lines demo");
ee_goto(4, 10);
ee_putstr("4: circles demo");
ee_goto(4, 11);
ee_putstr("5: ellipses demo");
ee_goto(4, 12);
ee_putstr("6: triangles demo");
ee_goto(4, 13);
ee_putstr("7: outlined triangles demo");
ee_goto(4, 14);
ee_putstr("8: sprites demo");

ee_goto(4, yo - 2);
ee_putstr("q: quit");
ee_putstr((xo - strlen("libee demo")) / 2, 3, "libee demo");
ee_putstr((xo - strlen("============")) / 2, 4, "============");

ee_putstr(4, 6, "0: complete demo");
ee_putstr(4, 7, "1: dots demo");
ee_putstr(4, 8, "2: lines demo");
ee_putstr(4, 9, "3: thin lines demo");
ee_putstr(4, 10, "4: circles demo");
ee_putstr(4, 11, "5: ellipses demo");
ee_putstr(4, 12, "6: triangles demo");
ee_putstr(4, 13, "7: outlined triangles demo");
ee_putstr(4, 14, "8: sprites demo");

ee_putstr(4, yo - 2, "q: quit");

ee_refresh();
}
@@ -265,11 +253,11 @@ static void demo_all(void)
{
int delta = ee_rand(-5, 5);
ee_color(ee_rand(1, 10));
ee_goto(ee_get_width() / 2
+ cos(0.02*j) * (delta + ee_get_width() / 4),
ee_get_height() / 2
+ sin(0.02*j) * (delta + ee_get_height() / 3));
ee_putchar('#');
ee_putchar(ee_get_width() / 2
+ cos(0.02*j) * (delta + ee_get_width() / 4),
ee_get_height() / 2
+ sin(0.02*j) * (delta + ee_get_height() / 3),
'#');
}

/* Draw foreground sprite */
@@ -290,8 +278,7 @@ static void demo_dots(void)
{
/* Putpixel */
ee_color(ee_rand(1, 10));
ee_goto(ee_rand(0, xmax), ee_rand(0, ymax));
ee_putchar('#');
ee_putchar(ee_rand(0, xmax), ee_rand(0, ymax), '#');
}
ee_refresh();
}


Načítá se…
Zrušit
Uložit