diff --git a/fighter/EndWorld.class b/fighter/EndWorld.class index 0edc688..6f2fd43 100644 Binary files a/fighter/EndWorld.class and b/fighter/EndWorld.class differ diff --git a/fighter/EndWorld.java b/fighter/EndWorld.java index d145619..c1a3ebb 100644 --- a/fighter/EndWorld.java +++ b/fighter/EndWorld.java @@ -18,13 +18,14 @@ public class EndWorld extends World // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(600, 400, 1); - showText("GAME OVER", 300, 60); - showText("the winner is " + pSieger, 300, 200); - showText("Drücke R für einen Neustart", 300, 220); + showText("GAME OVER", 300, 70); + showText("the winner is " + pSieger, 300, 220); + showText("Drücke R für einen Neustart", 300, 340); + setBackground(new GreenfootImage("GameOverSreen.png")); } public void act(){ if (Greenfoot.isKeyDown("r")){ - Greenfoot.setWorld(new StartWorld()); + Greenfoot.setWorld(new MenuWorld()); } } } diff --git a/fighter/Lebensanzeige.class b/fighter/Lebensanzeige.class index 7fb4844..cca5362 100644 Binary files a/fighter/Lebensanzeige.class and b/fighter/Lebensanzeige.class differ diff --git a/fighter/Lebensanzeige.ctxt b/fighter/Lebensanzeige.ctxt index 14db61a..b8d4613 100644 --- a/fighter/Lebensanzeige.ctxt +++ b/fighter/Lebensanzeige.ctxt @@ -6,6 +6,6 @@ comment1.target=Lebensanzeige() comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ LebensanzeigeP1\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n comment2.params= comment2.target=void\ act() -comment3.params=pLeben -comment3.target=void\ leben(double) +comment3.params=pLeben\ pMaxLeben +comment3.target=void\ leben(double,\ double) numComments=4 diff --git a/fighter/Lebensanzeige.java b/fighter/Lebensanzeige.java index ad47de4..2b2d6a5 100644 --- a/fighter/Lebensanzeige.java +++ b/fighter/Lebensanzeige.java @@ -15,7 +15,7 @@ public class Lebensanzeige extends Actor Lebensanzeige(){ setImage("green.png"); GreenfootImage image = getImage(); - image.scale(200,40); + image.scale(200,15); setImage(image); } @@ -24,11 +24,11 @@ public class Lebensanzeige extends Actor } - public void leben(double pLeben){ - if(pLeben != 0){ + public void leben(double pLeben, double pMaxLeben){ + if(pLeben > 0){ setImage("green.png"); GreenfootImage image = getImage(); - image.scale((int)(200 * (pLeben/100)),40); + image.scale((int)(200 * (pLeben/pMaxLeben)),15); setImage(image); } } diff --git a/fighter/MyWorld.class b/fighter/MyWorld.class index 45b4f94..1e7ae6d 100644 Binary files a/fighter/MyWorld.class and b/fighter/MyWorld.class differ diff --git a/fighter/MyWorld.ctxt b/fighter/MyWorld.ctxt index 3aefa1c..1c0002c 100644 --- a/fighter/MyWorld.ctxt +++ b/fighter/MyWorld.ctxt @@ -13,4 +13,6 @@ comment4.params= comment4.target=void\ gameEnd() comment5.params= comment5.target=void\ lebensAnzeige() -numComments=6 +comment6.params= +comment6.target=void\ charakterP1() +numComments=7 diff --git a/fighter/MyWorld.java b/fighter/MyWorld.java index 5fe9cd8..8815627 100644 --- a/fighter/MyWorld.java +++ b/fighter/MyWorld.java @@ -14,6 +14,13 @@ public class MyWorld extends World int charakterP2; Lebensanzeige l1; Lebensanzeige l2; + Picture p1; + Picture p2; + int attack1Distance; + int attack2Distance; + int attack1Strength; + int attack2Strength; + int var; /** * Constructor for objects of class MyWorld. * @@ -39,36 +46,56 @@ public class MyWorld extends World player2 = new Player2(charakterP2); addObject(player2,429,152); l1 = new Lebensanzeige(); - addObject(l1,150,50); + addObject(l1,150,40); l2 = new Lebensanzeige(); - addObject(l2,450,50); + addObject(l2,450,40); + p1 = new Picture(1); + addObject(p1,150,50); + p2 = new Picture(2); + addObject(p2,450,50); + charakterP1(); } public void act(){ if(player1.attacke()){ - if(player1.getX() - player2.getX() < 50 && player1.getX() - player2.getX() > -50 && player1.getY() - player2.getY() < 30 && player1.getY() - player2.getY() > -30){ - player2.leben = player2.leben -10; + if(player1.getX() - player2.getX() < attack1Distance && player1.getX() - player2.getX() > -attack1Distance && player1.getY() - player2.getY() < 30 && player1.getY() - player2.getY() > -30){ + player2.leben = player2.leben -attack1Strength; + setPaintOrder(Player1.class,Player2.class); } } if(player2.attacke()){ - if(player1.getX() - player2.getX() < 50 && player1.getX() - player2.getX() > -50 && player1.getY() - player2.getY() < 30 && player1.getY() - player2.getY() > -30){ - player1.leben = player1.leben -10; + if(player1.getX() - player2.getX() < attack1Distance && player1.getX() - player2.getX() > -attack1Distance && player1.getY() - player2.getY() < 30 && player1.getY() - player2.getY() > -30){ + player1.leben = player1.leben -attack1Strength; + setPaintOrder(Player2.class,Player1.class); } } - showText(String.valueOf(player2.leben),450,50); - showText(String.valueOf(player1.leben),150,50); - l1.leben(player1.leben); - l2.leben(player2.leben); - l1.setLocation(150 - (100 - player1.leben), 50); - l2.setLocation(450 - (100 - player2.leben), 50); + if(player1.attacke2()){ + if(player1.getX() - player2.getX() < attack2Distance && player1.getX() - player2.getX() > -attack2Distance && player1.getY() - player2.getY() < 30 && player1.getY() - player2.getY() > -30){ + player2.leben = player2.leben -attack2Strength; + setPaintOrder(Player1.class,Player2.class); + } + } + if(player2.attacke2()){ + if(player1.getX() - player2.getX() < attack2Distance && player1.getX() - player2.getX() > -attack2Distance && player1.getY() - player2.getY() < 30 && player1.getY() - player2.getY() > -30){ + player1.leben = player1.leben -attack2Strength; + setPaintOrder(Player2.class,Player1.class); + } + } + showText(String.valueOf(player2.leben),450,40); + showText(String.valueOf(player1.leben),150,40); + l1.leben(player1.leben, player1.maxLeben); + l2.leben(player2.leben, player2.maxLeben); + l1.setLocation(150 - (int)(100 - ((double)player1.leben/(double)player1.maxLeben)*100), 40); + l2.setLocation(450 + (int)(100 - ((double)player2.leben/(double)player2.maxLeben)*100), 40); gameEnd(); + lebensAnzeige(); } public void gameEnd(){ - if(player1.leben == 0){ + if(player1.leben <= 0){ Greenfoot.setWorld(new EndWorld("Player Two")); } - if(player2.leben == 0){ + if(player2.leben <= 0){ Greenfoot.setWorld(new EndWorld("Player One")); } } @@ -76,4 +103,25 @@ public class MyWorld extends World public void lebensAnzeige(){ } + + public void charakterP1(){ + if(charakterP1 == 1){ + attack1Distance = 95; + attack2Distance = 120; + attack1Strength = 10; + attack2Strength = 20; + } + else if(charakterP1 == 2){ + attack1Distance = 95; + attack2Distance = 145; + attack1Strength = 15; + attack2Strength = 30; + } + else if(charakterP1 == 3){ + attack1Distance = 95; + attack2Distance = 110; + attack1Strength = 8; + attack2Strength = 15; + } + } } diff --git a/fighter/StartWorld.class b/fighter/StartWorld.class index f0ba91c..0d0cfff 100644 Binary files a/fighter/StartWorld.class and b/fighter/StartWorld.class differ diff --git a/fighter/StartWorld.ctxt b/fighter/StartWorld.ctxt index d86e5d4..27d4563 100644 --- a/fighter/StartWorld.ctxt +++ b/fighter/StartWorld.ctxt @@ -3,22 +3,7 @@ comment0.target=StartWorld comment0.text=\r\n\ Write\ a\ description\ of\ class\ StartWorld\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n comment1.params= comment1.target=StartWorld() -comment10.params= -comment10.target=void\ act() +comment1.text=\r\n\ Constructor\ for\ objects\ of\ class\ StartWorld.\r\n\ \r\n comment2.params= -comment2.target=void\ pfeilA() -comment3.params= -comment3.target=void\ pfeilB() -comment4.params= -comment4.target=void\ pfeilC() -comment5.params= -comment5.target=void\ pfeil1() -comment6.params= -comment6.target=void\ pfeil2() -comment7.params= -comment7.target=void\ pfeil3() -comment8.params= -comment8.target=void\ SpielerWahl1() -comment9.params= -comment9.target=void\ SpielerWahl2() -numComments=11 +comment2.target=void\ act() +numComments=3 diff --git a/fighter/StartWorld.java b/fighter/StartWorld.java index 2242f38..8938cf1 100644 --- a/fighter/StartWorld.java +++ b/fighter/StartWorld.java @@ -8,101 +8,32 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) */ public class StartWorld extends World { - + long x= 0; + long timer = 0; + Picture p3; /** * Constructor for objects of class StartWorld. * */ - public int aktuellerSpieler1; - public int aktuellerSpieler2; - public Pfeil cursor1; - public Pfeil cursor2; - public StartWorld() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. - super(600, 400, 1); - showText("Spiel Name" , 300, 20); - showText("select a character", 300, 70); - showText("press enter to start", 300, 340); - showText("player 1 :", 100,100); - showText("player 2 :", 500,100); - - showText("1 character 1", 500,150); - showText("2 character 2", 500,200); - showText("3 character 3", 500,250); - - showText("a character 1", 100,150); - showText("b character 2", 100,200); - showText("c character 3", 100,250); - - cursor1 = new Pfeil(); - cursor1.setImage("cursor.png"); - addObject(cursor1, 50, 100); - - cursor2 = new Pfeil(); - cursor2.setImage("cursor.png"); - addObject(cursor2 , 450, 100); - - } - - public void pfeilA(){ - if(Greenfoot.isKeyDown("a")){ - aktuellerSpieler1 = 1; - cursor1.setLocation(50,160); - } - } - public void pfeilB(){ - if(Greenfoot.isKeyDown("b")){ - aktuellerSpieler1 = 2; - cursor1.setLocation(50,210); - } - } - public void pfeilC(){ - if(Greenfoot.isKeyDown("c")){ - aktuellerSpieler1 = 3; - cursor1.setLocation(50,260); - } - } - - public void pfeil1(){ - if(Greenfoot.isKeyDown("1")){ - aktuellerSpieler2 = 1; - cursor2.setLocation(450,160); - } - } - public void pfeil2(){ - if(Greenfoot.isKeyDown("2")){ - aktuellerSpieler2 = 2; - cursor2.setLocation(450,210); - } - } - public void pfeil3(){ - if(Greenfoot.isKeyDown("3")){ - aktuellerSpieler2 = 3; - cursor2.setLocation(450,260); - } - } - - public void SpielerWahl1(){ - pfeilA(); - pfeilB(); - pfeilC(); - } - - public void SpielerWahl2(){ - pfeil1(); - pfeil2(); - pfeil3(); + super(600, 400, 1); + } public void act(){ - SpielerWahl1(); - SpielerWahl2(); - if (Greenfoot.isKeyDown("enter")){ - if(aktuellerSpieler1 > 0 && aktuellerSpieler2 > 0){ - Greenfoot.setWorld(new MyWorld(aktuellerSpieler1, aktuellerSpieler2)); + if(System.currentTimeMillis() >= timer){ + p3 = new Picture(3); + addObject(p3,300,350); + x = System.currentTimeMillis() + 500; + timer = System.currentTimeMillis() + 1000; } + if(System.currentTimeMillis() >= x){ + removeObject(p3); + } + if (Greenfoot.isKeyDown("enter")){ + Greenfoot.setWorld(new MenuWorld()); } } } diff --git a/fighter/player1.class b/fighter/player1.class index 4495a0b..316dfdf 100644 Binary files a/fighter/player1.class and b/fighter/player1.class differ diff --git a/fighter/player1.ctxt b/fighter/player1.ctxt index b50411e..6abc36b 100644 --- a/fighter/player1.ctxt +++ b/fighter/player1.ctxt @@ -3,6 +3,8 @@ 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=pCharakter comment1.target=Player1(int) +comment10.params= +comment10.target=void\ charakter() comment2.params= comment2.target=void\ act() comment3.params= @@ -12,11 +14,11 @@ comment4.target=void\ springen() comment5.params= comment5.target=boolean\ attacke() comment6.params= -comment6.target=void\ animation1() +comment6.target=boolean\ attacke2() comment7.params= -comment7.target=void\ anitmationLaufen() +comment7.target=void\ animation1() comment8.params= -comment8.target=void\ gravitation() +comment8.target=void\ animationLaufen() comment9.params= -comment9.target=void\ charakter() -numComments=10 +comment9.target=void\ gravitation() +numComments=11 diff --git a/fighter/player1.java b/fighter/player1.java index 85286b6..05d7bf9 100644 --- a/fighter/player1.java +++ b/fighter/player1.java @@ -14,7 +14,10 @@ public class Player1 extends Actor */ public int leben; + int maxLeben; long c; + long d = 0; + long e = 0; boolean schautNachRechts; long attackTimer = 0; int attackPhase = 0; @@ -23,10 +26,22 @@ public class Player1 extends Actor long laufTimer = 0; boolean laeuft = false; int charakter; + boolean attacking2 = false; + String attacke1Animation; + String attacke2Animation1; + String attacke2Animation2; + String defaultAnimation; + String walk1; + String walk2; + String walk3; + String walk4; + int attack2Duration; + int speed; + double speedFaktor; + double speedFaktor2; Player1(int pCharakter){ charakter = pCharakter; - leben = 100; schautNachRechts = true; charakter(); } @@ -36,27 +51,31 @@ public class Player1 extends Actor gravitation(); springen(); animation1(); - anitmationLaufen(); + animationLaufen(); } public void bewegung(){ if(Greenfoot.isKeyDown("d")){ setRotation(0); - move(5); + move(speed); if(!schautNachRechts && attackPhase == 0){ getImage().mirrorHorizontally(); schautNachRechts = true; } laeuft = true; + attacke(); + attacke2(); } if(Greenfoot.isKeyDown("a")){ setRotation(0); - move(-5); + move(-speed); if(schautNachRechts && attackPhase == 0){ getImage().mirrorHorizontally(); schautNachRechts = false; } laeuft = true; + attacke(); + attacke2(); } } @@ -68,29 +87,30 @@ public class Player1 extends Actor setRotation(0); Greenfoot.delay(1); bewegung(); + attacke(); + attacke2(); } } } public boolean attacke(){ - if(Greenfoot.isKeyDown("e")){ - if(System.currentTimeMillis() >= c){ - - if (!attacking) { + if(System.currentTimeMillis() >= c){ + if(Greenfoot.isKeyDown("e")){ + if (!attacking && !attacking2) { attacking = true; attackPhase = 1; attackTimer = System.currentTimeMillis(); if(schautNachRechts){ - setImage("1Combo2.png"); + setImage(attacke1Animation); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); } else{ - setImage("1Combo2.png"); + setImage(attacke1Animation); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); getImage().mirrorHorizontally(); } @@ -98,81 +118,154 @@ public class Player1 extends Actor } - c = System.currentTimeMillis() + 500; - return true; + c = System.currentTimeMillis() + (int)(500/speedFaktor); } - else{ - return false; + } + if(attacking && attackPhase == 1 && System.currentTimeMillis() >= d){ + d = System.currentTimeMillis() + (int)(300/speedFaktor); + return true; + } + else{ + return false; + } + } + + public boolean attacke2(){ + if(System.currentTimeMillis() >= c){ + if(Greenfoot.isKeyDown("q")){ + if (!attacking2 && !attacking) { + attacking2 = true; + attackPhase = 1; + attackTimer = System.currentTimeMillis(); + + if(schautNachRechts){ + setImage(attacke2Animation1); + GreenfootImage image = getImage(); + image.scale(250, 250); + setImage(image); + } + else{ + setImage(attacke2Animation1); + GreenfootImage image = getImage(); + image.scale(250, 250); + setImage(image); + getImage().mirrorHorizontally(); + } + + } + + + c = System.currentTimeMillis() + (int)(800/speedFaktor); } } + if(attacking2 && attackPhase == attack2Duration && System.currentTimeMillis() >= System.currentTimeMillis()+e){ + e = (int)(1000/speedFaktor2); + return true; + } else{ return false; } } public void animation1(){ - if (attacking && attackPhase == 1 && System.currentTimeMillis() - attackTimer >= 200) { + if (attacking && attackPhase == 1 && System.currentTimeMillis() - attackTimer >= (int)(200/speedFaktor)) { if(schautNachRechts){ attackPhase = 2; - setImage("2Combo1.png"); + setImage(defaultAnimation); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); } else{ attackPhase = 2; - setImage("2Combo1.png"); + setImage(defaultAnimation); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); getImage().mirrorHorizontally(); } } - if (attacking && attackPhase == 2 && System.currentTimeMillis() - attackTimer >= 300) { + if (attacking && attackPhase == 2 && System.currentTimeMillis() - attackTimer >= (int)(500/speedFaktor)) { attacking = false; attackPhase = 0; + d = 0; + } + if (attacking2 && attackPhase == 1 && System.currentTimeMillis() - attackTimer >= (int)(550/speedFaktor2)) { + if(schautNachRechts){ + attackPhase = 2; + setImage(attacke2Animation2); + GreenfootImage image = getImage(); + image.scale(250, 250); + setImage(image); + } + else{ + attackPhase = 2; + setImage(attacke2Animation2); + GreenfootImage image = getImage(); + image.scale(250, 250); + setImage(image); + getImage().mirrorHorizontally(); + } + } + if (attacking2 && attackPhase == 2 && System.currentTimeMillis() - attackTimer >= (int)(800/speedFaktor2)) { + attacking2 = false; + attackPhase = 0; + e = 0; + if(schautNachRechts){ + setImage(defaultAnimation); + GreenfootImage image = getImage(); + image.scale(250, 250); + setImage(image); + } + else{ + setImage(defaultAnimation); + GreenfootImage image = getImage(); + image.scale(250, 250); + setImage(image); + getImage().mirrorHorizontally(); + } } } - public void anitmationLaufen(){ - if(laeuft){ + public void animationLaufen(){ + if(laeuft &! attacking &! attacking2){ if(schautNachRechts){ if(laufPhase == 0){ - setImage("RenRun1.png"); + setImage(walk1); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); laufPhase = 1; laufTimer = System.currentTimeMillis(); } - if(laufPhase == 1 && System.currentTimeMillis() - laufTimer >= 100){ - setImage("RenRun2.png"); + if(laufPhase == 1 && System.currentTimeMillis() - laufTimer >= 200){ + setImage(walk2); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); laufPhase = 2; laufTimer = System.currentTimeMillis(); } - if(laufPhase == 2 && System.currentTimeMillis() - laufTimer >= 100){ - setImage("RenRun3.png"); + if(laufPhase == 2 && System.currentTimeMillis() - laufTimer >= 200){ + setImage(walk3); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); laufPhase = 3; laufTimer = System.currentTimeMillis(); } - if(laufPhase == 3 && System.currentTimeMillis() - laufTimer >= 100){ - setImage("RenRun4.png"); + if(laufPhase == 3 && System.currentTimeMillis() - laufTimer >= 200){ + setImage(walk4); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); laufPhase = 4; laufTimer = System.currentTimeMillis(); } - if(laufPhase == 4 && System.currentTimeMillis() - laufTimer >= 100){ - setImage("2Combo1.png"); + if(laufPhase == 4 && System.currentTimeMillis() - laufTimer >= 200){ + setImage(defaultAnimation); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); laufPhase = 0; laufTimer = System.currentTimeMillis(); @@ -181,45 +274,45 @@ public class Player1 extends Actor } else{ if(laufPhase == 0){ - setImage("RenRun1.png"); + setImage(walk1); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); getImage().mirrorHorizontally(); laufPhase = 1; laufTimer = System.currentTimeMillis(); } - if(laufPhase == 1 && System.currentTimeMillis() - laufTimer >= 100){ - setImage("RenRun2.png"); + if(laufPhase == 1 && System.currentTimeMillis() - laufTimer >= 200){ + setImage(walk2); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); getImage().mirrorHorizontally(); laufPhase = 2; laufTimer = System.currentTimeMillis(); } - if(laufPhase == 2 && System.currentTimeMillis() - laufTimer >= 100){ - setImage("RenRun3.png"); + if(laufPhase == 2 && System.currentTimeMillis() - laufTimer >= 200){ + setImage(walk3); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); getImage().mirrorHorizontally(); laufPhase = 3; laufTimer = System.currentTimeMillis(); } - if(laufPhase == 3 && System.currentTimeMillis() - laufTimer >= 100){ - setImage("RenRun4.png"); + if(laufPhase == 3 && System.currentTimeMillis() - laufTimer >= 200){ + setImage(walk4); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); getImage().mirrorHorizontally(); laufPhase = 4; laufTimer = System.currentTimeMillis(); } - if(laufPhase == 4 && System.currentTimeMillis() - laufTimer >= 100){ - setImage("2Combo1.png"); + if(laufPhase == 4 && System.currentTimeMillis() - laufTimer >= 200){ + setImage(defaultAnimation); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); getImage().mirrorHorizontally(); laufPhase = 0; @@ -241,11 +334,56 @@ public class Player1 extends Actor public void charakter(){ if(charakter == 1){ - setImage("2Combo1.png"); - GreenfootImage image = getImage(); - image.scale(160,160); - setImage(image); + defaultAnimation = "2Combo1.png"; + attacke1Animation = "1Combo2.png"; + attacke2Animation1 = "3Combo2.png"; + attacke2Animation2 = defaultAnimation; + walk1 = "RenRun1.png"; + walk2 = "RenRun2.png"; + walk3 = "RenRun3.png"; + walk4 = "RenRun4.png"; + attack2Duration = 1; + speed = 6; + maxLeben = 100; + leben = maxLeben; + speedFaktor = 1; + speedFaktor2 = speedFaktor; } - + if(charakter == 2){ + defaultAnimation = "Tetsu1Combo1.png"; + attacke1Animation = "Tetsu1Combo2.png"; + attacke2Animation1 = "Tetsu3Combo1.png"; + attacke2Animation2 = "Tetsu3Combo2.png"; + walk1 = "TetsuRun1.png"; + walk2 = "TetsuRun2.png"; + walk3 = "TetsuRun3.png"; + walk4 = "TetsuRun4.png"; + attack2Duration = 2; + speed = 4; + maxLeben = 130; + leben = maxLeben; + speedFaktor = 0.5; + speedFaktor2 = 0.75; + } + if(charakter == 3){ + defaultAnimation = "HinataShoot1.png"; + attacke1Animation = "Hinata2Combo1.png"; + attacke2Animation1 = "Hinata3Combo1.png"; + attacke2Animation2 = defaultAnimation; + walk1 = "HinataRun1.png"; + walk2 = "HinataRun2.png"; + walk3 = "HinataRun3.png"; + walk4 = "HinataRun4.png"; + attack2Duration = 1; + speed = 8; + maxLeben = 80; + leben = maxLeben; + speedFaktor = 2; + speedFaktor2 = 8; + } + setImage(defaultAnimation); + GreenfootImage image = getImage(); + image.scale(250,250); + setImage(image); } } diff --git a/fighter/player2.class b/fighter/player2.class index e9a6cf0..ad12fb3 100644 Binary files a/fighter/player2.class and b/fighter/player2.class differ diff --git a/fighter/player2.ctxt b/fighter/player2.ctxt index e7a2a7f..7c3c266 100644 --- a/fighter/player2.ctxt +++ b/fighter/player2.ctxt @@ -3,6 +3,8 @@ 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=pCharakter comment1.target=Player2(int) +comment10.params= +comment10.target=void\ charakter() comment2.params= comment2.target=void\ act() comment3.params= @@ -12,11 +14,11 @@ comment4.target=void\ springen() comment5.params= comment5.target=boolean\ attacke() comment6.params= -comment6.target=void\ animation1() +comment6.target=boolean\ attacke2() comment7.params= -comment7.target=void\ anitmationLaufen() +comment7.target=void\ animation1() comment8.params= -comment8.target=void\ gravitation() +comment8.target=void\ animationLaufen() comment9.params= -comment9.target=void\ charakter() -numComments=10 +comment9.target=void\ gravitation() +numComments=11 diff --git a/fighter/player2.java b/fighter/player2.java index 31dfdc9..1dd0ab8 100644 --- a/fighter/player2.java +++ b/fighter/player2.java @@ -14,7 +14,10 @@ public class Player2 extends Actor */ public int leben; + int maxLeben; long c; + long d = 0; + long e = 0; boolean schautNachRechts; long attackTimer = 0; int attackPhase = 0; @@ -23,10 +26,22 @@ public class Player2 extends Actor long laufTimer = 0; boolean laeuft = false; int charakter; + boolean attacking2 = false; + String attacke1Animation; + String attacke2Animation1; + String attacke2Animation2; + String defaultAnimation; + String walk1; + String walk2; + String walk3; + String walk4; + int attack2Duration; + int speed; + double speedFaktor; + double speedFaktor2; Player2(int pCharakter){ charakter = pCharakter; - leben = 100; schautNachRechts = false; charakter(); } @@ -36,142 +51,221 @@ public class Player2 extends Actor gravitation(); springen(); animation1(); - anitmationLaufen(); + animationLaufen(); } public void bewegung(){ - if(Greenfoot.isKeyDown("right")){ + if(Greenfoot.isKeyDown("l")){ setRotation(0); - move(5); + move(speed); if(!schautNachRechts && attackPhase == 0){ getImage().mirrorHorizontally(); schautNachRechts = true; } laeuft = true; + attacke(); + attacke2(); } - if(Greenfoot.isKeyDown("left")){ + if(Greenfoot.isKeyDown("j")){ setRotation(0); - move(-5); + move(-speed); if(schautNachRechts && attackPhase == 0){ getImage().mirrorHorizontally(); schautNachRechts = false; } laeuft = true; + attacke(); + attacke2(); } } public void springen(){ - if(Greenfoot.isKeyDown("up") && this.getY() > 289 ){ + 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 boolean attacke(){ - if(Greenfoot.isKeyDown(".")){ - if(System.currentTimeMillis() >= c){ - - if (!attacking) { + if(System.currentTimeMillis() >= c){ + if(Greenfoot.isKeyDown("o")){ + if (!attacking && !attacking2) { attacking = true; attackPhase = 1; attackTimer = System.currentTimeMillis(); - + if(schautNachRechts){ - setImage("1Combo2.png"); + setImage(attacke1Animation); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); } else{ - setImage("1Combo2.png"); + setImage(attacke1Animation); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); getImage().mirrorHorizontally(); } + } - c = System.currentTimeMillis() + 500; - return true; + c = System.currentTimeMillis() + (int)(500/speedFaktor); } - else{ - return false; + } + if(attacking && attackPhase == 1 && System.currentTimeMillis() >= d){ + d = System.currentTimeMillis() + (int)(300/speedFaktor); + return true; + } + else{ + return false; + } + } + + public boolean attacke2(){ + if(System.currentTimeMillis() >= c){ + if(Greenfoot.isKeyDown("u")){ + if (!attacking2 && !attacking) { + attacking2 = true; + attackPhase = 1; + attackTimer = System.currentTimeMillis(); + + if(schautNachRechts){ + setImage(attacke2Animation1); + GreenfootImage image = getImage(); + image.scale(250, 250); + setImage(image); + } + else{ + setImage(attacke2Animation1); + GreenfootImage image = getImage(); + image.scale(250, 250); + setImage(image); + getImage().mirrorHorizontally(); + } + + } + + + c = System.currentTimeMillis() + (int)(800/speedFaktor); } } + if(attacking2 && attackPhase == attack2Duration && System.currentTimeMillis() >= System.currentTimeMillis()+e){ + e = (int)(1000/speedFaktor2); + return true; + } else{ return false; } } public void animation1(){ - if (attacking && attackPhase == 1 && System.currentTimeMillis() - attackTimer >= 200) { + if (attacking && attackPhase == 1 && System.currentTimeMillis() - attackTimer >= (int)(200/speedFaktor)) { if(schautNachRechts){ attackPhase = 2; - setImage("2Combo1.png"); + setImage(defaultAnimation); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); } else{ attackPhase = 2; - setImage("2Combo1.png"); + setImage(defaultAnimation); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); getImage().mirrorHorizontally(); } } - if (attacking && attackPhase == 2 && System.currentTimeMillis() - attackTimer >= 300) { + if (attacking && attackPhase == 2 && System.currentTimeMillis() - attackTimer >= (int)(500/speedFaktor)) { attacking = false; attackPhase = 0; + d = 0; + } + if (attacking2 && attackPhase == 1 && System.currentTimeMillis() - attackTimer >= (int)(550/speedFaktor2)) { + if(schautNachRechts){ + attackPhase = 2; + setImage(attacke2Animation2); + GreenfootImage image = getImage(); + image.scale(250, 250); + setImage(image); + } + else{ + attackPhase = 2; + setImage(attacke2Animation2); + GreenfootImage image = getImage(); + image.scale(250, 250); + setImage(image); + getImage().mirrorHorizontally(); + } + } + if (attacking2 && attackPhase == 2 && System.currentTimeMillis() - attackTimer >= (int)(800/speedFaktor2)) { + attacking2 = false; + attackPhase = 0; + e = 0; + if(schautNachRechts){ + setImage(defaultAnimation); + GreenfootImage image = getImage(); + image.scale(250, 250); + setImage(image); + } + else{ + setImage(defaultAnimation); + GreenfootImage image = getImage(); + image.scale(250, 250); + setImage(image); + getImage().mirrorHorizontally(); + } } } - public void anitmationLaufen(){ - if(laeuft){ + public void animationLaufen(){ + if(laeuft &! attacking &! attacking2){ if(schautNachRechts){ if(laufPhase == 0){ - setImage("RenRun1.png"); + setImage(walk1); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); laufPhase = 1; laufTimer = System.currentTimeMillis(); } - if(laufPhase == 1 && System.currentTimeMillis() - laufTimer >= 100){ - setImage("RenRun2.png"); + if(laufPhase == 1 && System.currentTimeMillis() - laufTimer >= 200){ + setImage(walk2); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); laufPhase = 2; laufTimer = System.currentTimeMillis(); } - if(laufPhase == 2 && System.currentTimeMillis() - laufTimer >= 100){ - setImage("RenRun3.png"); + if(laufPhase == 2 && System.currentTimeMillis() - laufTimer >= 200){ + setImage(walk3); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); laufPhase = 3; laufTimer = System.currentTimeMillis(); } - if(laufPhase == 3 && System.currentTimeMillis() - laufTimer >= 100){ - setImage("RenRun4.png"); + if(laufPhase == 3 && System.currentTimeMillis() - laufTimer >= 200){ + setImage(walk4); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); laufPhase = 4; laufTimer = System.currentTimeMillis(); } - if(laufPhase == 4 && System.currentTimeMillis() - laufTimer >= 100){ - setImage("2Combo1.png"); + if(laufPhase == 4 && System.currentTimeMillis() - laufTimer >= 200){ + setImage(defaultAnimation); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); laufPhase = 0; laufTimer = System.currentTimeMillis(); @@ -180,45 +274,45 @@ public class Player2 extends Actor } else{ if(laufPhase == 0){ - setImage("RenRun1.png"); + setImage(walk1); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); getImage().mirrorHorizontally(); laufPhase = 1; laufTimer = System.currentTimeMillis(); } - if(laufPhase == 1 && System.currentTimeMillis() - laufTimer >= 100){ - setImage("RenRun2.png"); + if(laufPhase == 1 && System.currentTimeMillis() - laufTimer >= 200){ + setImage(walk2); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); getImage().mirrorHorizontally(); laufPhase = 2; laufTimer = System.currentTimeMillis(); } - if(laufPhase == 2 && System.currentTimeMillis() - laufTimer >= 100){ - setImage("RenRun3.png"); + if(laufPhase == 2 && System.currentTimeMillis() - laufTimer >= 200){ + setImage(walk3); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); getImage().mirrorHorizontally(); laufPhase = 3; laufTimer = System.currentTimeMillis(); } - if(laufPhase == 3 && System.currentTimeMillis() - laufTimer >= 100){ - setImage("RenRun4.png"); + if(laufPhase == 3 && System.currentTimeMillis() - laufTimer >= 200){ + setImage(walk4); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); getImage().mirrorHorizontally(); laufPhase = 4; laufTimer = System.currentTimeMillis(); } - if(laufPhase == 4 && System.currentTimeMillis() - laufTimer >= 100){ - setImage("2Combo1.png"); + if(laufPhase == 4 && System.currentTimeMillis() - laufTimer >= 200){ + setImage(defaultAnimation); GreenfootImage image = getImage(); - image.scale(160, 160); + image.scale(250, 250); setImage(image); getImage().mirrorHorizontally(); laufPhase = 0; @@ -240,12 +334,57 @@ public class Player2 extends Actor public void charakter(){ if(charakter == 1){ - setImage("2Combo1.png"); - GreenfootImage image = getImage(); - image.scale(160,160); - setImage(image); - getImage().mirrorHorizontally(); + defaultAnimation = "2Combo1.png"; + attacke1Animation = "1Combo2.png"; + attacke2Animation1 = "3Combo2.png"; + attacke2Animation2 = defaultAnimation; + walk1 = "RenRun1.png"; + walk2 = "RenRun2.png"; + walk3 = "RenRun3.png"; + walk4 = "RenRun4.png"; + attack2Duration = 1; + speed = 6; + maxLeben = 100; + leben = maxLeben; + speedFaktor = 1; + speedFaktor2 = speedFaktor; } - + if(charakter == 2){ + defaultAnimation = "Tetsu1Combo1.png"; + attacke1Animation = "Tetsu1Combo2.png"; + attacke2Animation1 = "Tetsu3Combo1.png"; + attacke2Animation2 = "Tetsu3Combo2.png"; + walk1 = "TetsuRun1.png"; + walk2 = "TetsuRun2.png"; + walk3 = "TetsuRun3.png"; + walk4 = "TetsuRun4.png"; + attack2Duration = 2; + speed = 4; + maxLeben = 130; + leben = maxLeben; + speedFaktor = 0.5; + speedFaktor2 = 0.75; + } + if(charakter == 3){ + defaultAnimation = "HinataShoot1.png"; + attacke1Animation = "Hinata2Combo1.png"; + attacke2Animation1 = "Hinata3Combo1.png"; + attacke2Animation2 = defaultAnimation; + walk1 = "HinataRun1.png"; + walk2 = "HinataRun2.png"; + walk3 = "HinataRun3.png"; + walk4 = "HinataRun4.png"; + attack2Duration = 1; + speed = 8; + maxLeben = 80; + leben = maxLeben; + speedFaktor = 2; + speedFaktor2 = 8; + } + setImage(defaultAnimation); + GreenfootImage image = getImage(); + image.scale(250,250); + setImage(image); + getImage().mirrorHorizontally(); } } diff --git a/fighter/project.greenfoot b/fighter/project.greenfoot index cc449e0..43b83a0 100644 --- a/fighter/project.greenfoot +++ b/fighter/project.greenfoot @@ -3,34 +3,47 @@ class.Lebensanzeige.image=Lebensanzeige.png class.MyWorld.image=IMG_7841.png class.Player1.image=man01.png class.Player2.image=man01.png +class.StartWorld.image=HomeScreen.png dependency1.from=EndWorld -dependency1.to=StartWorld +dependency1.to=MenuWorld dependency1.type=UsesDependency +dependency10.from=MyWorld +dependency10.to=Picture +dependency10.type=UsesDependency +dependency11.from=MyWorld +dependency11.to=EndWorld +dependency11.type=UsesDependency dependency2.from=StartWorld -dependency2.to=Pfeil +dependency2.to=Picture dependency2.type=UsesDependency dependency3.from=StartWorld -dependency3.to=MyWorld +dependency3.to=MenuWorld dependency3.type=UsesDependency -dependency4.from=MyWorld -dependency4.to=Player1 +dependency4.from=MenuWorld +dependency4.to=Pfeil dependency4.type=UsesDependency -dependency5.from=MyWorld -dependency5.to=Player2 +dependency5.from=MenuWorld +dependency5.to=Picture dependency5.type=UsesDependency -dependency6.from=MyWorld -dependency6.to=Lebensanzeige +dependency6.from=MenuWorld +dependency6.to=MyWorld dependency6.type=UsesDependency dependency7.from=MyWorld -dependency7.to=EndWorld +dependency7.to=Player1 dependency7.type=UsesDependency -editor.fx.0.height=686 -editor.fx.0.width=1294 -editor.fx.0.x=-7 -editor.fx.0.y=-7 +dependency8.from=MyWorld +dependency8.to=Player2 +dependency8.type=UsesDependency +dependency9.from=MyWorld +dependency9.to=Lebensanzeige +dependency9.type=UsesDependency +editor.fx.0.height=678 +editor.fx.0.width=604 +editor.fx.0.x=682 +editor.fx.0.y=0 height=686 -package.numDependencies=7 -package.numTargets=7 +package.numDependencies=11 +package.numTargets=9 project.charset=UTF-8 publish.hasSource=false publish.locked=true @@ -60,40 +73,54 @@ target2.width=120 target2.x=0 target2.y=0 target3.height=70 -target3.name=Lebensanzeige +target3.name=Picture target3.showInterface=false target3.type=ClassTarget target3.width=120 target3.x=0 target3.y=0 target4.height=70 -target4.name=StartWorld +target4.name=Lebensanzeige target4.showInterface=false target4.type=ClassTarget target4.width=120 target4.x=0 target4.y=0 target5.height=70 -target5.name=Player2 +target5.name=StartWorld target5.showInterface=false target5.type=ClassTarget target5.width=120 target5.x=0 target5.y=0 target6.height=70 -target6.name=Player1 +target6.name=Player2 target6.showInterface=false target6.type=ClassTarget target6.width=120 target6.x=0 target6.y=0 target7.height=70 -target7.name=MyWorld +target7.name=Player1 target7.showInterface=false target7.type=ClassTarget target7.width=120 target7.x=0 target7.y=0 +target8.height=70 +target8.name=MenuWorld +target8.showInterface=false +target8.type=ClassTarget +target8.width=120 +target8.x=0 +target8.y=0 +target9.height=70 +target9.name=MyWorld +target9.showInterface=false +target9.type=ClassTarget +target9.width=120 +target9.x=0 +target9.y=0 version=3.1.0 width=1294 world.lastInstantiated=StartWorld