//
// CHAPTER 26
// Class Source Name [MoverCuttle.java]
// Package name [userClass.App]
// 1996.3
// Author [ Junzo hagimoto ]
package userClass.App;
import java.applet.*;
import java.awt.*;
import userClass.App.*;
public class MoverCuttle extends Mover {
int vector_y=0;
int inc_y=0;
//
// Moverの表示。
//
public void drawImage(Graphics g){
if( hitTimer ==0 ){
g.drawImage(owner.img[imgCount++/4 + imgSelect ],x,y,owner.a);
if(imgCount / 4 == 3 ){
imgCount = 0;
}
}else{
g.drawImage(owner.img[(hitTimer/2) % owner.maxImage ],save_x,save_y,owner.a);
}
}
//
// Moverの次の表示座標を計算する。
//
public void calcxy(Dimension d,int speed){
if( x > d.width - getImageWidth(0) ){
x = d.width - getImageWidth(0) -1;
x_Plus = -1 ;
imgSelect = 3;
}
if( x < 0 ){
x = 0;
x_Plus = 1 ;
imgSelect = 0;
}
if( y > d.height - getImageHeight(0) ){
y = d.height - getImageHeight(0)-1 ;
y_Plus = -1;
}
if( y < 0 ){
y =1;
y_Plus = 1;
}
if( imgCount == 0 ){
inc_y = (int)(Math.random() * 30);
if(inc_y % 2 == 0){
vector_y=1;
}else{
vector_y=-1;
}
inc_y = 2 * vector_y;
}
int xadd1 = imgCount/4 - 1;
int xadd2 = (imgCount%3+2) * x_Plus ;
if(x_Plus == 1 ){
x += ( xadd1 * 3 + xadd2 * 2 ) * x_Plus ;
}else{
x += ( xadd1 * 7 + xadd2 * 2 ) * x_Plus - 10 ;
}
y += inc_y;
}
}
//