



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Asteroid(boolean
isLarge,
float
initialX,
float
initialY,
long
previousDrawTime)
{
//
set
the
initial
x
and
y
pos
xPos
=
initialX;
yPos
=
initialY;
//
get
a
random
orientation
for
this
asteroid
rotation
=
random(0,
TWO_PI);
//
get
the
asteroid's
velocity
in
x
and
y
directions
//
based
on
its
orientation
and
size
(bigger
moves
slower)
if
(isLarge)
{
velocityX
=
sin(rotation)*10;
velocityY
=
-cos(rotation)*10;
}
else
{
velocityX
=
sin(rotation)*25;
velocityY
=
-cos(rotation)*25;
} large
=
isLarge;
lastDrawMillis
=
previousDrawTime;
}
Asteroid()
{
this
(true,
random(0,
XSIZE),
random(0,
YSIZE),
0);
} Asteroid(boolean
isLarge,
float
initialX,
float
initialY,
long
previousDrawTime)
{
xPos
=
initialX;
yPos
=^
initialY;
rotation
=
random(0,
TWO_PI);
if
(isLarge)
{
velocityX
=
sin(rotation)*10;
velocityY
=
-cos(rotation)*10;
}
else
{
velocityX
=
sin(rotation)*25;
velocityY
=
-cos(rotation)*25;
} large
=
isLarge;
lastDrawMillis
=
previousDrawTime;
}