Hey guys need a little help
I've created a console app that when run it creates a ball that bounces from wall to wall like a screen saver.
Each time it run it randomly generates a different coloured and different sized ball but i now want to add more than one ball to the screen. (8 balls)
How can i do this?
I've placed my current code bellow
Any help will be greatly appreciated
Kind Regards
Darkowl
-------------------------------------------------------------------------
Code:
#include <graphics.h>
#include <iostream>
#include <time.h>
#include <stdlib.h>
using namespace std;
int random(int min, int max){
return (rand()%max + min);
}
int cX,cY, ySpeed, xSpeed, radius, colour;
void display() {fillellipse(cX, cY, radius, radius);
}
void move() {
cX += xSpeed; cY += ySpeed;
if (cX > 400 || cX < 0) { xSpeed *= -1; cX += xSpeed; }
if (cY > 300 || cY < 0) { ySpeed *= -1; cY += ySpeed; }
}
int main( ) {
cout<< "Max int: " << RAND_MAX;
srand(time(0));
for (int k = 0; k < 2; k++){
cout << random(0, 21)<< endl;
}
initwindow(400, 300, "First Sample");
radius = xSpeed = ySpeed = random(10,25); cX = 200; cY = 150;
colour = random(1,10); setfillstyle(1, colour);
display();
while (!kbhit( )) {
delay(75);
cleardevice();
move();
display();
}
return 0;
}