So far I've gotten my program to display a bunch of pixels in varying colors that appear randomly on a screen. I was wondering if it is possible to have the pixels move downward, kind of like you're moving forward in space in a spaceship. This is my program so far, it's very simplistic but does what I need it to.
Code:
#include <conio.h>
#include <graphics.h>
#include <dos.h>
#include <stdlib.h>
int main() {
int gd = DETECT, gm;
int i, x, y;
initgraph(&gd, &gm, "C:\\TC\\BGI");
initwindow(1200, 768);
/* color 500 random pixels on screen */
for(i=0; i<=125; i++) {
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,1);
}
for(i=0; i<=125; i++) {
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,2);
}
for(i=0; i<=125; i++) {
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,3);
}
for(i=0; i<=125; i++) {
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,4);
}
for(i=0; i<=125; i++) {
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,5);
}
for(i=0; i<=125; i++) {
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,6);
}
for(i=0; i<=125; i++) {
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,7);
}
for(i=0; i<=125; i++) {
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,8);
}
for(i=0; i<=125; i++) {
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,9);
}
for(i=0; i<=125; i++) {
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,9);
}
for(i=0; i<=125; i++) {
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,10);
}
for(i=0; i<=125; i++) {
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,11);
}
for(i=0; i<=125; i++) {
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,12);
}
for(i=0; i<=125; i++) {
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,13);
}
for(i=0; i<=100; i++) {
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,14);
}
for(i=0; i<=900; i++) {
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,15);
}
getch();
closegraph();
return 0;
}
Any help would be greatly appreciated.