Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
public void run()
{
int counter = 0;
while(true)
{
repaint();
keyInteraction();
maneuver();
if(counter==5)
{
shotInteraction();
counter = 0;
}
else
counter++;
try{Thread.sleep(10);}catch(Exception e){}
}
}
public void maneuver()
{
double x = (mouseX - shipX) / (double) d.width;
double y = (mouseY - shipY) / (double) d.height;
shipRot = Math.toRadians((Math.PI * ((y < 0)? 1 : 2) - Math.atan(x / y)));
shipX += f_LEFT;
shipY += f_UP;
if(shipY<0)
shipY = d.height;
else if(shipY>d.height)
shipY = 0;
if(shipX<0)
shipX = d.width;
else if(shipX>d.width)
shipX = 0;
}
public void keyInteraction()
{
if(left)
f_LEFT -=0.05;
if(right)
f_LEFT +=0.05;
if(up)
f_UP -= 0.05;
if(down)
f_UP += 0.05;
}
// left, right, up und down sind booleans, sie werden aktiviert bei
// Tasten betätigung, und werden deaktiviert, bei Tasten enttätigung.
// f_LEFT und f_UP sind double.