- Lebensanzeige
- walk Animation fertig
This commit is contained in:
Binary file not shown.
@@ -1,8 +1,8 @@
|
||||
#BlueJ class context
|
||||
comment0.target=Player1
|
||||
comment0.text=\r\n\ Write\ a\ description\ of\ class\ player\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
|
||||
comment1.params=
|
||||
comment1.target=Player1()
|
||||
comment1.params=pCharakter
|
||||
comment1.target=Player1(int)
|
||||
comment2.params=
|
||||
comment2.target=void\ act()
|
||||
comment3.params=
|
||||
|
||||
+107
-31
@@ -22,8 +22,10 @@ public class Player1 extends Actor
|
||||
int laufPhase = 0;
|
||||
long laufTimer = 0;
|
||||
boolean laeuft = false;
|
||||
int charakter;
|
||||
|
||||
Player1(){
|
||||
Player1(int pCharakter){
|
||||
charakter = pCharakter;
|
||||
leben = 100;
|
||||
schautNachRechts = true;
|
||||
charakter();
|
||||
@@ -54,11 +56,12 @@ public class Player1 extends Actor
|
||||
getImage().mirrorHorizontally();
|
||||
schautNachRechts = false;
|
||||
}
|
||||
laeuft = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void springen(){
|
||||
if(Greenfoot.isKeyDown("space") && this.getY() > 363 ){
|
||||
if(Greenfoot.isKeyDown("space") && this.getY() > 289 ){
|
||||
for(int i = 12; i > -12; i--){
|
||||
setRotation(270);
|
||||
move(i);
|
||||
@@ -77,15 +80,25 @@ public class Player1 extends Actor
|
||||
attacking = true;
|
||||
attackPhase = 1;
|
||||
attackTimer = System.currentTimeMillis();
|
||||
|
||||
setImage("1Combo2.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(80, 80);
|
||||
setImage(image);
|
||||
|
||||
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() + 1000;
|
||||
c = System.currentTimeMillis() + 500;
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
@@ -98,14 +111,24 @@ public class Player1 extends Actor
|
||||
}
|
||||
|
||||
public void animation1(){
|
||||
if (attacking && attackPhase == 1 && System.currentTimeMillis() - attackTimer >= 300) {
|
||||
attackPhase = 2;
|
||||
setImage("2Combo1.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(80, 80);
|
||||
setImage(image);
|
||||
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 >= 600) {
|
||||
if (attacking && attackPhase == 2 && System.currentTimeMillis() - attackTimer >= 300) {
|
||||
attacking = false;
|
||||
attackPhase = 0;
|
||||
}
|
||||
@@ -113,52 +136,102 @@ public class Player1 extends Actor
|
||||
|
||||
public void anitmationLaufen(){
|
||||
if(laeuft){
|
||||
if(schautNachRechts){
|
||||
if(laufPhase == 0){
|
||||
setImage("RenRun1.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(80, 80);
|
||||
setImage(image);
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
laufPhase = 1;
|
||||
laufTimer = System.currentTimeMillis();
|
||||
}
|
||||
if(laufPhase == 1 && System.currentTimeMillis() - laufTimer >= 50){
|
||||
if(laufPhase == 1 && System.currentTimeMillis() - laufTimer >= 100){
|
||||
setImage("RenRun2.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(80, 80);
|
||||
setImage(image);
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
laufPhase = 2;
|
||||
laufTimer = System.currentTimeMillis();
|
||||
}
|
||||
if(laufPhase == 2 && System.currentTimeMillis() - laufTimer >= 50){
|
||||
if(laufPhase == 2 && System.currentTimeMillis() - laufTimer >= 100){
|
||||
setImage("RenRun3.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(80, 80);
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
laufPhase = 3;
|
||||
laufTimer = System.currentTimeMillis();
|
||||
}
|
||||
if(laufPhase == 3 && System.currentTimeMillis() - laufTimer >= 50){
|
||||
if(laufPhase == 3 && System.currentTimeMillis() - laufTimer >= 100){
|
||||
setImage("RenRun4.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(80, 80);
|
||||
image.scale(160, 160);
|
||||
setImage(image);
|
||||
laufPhase = 4;
|
||||
laufTimer = System.currentTimeMillis();
|
||||
}
|
||||
if(laufPhase == 4 && System.currentTimeMillis() - laufTimer >= 50){
|
||||
if(laufPhase == 4 && System.currentTimeMillis() - laufTimer >= 100){
|
||||
setImage("2Combo1.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(80, 80);
|
||||
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() < 363){
|
||||
if(this.getY() < 290){
|
||||
setRotation(90);
|
||||
move(4);
|
||||
setRotation(0);
|
||||
@@ -167,9 +240,12 @@ public class Player1 extends Actor
|
||||
}
|
||||
|
||||
public void charakter(){
|
||||
setImage("2Combo1.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(80,80);
|
||||
setImage(image);
|
||||
if(charakter == 1){
|
||||
setImage("2Combo1.png");
|
||||
GreenfootImage image = getImage();
|
||||
image.scale(160,160);
|
||||
setImage(image);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
+10
-4
@@ -1,8 +1,8 @@
|
||||
#BlueJ class context
|
||||
comment0.target=Player2
|
||||
comment0.text=\r\n\ Write\ a\ description\ of\ class\ player\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
|
||||
comment1.params=
|
||||
comment1.target=Player2()
|
||||
comment1.params=pCharakter
|
||||
comment1.target=Player2(int)
|
||||
comment2.params=
|
||||
comment2.target=void\ act()
|
||||
comment3.params=
|
||||
@@ -12,5 +12,11 @@ comment4.target=void\ springen()
|
||||
comment5.params=
|
||||
comment5.target=boolean\ attacke()
|
||||
comment6.params=
|
||||
comment6.target=void\ gravitation()
|
||||
numComments=7
|
||||
comment6.target=void\ animation1()
|
||||
comment7.params=
|
||||
comment7.target=void\ anitmationLaufen()
|
||||
comment8.params=
|
||||
comment8.target=void\ gravitation()
|
||||
comment9.params=
|
||||
comment9.target=void\ charakter()
|
||||
numComments=10
|
||||
|
||||
+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