Changeset 136 for ttyvaders


Ignore:
Timestamp:
Nov 10, 2003, 7:29:04 PM (16 years ago)
Author:
Sam Hocevar
Message:
  • libee/sprite.c: + Added sanity checks in ee_sprite_* functions.
  • libee/conic.c: + Use ellipsepoints() in ee_draw_circle().
Location:
ttyvaders/trunk/libee
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ttyvaders/trunk/libee/conic.c

    r132 r136  
    2727#include "ee.h"
    2828
     29static void ellipsepoints(int, int, int, int, char);
     30
    2931void ee_draw_circle(int x, int y, int r, char c)
    3032{
     
    3436    for(test = 0, dx = 0, dy = r ; dx <= dy ; dx++)
    3537    {
    36         ee_putcharTO(x + dx, y + dy / 2, c);
    37         ee_putcharTO(x - dx, y + dy / 2, c);
    38         ee_putcharTO(x + dx, y - dy / 2, c);
    39         ee_putcharTO(x - dx, y - dy / 2, c);
    40 
    41         ee_putcharTO(x + dy, y + dx / 2, c);
    42         ee_putcharTO(x - dy, y + dx / 2, c);
    43         ee_putcharTO(x + dy, y - dx / 2, c);
    44         ee_putcharTO(x - dy, y - dx / 2, c);
     38        ellipsepoints(x, y, dx, dy, c);
     39        ellipsepoints(x, y, dy, dx, c);
    4540
    4641        test += test > 0 ? dx - dy-- : dx;
    4742    }
    48 }
    49 
    50 static void ellipsepoints(int xo, int yo, int x, int y, char c)
    51 {
    52     ee_putcharTO(xo + x, yo + y, c);
    53     ee_putcharTO(xo - x, yo + y, c);
    54     ee_putcharTO(xo + x, yo - y, c);
    55     ee_putcharTO(xo - x, yo - y, c);
    5643}
    5744
     
    9885}
    9986
     87static void ellipsepoints(int xo, int yo, int x, int y, char c)
     88{
     89    ee_putcharTO(xo + x, yo + y, c);
     90    ee_putcharTO(xo - x, yo + y, c);
     91    ee_putcharTO(xo + x, yo - y, c);
     92    ee_putcharTO(xo - x, yo - y, c);
     93}
     94
  • ttyvaders/trunk/libee/sprite.c

    r122 r136  
    131131void ee_set_sprite_frame(struct ee_sprite *sprite, int f)
    132132{
     133    if(sprite == NULL)
     134        return;
     135
    133136    if(f < 0 || f >= sprite->nf)
    134137        return;
     
    139142int ee_get_sprite_frame(struct ee_sprite *sprite)
    140143{
     144    if(sprite == NULL)
     145        return -1;
     146
    141147    return sprite->f;
    142148}
     
    145151{
    146152    int i, j;
    147     struct ee_frame *frame = &sprite->frames[sprite->f];
     153    struct ee_frame *frame;
     154
     155    if(sprite == NULL)
     156        return;
     157
     158    frame = &sprite->frames[sprite->f];
    148159
    149160    for(j = 0; j < frame->h; j++)
     
    166177    int i;
    167178
     179    if(sprite == NULL)
     180        return;
     181
    168182    for(i = sprite->nf; i--;)
    169183    {
Note: See TracChangeset for help on using the changeset viewer.