You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.8 KiB
Java
73 lines
1.8 KiB
Java
package Main;
|
|
|
|
import org.newdawn.slick.Animation;
|
|
import org.newdawn.slick.GameContainer;
|
|
import org.newdawn.slick.Graphics;
|
|
import org.newdawn.slick.SlickException;
|
|
import org.newdawn.slick.SpriteSheet;
|
|
|
|
public class Ball {
|
|
|
|
SpriteSheet virus_sheet;
|
|
Animation virus;
|
|
|
|
int xPos,yPos;
|
|
float xSpd,ySpd;
|
|
boolean isColliding = false,ballIsKilled = true;
|
|
//initial methode mit Koordinatenbestimmung und startrichtung
|
|
void init (GameContainer gc,int xPos, int yPos, int invaderSpd) throws SlickException{
|
|
|
|
this.xPos = xPos;
|
|
this.yPos = yPos;
|
|
|
|
this.xSpd = 1.0f * invaderSpd;//initiierung mit Hacker flugrichtungsindikation
|
|
this.ySpd = 1.0f;
|
|
|
|
virus_sheet = new SpriteSheet ("Main/Virus_sheet.png", 72, 72);
|
|
virus = new Animation(virus_sheet,2,1,3,4,true,200,true);
|
|
|
|
|
|
}
|
|
|
|
|
|
void render(GameContainer gc, Graphics g) throws SlickException{
|
|
|
|
virus.draw(xPos-36, yPos-36);
|
|
|
|
}
|
|
|
|
|
|
void update(GameContainer gc, float _delta)throws SlickException{
|
|
|
|
this.xPos += xSpd;
|
|
this.yPos += ySpd;
|
|
|
|
}
|
|
|
|
public void collisionManager(String direction){//Verwaltet Apprallrichtung und intensität
|
|
|
|
|
|
switch(direction){
|
|
|
|
|
|
case "x_inverted" :this.xSpd *= -1; break;
|
|
case "y_inverted" :this.ySpd *= -1; break;
|
|
case "rebounce" :this.xSpd *= -1; this.ySpd *= -1;break;
|
|
|
|
case "left" :this.xSpd *= -1; this.ySpd *= -1;break;
|
|
case "midleft" :this.xSpd *= 2; this.ySpd *= -1;break;
|
|
case "middle" :this.ySpd *= -1; break;
|
|
case "midright" :this.xSpd *= 2; this.ySpd *= -1;break;
|
|
case "right" :this.xSpd *= -1; this.ySpd *= -1;break;
|
|
}
|
|
|
|
}
|
|
//ball "zerstörung"
|
|
public void killBall(GameContainer gc) throws SlickException{
|
|
init(gc, -50,350, 1);
|
|
ballIsKilled=true;
|
|
}
|
|
|
|
|
|
}
|