From 76c0b11e970a4f5b73b97cd83a119bff0ea6c1f4 Mon Sep 17 00:00:00 2001 From: Joshua Grams Date: Mon, 5 Mar 2007 15:44:08 +0000 Subject: [PATCH] * main.c: combined dot drawing functions. --- main.c | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/main.c b/main.c index f69b5dc..9e5c36f 100644 --- a/main.c +++ b/main.c @@ -64,6 +64,7 @@ struct dot { float dx, dy; float mass; // in DOT_MASS_UNITs float decay; // rate at which to reduce mass. + int heat; // heat multiplier (color). }; struct dot edot[MAXENGINEDOTS], *dotptr = edot; @@ -166,6 +167,7 @@ new_engine_dots(float time_span) { dotptr->active = 1; dotptr->decay = 3; + dotptr->heat = 6; // dot was created at a random time during the time span time = frnd() * time_span; // this is how long ago @@ -240,6 +242,7 @@ new_bang_dots(struct sprite *s) bdot[bd2].y = y + s->y; bdot[bd2].mass = frnd() * 99; bdot[bd2].decay = frnd()*1.5 + 0.5; + bdot[bd2].heat = 3; bdot[bd2].active = 1; bd2 = (bd2+1) % MAXBANGDOTS; @@ -288,43 +291,27 @@ move_dots(float ticks) void -draw_bang_dots(SDL_Surface *s) +draw_dot(SDL_Surface *s, struct dot *d) { - int i; uint16_t *pixels, *pixel; - int row_inc = s->pitch/sizeof(uint16_t); - - pixels = (uint16_t *) s->pixels; + int row_inc; - for(i=0; iactive) { + pixels = (uint16_t *) s->pixels; + row_inc = s->pitch / sizeof(uint16_t); + pixel = pixels + (int)d->y * row_inc + (int)d->x; + *pixel = heatcolor[min(3*W-1, (int)(d->mass * d->heat))]; } } void -draw_engine_dots(SDL_Surface *s) -{ +draw_dots(SDL_Surface *s) { int i; - uint16_t *pixels, *pixel; - int row_inc = s->pitch/sizeof(uint16_t); - pixels = (uint16_t *) s->pixels; - - for(i = 0; i