- Lebensanzeige
- walk Animation fertig
This commit is contained in:
+183
-7
@@ -15,30 +15,53 @@ public class Player2 extends Actor
|
||||
|
||||
public int leben;
|
||||
long c;
|
||||
boolean schautNachRechts;
|
||||
long attackTimer = 0;
|
||||
int attackPhase = 0;
|
||||
boolean attacking = false;
|
||||
int laufPhase = 0;
|
||||
long laufTimer = 0;
|
||||
boolean laeuft = false;
|
||||
int charakter;
|
||||
|
||||
Player2(){
|
||||
Player2(int pCharakter){
|
||||
charakter = pCharakter;
|
||||
leben = 100;
|
||||
schautNachRechts = false;
|
||||
charakter();
|
||||
}
|
||||
public void act()
|
||||
{
|
||||
bewegung();
|
||||
gravitation();
|
||||
springen();
|
||||
animation1();
|
||||
anitmationLaufen();
|
||||
}
|
||||
|
||||
public void bewegung(){
|
||||
if(Greenfoot.isKeyDown("right")){
|
||||
setRotation(0);
|
||||
move(3);
|
||||
move(5);
|
||||
if(!schautNachRechts && attackPhase == 0){
|
||||
getImage().mirrorHorizontally();
|
||||
schautNachRechts = true;
|
||||
}
|
||||
laeuft = true;
|
||||
}
|
||||
if(Greenfoot.isKeyDown("left")){
|
||||
setRotation(0);
|
||||
move(-3);
|
||||
move(-5);
|
||||
if(schautNachRechts && attackPhase == 0){
|
||||
getImage().mirrorHorizontally();
|
||||
schautNachRechts = false;
|
||||
}
|
||||
laeuft = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void springen(){
|
||||
if(Greenfoot.isKeyDown("-") && this.getY() > 370 ){
|
||||
if(Greenfoot.isKeyDown("up") && this.getY() > 289 ){
|
||||
for(int i = 12; i > -12; i--){
|
||||
setRotation(270);
|
||||
move(i);
|
||||
@@ -50,9 +73,31 @@ public class Player2 extends Actor
|
||||
}
|
||||
|
||||
public boolean attacke(){
|
||||
if(Greenfoot.isKeyDown("e")){
|
||||
if(Greenfoot.isKeyDown(".")){
|
||||
if(System.currentTimeMillis() >= c){
|
||||
c = System.currentTimeMillis() + 2000;
|
||||
|
||||
if (!attacking) {
|
||||
attacking = true;
|
||||
attackPhase = 1;
|
||||
attackTimer = System.currentTimeMillis();
|
||||
|
||||
if(schautNachRechts){
|
||||
setImage("1Combo2.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
}
|
||||
else{
|
||||
setImage("1Combo2.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
getImage().mirrorHorizontally();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
c = System.currentTimeMillis() + 500;
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
@@ -64,12 +109,143 @@ public class Player2 extends Actor
|
||||
}
|
||||
}
|
||||
|
||||
public void animation1(){
|
||||
if (attacking && attackPhase == 1 && System.currentTimeMillis() - attackTimer >= 200) {
|
||||
if(schautNachRechts){
|
||||
attackPhase = 2;
|
||||
setImage("2Combo1.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
}
|
||||
else{
|
||||
attackPhase = 2;
|
||||
setImage("2Combo1.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
getImage().mirrorHorizontally();
|
||||
}
|
||||
}
|
||||
if (attacking && attackPhase == 2 && System.currentTimeMillis() - attackTimer >= 300) {
|
||||
attacking = false;
|
||||
attackPhase = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void anitmationLaufen(){
|
||||
if(laeuft){
|
||||
if(schautNachRechts){
|
||||
if(laufPhase == 0){
|
||||
setImage("RenRun1.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
laufPhase = 1;
|
||||
laufTimer = System.currentTimeMillis();
|
||||
}
|
||||
if(laufPhase == 1 && System.currentTimeMillis() - laufTimer >= 100){
|
||||
setImage("RenRun2.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
laufPhase = 2;
|
||||
laufTimer = System.currentTimeMillis();
|
||||
}
|
||||
if(laufPhase == 2 && System.currentTimeMillis() - laufTimer >= 100){
|
||||
setImage("RenRun3.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
laufPhase = 3;
|
||||
laufTimer = System.currentTimeMillis();
|
||||
}
|
||||
if(laufPhase == 3 && System.currentTimeMillis() - laufTimer >= 100){
|
||||
setImage("RenRun4.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
laufPhase = 4;
|
||||
laufTimer = System.currentTimeMillis();
|
||||
}
|
||||
if(laufPhase == 4 && System.currentTimeMillis() - laufTimer >= 100){
|
||||
setImage("2Combo1.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
laufPhase = 0;
|
||||
laufTimer = System.currentTimeMillis();
|
||||
laeuft = false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(laufPhase == 0){
|
||||
setImage("RenRun1.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
getImage().mirrorHorizontally();
|
||||
laufPhase = 1;
|
||||
laufTimer = System.currentTimeMillis();
|
||||
}
|
||||
if(laufPhase == 1 && System.currentTimeMillis() - laufTimer >= 100){
|
||||
setImage("RenRun2.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
getImage().mirrorHorizontally();
|
||||
laufPhase = 2;
|
||||
laufTimer = System.currentTimeMillis();
|
||||
}
|
||||
if(laufPhase == 2 && System.currentTimeMillis() - laufTimer >= 100){
|
||||
setImage("RenRun3.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
getImage().mirrorHorizontally();
|
||||
laufPhase = 3;
|
||||
laufTimer = System.currentTimeMillis();
|
||||
}
|
||||
if(laufPhase == 3 && System.currentTimeMillis() - laufTimer >= 100){
|
||||
setImage("RenRun4.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
getImage().mirrorHorizontally();
|
||||
laufPhase = 4;
|
||||
laufTimer = System.currentTimeMillis();
|
||||
}
|
||||
if(laufPhase == 4 && System.currentTimeMillis() - laufTimer >= 100){
|
||||
setImage("2Combo1.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
getImage().mirrorHorizontally();
|
||||
laufPhase = 0;
|
||||
laufTimer = System.currentTimeMillis();
|
||||
laeuft = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void gravitation(){
|
||||
if(this.getY() < 370){
|
||||
if(this.getY() < 290){
|
||||
setRotation(90);
|
||||
move(4);
|
||||
setRotation(0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void charakter(){
|
||||
if(charakter == 1){
|
||||
setImage("2Combo1.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(160,160);
|
||||
setImage(image);
|
||||
getImage().mirrorHorizontally();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user