Karlos wrote:
Strange that you are using degrees as an angular measure for sin and cos. I thought it only worked in radians?
Ohhhhh, that could be my mistake - I was treating the result as degrees :roll: However, this seems to work better anyway:
Pinwheel::Pinwheel()
{
...
xVel=4;
yVel-2;
...
}
Pinwheel::move()
{
if ( x <= 0 )
{
x=1;
xVel = -xVel;
}
if ( y <= 0 )
{
y=1;
yVel = -yVel;
}
if ( x >= LEVEL_WIDTH-PINWHEEL_WIDTH )
{
x=(LEVEL_WIDTH-PINWHEEL_WIDTH)-1;
xVel = -xVel;
}
if ( y >= LEVEL_HEIGHT-PINWHEEL_HEIGHT )
{
y=(LEVEL_HEIGHT-PINWHEEL_HEIGHT)-1;
yVel = -yVel;
}
x+=xVel;
y+=yVel;
}
This works perfectly even with 1000 pinwheels on screen. Only problem is, when I tried changing the values of xVel and yVel to "rand() % 10 + 2" to make them a random number, the pinwheels all moved in the same direction every time. Did I get the rand() syntax wrong?
--
moto