Hello, I am a begginer in coding and I want to make a parabolic simulation. I made the ball work. But the ask command keeps repeating once i type the answer. And I don't know how to get back an answer from the greenfoot.ask. Is it the return command and do I have to make another variable for the angle? And do I insert that into my public void act? Please help, its an easy project so it wont take long.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class ball extends Actor
{
private double posx,posy,vx,vy,ax,ay,dt=0.1;
public void addedToWorld(World myworld)
{
posx=getX();
posy=getY();
ax=0;
ay=10;
vx=20;
vy=-20;
}
public void act()
{
String input = Greenfoot.ask("What do you want the angle to be?");
posx+=vx*dt+0.5*ax*dt*dt;
posy+=vy*dt+0.5*ay*dt*dt;
vx+=ax*dt;
vy+=ay*dt;
setLocation((int)posx,(int)posy);
}
}
