-void init_space_dots() {
- int i,intensity;
- for(i = 0; i<MAXSPACEDOTS; i++) {
- float r;
-
- sdot[i].x = rnd()*(XSIZE-5);
- sdot[i].y = rnd()*(YSIZE-5);
-
- r = rnd()*rnd();
-
- sdot[i].dx = -r*4;
- // -1/((1-r) + .3);
- intensity = (int)(r*180 + 70);
- sdot[i].color = SDL_MapRGB(surf_screen->format,intensity,intensity,intensity);
-
- }
-}
-
-int drawlaser() {
- int i,xc,hitrock;
- Uint16 c, *rawpixel;
-
- hitrock = -1;
- xc = XSIZE;
- // let xc = x coordinate of the collision between the laser and a space rock
- // 1. Calculate xc and determine the asteroid that was hit
- for(i = 0; i<MAXROCKS; i++) {
- if(rock[i].active) {
- if(yship + 12>rock[i].y && yship + 12<rock[i].y + rock[i].image->h && xship + 32<rock[i].x + (rock[i].image->w/2) && rock[i].x + (rock[i].image->w/2) < xc) {
- xc = rock[i].x + (rock[i].image->w/2);
- hitrock = i;
- }
- }
- }
-
- if(hitrock >= 0) {
- rock[hitrock].heat += movementrate*3;
- }
-
- // Plot a number of random dots between xship and XSIZE
- SDL_LockSurface(surf_screen);
- rawpixel = (Uint16 *) surf_screen->pixels;
- c = SDL_MapRGB(surf_ship->format,rnd()*128,128 + rnd()*120,rnd()*128);
-
- for(i = 0; i<(xc-xship)*5; i += 10) {
- int x,y;
- x = rnd()*(xc-(xship + 32)) + xship + 32;
- y = yship + 12 + (rnd()-0.5)*1.5;
- rawpixel[surf_screen->pitch/2*y + x] = c;
- }
-
- SDL_UnlockSurface(surf_screen);
-}
-
-
-int makebangdots(int xbang, int ybang, int xvel, int yvel, SDL_Surface *s, int power) {
-
- // TODO - stop generating dots after a certain amount of time has passed, to cope with slower CPUs.
- // TODO - generate and display dots in a circular buffer
-
- int i,x,y,n,endcount;
- Uint16 *rawpixel,c;
- double theta,r,dx,dy;
- int begin_generate;
-
- begin_generate = SDL_GetTicks();
-
- SDL_LockSurface(s);
- rawpixel = (Uint16 *) s->pixels;
-
- //for(n = 0; n <= power/2; n++) {
-
- endcount = 0;
- while (endcount<3) {
-
- for(x = 0; x<s->w; x++) {
- for(y = 0; y<s->h; y++) {
- c = rawpixel[s->pitch/2*y + x];
- if(c && c != SDL_MapRGB(s->format,0,255,0)) {
-
- theta = rnd()*M_PI*2;
-
- r = 1-(rnd()*rnd());
-
- bdot[bd2].dx = (power/50.0)*45.0*cos(theta)*r + xvel;
- bdot[bd2].dy = (power/50.0)*45.0*sin(theta)*r + yvel;
- bdot[bd2].x = x + xbang;
- bdot[bd2].y = y + ybang;
-
- // Replace the last few bang dots with the pixels from the exploding object
- bdot[bd2].c = (endcount>0)?c:0;
- bdot[bd2].life = 100;
- bdot[bd2].decay = rnd()*3 + 1;
- bdot[bd2].active = 1;
-
- bd2++;
- bd2 %= MAXBANGDOTS;
-
- // If the circular buffer is filled, who cares? They've had their chance.
- //if(bd2 == bd1-1) goto exitloop;