import java.applet.Applet ;
import java.awt.Graphics ;
import java.awt.Color ;
import java.awt.Image ;
import java.awt.Dimension ;
/* <applet code="houbutsu.class" width="800" height="500"></applet> */
final static double grav = 9.81 ; // 重力加速度
final static double x_start = 20.0 ; // スタート位置 x
final static double y_start = 220.0 ; // スタート位置 y
final static double vx_start = 50.0 ; // 初速 x
final static double vy_start = 30.0 ; // 初速 y
final static double delta = 0.12 ; // 時間間隔(調整可能)
final static int hosei = 30 ;
final static int speed = 100 ; // 画面表示のスピード(調整可能)
double x, y, prev1_x, prev1_y, prev2_x, prev2_y, stop_y;
double t;
double dim_y;
public void init( ) {
t = 0.0 ;
th.start ( ) ;
dim = getSize( ) ;
buff = createImage( dim.width , dim.height ) ;
dim_y = ( double ) dim.height ;
}
public void run( ) {
try {
while ( true ) {
/* 描画関係 */
prev2_x = prev1_x;
prev2_y = prev1_y;
prev1_x = x;
prev1_y = y;
/* 以下、運動の記述 */
x = x_start + t * vx_start;
y = dim_y - ( stop_y = y_start + t * vy_start - 0.5 * grav * t * t) - hosei;
t += delta;
/* 停止条件 */
if ( stop_y < 0 )
break ;
repaint( ) ;
}
}
paint( g) ;
}
if ( ct == null ) ct = buff.getGraphics ( ) ;
ct.
setColor ( Color .
white ) ; ct.fillRect ( ( int ) prev2_x, ( int ) prev2_y, 20 , 20 ) ;
ct.fillRect ( ( int ) prev1_x, ( int ) prev1_y, 20 , 20 ) ;
// ct.fillRect(0, 0, dim.width, dim.height);
ct.fillOval ( ( int ) x, ( int ) y, 20 , 20 ) ;
g.drawImage ( buff, 0 , 0 , this ) ;
}
}
/* end */
aW1wb3J0IGphdmEuYXBwbGV0LkFwcGxldDsKaW1wb3J0IGphdmEuYXd0LkdyYXBoaWNzOwppbXBvcnQgamF2YS5hd3QuQ29sb3I7CmltcG9ydCBqYXZhLmF3dC5JbWFnZTsKaW1wb3J0IGphdmEuYXd0LkRpbWVuc2lvbjsKCi8qIDxhcHBsZXQgY29kZT0iaG91YnV0c3UuY2xhc3MiI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