-Dash
-DashAttack -neue Springenmethode -block
This commit is contained in:
+194
-25
@@ -19,6 +19,7 @@ public class Player2 extends Actor
|
||||
long d = 0;
|
||||
long e = 0;
|
||||
boolean schautNachRechts;
|
||||
int schautNachRechts2;
|
||||
long attackTimer = 0;
|
||||
int attackPhase = 0;
|
||||
boolean attacking = false;
|
||||
@@ -35,10 +36,27 @@ public class Player2 extends Actor
|
||||
String walk2;
|
||||
String walk3;
|
||||
String walk4;
|
||||
String dashAnimation;
|
||||
String hitAnimation;
|
||||
String dashAttackAnimation;
|
||||
String blockAnimation;
|
||||
int attack2Duration;
|
||||
int speed;
|
||||
double speedFaktor;
|
||||
double speedFaktor2;
|
||||
long dashTimer;
|
||||
long jumpTimer = 0;
|
||||
int vSpeed = 0;
|
||||
int meereshoehe = 289;
|
||||
int vDashSpeed = 0;
|
||||
int vDashSpeedCharakter;
|
||||
boolean gotHit = false;
|
||||
long hitTimer = 0;
|
||||
long dashAttackTimer = 0;
|
||||
boolean isDash = false;
|
||||
boolean isDashAttack = false;
|
||||
long dashAttackTimer2 = 0;
|
||||
boolean isBlocking = false;
|
||||
|
||||
Player2(int pCharakter){
|
||||
charakter = pCharakter;
|
||||
@@ -52,10 +70,15 @@ public class Player2 extends Actor
|
||||
springen();
|
||||
animation1();
|
||||
animationLaufen();
|
||||
dash();
|
||||
dashAnimation(schautNachRechts2);
|
||||
dashAttackAnimation();
|
||||
gotHit();
|
||||
block();
|
||||
}
|
||||
|
||||
public void bewegung(){
|
||||
if(Greenfoot.isKeyDown("l")){
|
||||
if(Greenfoot.isKeyDown("p") &! isBlocking){
|
||||
setRotation(0);
|
||||
move(speed);
|
||||
if(!schautNachRechts && attackPhase == 0){
|
||||
@@ -66,7 +89,7 @@ public class Player2 extends Actor
|
||||
attacke();
|
||||
attacke2();
|
||||
}
|
||||
if(Greenfoot.isKeyDown("j")){
|
||||
if(Greenfoot.isKeyDown("i") &! isBlocking){
|
||||
setRotation(0);
|
||||
move(-speed);
|
||||
if(schautNachRechts && attackPhase == 0){
|
||||
@@ -78,24 +101,35 @@ public class Player2 extends Actor
|
||||
attacke2();
|
||||
}
|
||||
}
|
||||
|
||||
public void springen(){
|
||||
if(Greenfoot.isKeyDown("i") && this.getY() > 289 ){
|
||||
for(int i = 12; i > -12; i--){
|
||||
setRotation(270);
|
||||
move(i);
|
||||
setRotation(0);
|
||||
Greenfoot.delay(1);
|
||||
bewegung();
|
||||
attacke();
|
||||
attacke2();
|
||||
}
|
||||
}
|
||||
public void springen() {
|
||||
if (Greenfoot.isKeyDown("o") && getY() >= meereshoehe &! isBlocking) {
|
||||
vSpeed = -15;
|
||||
fall();
|
||||
}
|
||||
}
|
||||
|
||||
public void gravitation() {
|
||||
if (getY() < meereshoehe || vSpeed < 0) {
|
||||
fall();
|
||||
} else {
|
||||
vSpeed = 0;
|
||||
setLocation(getX(), meereshoehe);
|
||||
}
|
||||
}
|
||||
|
||||
private void fall() {
|
||||
setLocation(getX(), getY() + vSpeed);
|
||||
vSpeed += 1;
|
||||
}
|
||||
|
||||
|
||||
public boolean attacke(){
|
||||
if(System.currentTimeMillis() >= c){
|
||||
if(Greenfoot.isKeyDown("o")){
|
||||
if(System.currentTimeMillis() >= c &! isBlocking){
|
||||
GreenfootImage img = getImage();
|
||||
setImage(dashAnimation);
|
||||
GreenfootImage img2 = getImage();
|
||||
setImage(img);
|
||||
if(Greenfoot.isKeyDown("j") &! isDash){
|
||||
if (!attacking && !attacking2) {
|
||||
attacking = true;
|
||||
attackPhase = 1;
|
||||
@@ -131,8 +165,8 @@ public class Player2 extends Actor
|
||||
}
|
||||
|
||||
public boolean attacke2(){
|
||||
if(System.currentTimeMillis() >= c){
|
||||
if(Greenfoot.isKeyDown("u")){
|
||||
if(System.currentTimeMillis() >= c &! isBlocking){
|
||||
if(Greenfoot.isKeyDown("n")){
|
||||
if (!attacking2 && !attacking) {
|
||||
attacking2 = true;
|
||||
attackPhase = 1;
|
||||
@@ -167,6 +201,97 @@ public class Player2 extends Actor
|
||||
}
|
||||
}
|
||||
|
||||
public void dash(){
|
||||
if(Greenfoot.isKeyDown("u") && System.currentTimeMillis() >= dashTimer &! isBlocking){
|
||||
if(schautNachRechts){
|
||||
vDashSpeed = vDashSpeedCharakter;
|
||||
schautNachRechts2 = 1;
|
||||
dashAnimation(schautNachRechts2);
|
||||
}
|
||||
else{
|
||||
vDashSpeed = -vDashSpeedCharakter;
|
||||
schautNachRechts2 = 0;
|
||||
dashAnimation(schautNachRechts2);
|
||||
}
|
||||
isDash = true;
|
||||
dashTimer = System.currentTimeMillis() + 1000;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean dashAttack(){
|
||||
if(isDash && Greenfoot.isKeyDown("j") && System.currentTimeMillis() >= dashAttackTimer &! isBlocking){
|
||||
dashAttackTimer = System.currentTimeMillis() + 300;
|
||||
dashAttackTimer2 = System.currentTimeMillis() + 300;
|
||||
isDashAttack = true;
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void dashAttackAnimation(){
|
||||
if(isDashAttack){
|
||||
setImage(dashAttackAnimation);
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(250, 250);
|
||||
setImage(image);
|
||||
if(schautNachRechts2 == 0){
|
||||
getImage().mirrorHorizontally();
|
||||
}
|
||||
if(System.currentTimeMillis() >= dashAttackTimer2){
|
||||
setImage(defaultAnimation);
|
||||
image = getImage();
|
||||
image.scale(250, 250);
|
||||
setImage(image);
|
||||
if(schautNachRechts2 == 0){
|
||||
getImage().mirrorHorizontally();
|
||||
}
|
||||
isDashAttack = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dashAnimation(int pRechts){
|
||||
if(vDashSpeed != 0){
|
||||
if(pRechts == 1){
|
||||
setImage(dashAnimation);
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(250, 250);
|
||||
setImage(image);
|
||||
setLocation(getX() + vDashSpeed, getY());
|
||||
vDashSpeed -= 1;
|
||||
if(vDashSpeed == 0){
|
||||
setImage(defaultAnimation);
|
||||
image = getImage();
|
||||
image.scale(250, 250);
|
||||
setImage(image);
|
||||
}
|
||||
}
|
||||
if(pRechts == 0){
|
||||
setImage(dashAnimation);
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(250, 250);
|
||||
setImage(image);
|
||||
getImage().mirrorHorizontally();
|
||||
setLocation(getX() + vDashSpeed, getY());
|
||||
vDashSpeed += 1;
|
||||
if(vDashSpeed == 0){
|
||||
setImage(defaultAnimation);
|
||||
image = getImage();
|
||||
image.scale(250, 250);
|
||||
setImage(image);
|
||||
getImage().mirrorHorizontally();
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
isDash = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void animation1(){
|
||||
if (attacking && attackPhase == 1 && System.currentTimeMillis() - attackTimer >= (int)(200/speedFaktor)) {
|
||||
if(schautNachRechts){
|
||||
@@ -323,12 +448,39 @@ public class Player2 extends Actor
|
||||
}
|
||||
}
|
||||
|
||||
public void gravitation(){
|
||||
if(this.getY() < 290){
|
||||
setRotation(90);
|
||||
move(4);
|
||||
setRotation(0);
|
||||
|
||||
public void gotHit(){
|
||||
if(System.currentTimeMillis() >= hitTimer && gotHit){
|
||||
setImage(defaultAnimation);
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(250, 250);
|
||||
setImage(image);
|
||||
if(!schautNachRechts){
|
||||
getImage().mirrorHorizontally();
|
||||
}
|
||||
gotHit = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void block(){
|
||||
if(Greenfoot.isKeyDown("k")){
|
||||
isBlocking = true;
|
||||
setImage(blockAnimation);
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(250, 250);
|
||||
setImage(image);
|
||||
if(!schautNachRechts){
|
||||
getImage().mirrorHorizontally();
|
||||
}
|
||||
}
|
||||
if(isBlocking &! Greenfoot.isKeyDown("k")){
|
||||
isBlocking = false;
|
||||
setImage(defaultAnimation);
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(250, 250);
|
||||
setImage(image);
|
||||
if(!schautNachRechts){
|
||||
getImage().mirrorHorizontally();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,12 +494,17 @@ public class Player2 extends Actor
|
||||
walk2 = "RenRun2.png";
|
||||
walk3 = "RenRun3.png";
|
||||
walk4 = "RenRun4.png";
|
||||
dashAnimation = "RenDashForward.png";
|
||||
hitAnimation = "RenHit.png";
|
||||
dashAttackAnimation = "RenDashForwardAttack.png";
|
||||
blockAnimation = "RenBlock.png";
|
||||
attack2Duration = 1;
|
||||
speed = 6;
|
||||
maxLeben = 100;
|
||||
leben = maxLeben;
|
||||
speedFaktor = 1;
|
||||
speedFaktor2 = speedFaktor;
|
||||
vDashSpeedCharakter = 12;
|
||||
}
|
||||
if(charakter == 2){
|
||||
defaultAnimation = "Tetsu1Combo1.png";
|
||||
@@ -358,12 +515,17 @@ public class Player2 extends Actor
|
||||
walk2 = "TetsuRun2.png";
|
||||
walk3 = "TetsuRun3.png";
|
||||
walk4 = "TetsuRun4.png";
|
||||
dashAnimation = "TetsuDashForward.png";
|
||||
hitAnimation = "TetsuHit.png";
|
||||
dashAttackAnimation = "TetsuDashForwardAttack.png";
|
||||
blockAnimation = "TetsuBlock.png";
|
||||
attack2Duration = 2;
|
||||
speed = 4;
|
||||
maxLeben = 130;
|
||||
leben = maxLeben;
|
||||
speedFaktor = 0.5;
|
||||
speedFaktor2 = 0.75;
|
||||
vDashSpeedCharakter = 10;
|
||||
}
|
||||
if(charakter == 3){
|
||||
defaultAnimation = "HinataShoot1.png";
|
||||
@@ -374,12 +536,17 @@ public class Player2 extends Actor
|
||||
walk2 = "HinataRun2.png";
|
||||
walk3 = "HinataRun3.png";
|
||||
walk4 = "HinataRun4.png";
|
||||
dashAnimation = "HinataDashForward.png";
|
||||
hitAnimation = "HinataHit.png";
|
||||
dashAttackAnimation = "HinataDashForwardAttack.png";
|
||||
blockAnimation = "HinataBlock.png";
|
||||
attack2Duration = 1;
|
||||
speed = 8;
|
||||
maxLeben = 80;
|
||||
leben = maxLeben;
|
||||
speedFaktor = 2;
|
||||
speedFaktor2 = 8;
|
||||
vDashSpeedCharakter = 14;
|
||||
}
|
||||
setImage(defaultAnimation);
|
||||
GreenfootImage image = getImage();
|
||||
@@ -387,4 +554,6 @@ public class Player2 extends Actor
|
||||
setImage(image);
|
||||
getImage().mirrorHorizontally();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user