File: laser.c

package info (click to toggle)
rockdodger 0.9.2-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,220 kB
  • ctags: 756
  • sloc: ansic: 5,374; makefile: 159; sh: 21
file content (20 lines) | stat: -rw-r--r-- 561 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "laser.h"
#include "config.h"
#include "random_gen.h"

void draw_random_dots(SDL_Surface *surf, int ypos, int x_min, int x_max) {
  RD_VIDEO_TYPE c, *rawpixel;
  int i;
  int x, y;

  SDL_LockSurface(surf);
  rawpixel = (RD_VIDEO_TYPE *) surf->pixels;
  c = SDL_MapRGB(surf->format, rnd() * 128, 128 + rnd() * 120, rnd() * 128);

  for(i = 0; i < (x_max - x_min) * 5; i += 10) {
    x = rnd() * (x_max - x_min) + x_min;
    y = ypos + (rnd() - 0.5) * 1.5;
    rawpixel[surf->pitch / sizeof(RD_VIDEO_TYPE) * y + x] = c;
  }
  SDL_UnlockSurface(surf);
}