Compare commits

..

11 Commits

Author SHA1 Message Date
Max 4d98573c7c - Lebensanzeige
- walk Animation fertig
2026-09-15 21:04:26 +02:00
Max 067d36033d - Lebensanzeige
- walk Animation fertig
2026-09-15 21:04:11 +02:00
Max 60d21d5f68 - Start World to Game World 2026-09-15 19:35:25 +02:00
Leif cce1abcc81 Endscreen erstellt 2026-09-15 19:27:12 +02:00
Max 6b842a7b75 Merge remote-tracking branch 'origin/main'
# Conflicts:
#	fighter/project.greenfoot
2026-09-15 19:14:59 +02:00
Max 67db7a5e48 test file 2026-09-15 19:14:23 +02:00
Max 6e7ff8d2eb - Spieler Attacke, Animation 2026-09-15 19:13:35 +02:00
Leif c4505df6ed Startscreen erstellt 2026-09-15 19:10:55 +02:00
Max a53a0a22c6 Bewegung des 1. und 2. Spielers 2026-09-15 09:49:28 +02:00
Max 48b3ce212f initial 2026-09-14 23:41:15 +02:00
Michel May 6301a9b0a6 test file deleted 2026-09-14 21:24:38 +02:00
70 changed files with 1013 additions and 1 deletions
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/fighter" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
#BlueJ class context
comment0.target=EndWorld
comment0.text=\r\n\ Write\ a\ description\ of\ class\ GameOverWorld\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=pSieger
comment1.target=EndWorld(java.lang.String)
comment1.text=\r\n\ Constructor\ for\ objects\ of\ class\ GameOverWorld.\r\n\ \r\n
comment2.params=
comment2.target=void\ act()
numComments=3
+30
View File
@@ -0,0 +1,30 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class GameOverWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class EndWorld extends World
{
/**
* Constructor for objects of class GameOverWorld.
*
*/
public EndWorld(String pSieger)
{
// 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);
}
public void act(){
if (Greenfoot.isKeyDown("r")){
Greenfoot.setWorld(new StartWorld());
}
}
}
Binary file not shown.
+11
View File
@@ -0,0 +1,11 @@
#BlueJ class context
comment0.target=Lebensanzeige
comment0.text=\r\n\ Write\ a\ description\ of\ class\ LebensanzeigeP1\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=
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)
numComments=4
+35
View File
@@ -0,0 +1,35 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class LebensanzeigeP1 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Lebensanzeige extends Actor
{
/**
* Act - do whatever the LebensanzeigeP1 wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
Lebensanzeige(){
setImage("green.png");
GreenfootImage image = getImage();
image.scale(200,40);
setImage(image);
}
public void act()
{
}
public void leben(double pLeben){
if(pLeben != 0){
setImage("green.png");
GreenfootImage image = getImage();
image.scale((int)(200 * (pLeben/100)),40);
setImage(image);
}
}
}
Binary file not shown.
+16
View File
@@ -0,0 +1,16 @@
#BlueJ class context
comment0.target=MyWorld
comment0.text=\r\n\ Write\ a\ description\ of\ class\ MyWorld\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=pCharakterP1\ pCharakterP2
comment1.target=MyWorld(int,\ int)
comment1.text=\r\n\ Constructor\ for\ objects\ of\ class\ MyWorld.\r\n\ \r\n
comment2.params=
comment2.target=void\ prepare()
comment2.text=\r\n\ Prepare\ the\ world\ for\ the\ start\ of\ the\ program.\r\n\ That\ is\:\ create\ the\ initial\ objects\ and\ add\ them\ to\ the\ world.\r\n
comment3.params=
comment3.target=void\ act()
comment4.params=
comment4.target=void\ gameEnd()
comment5.params=
comment5.target=void\ lebensAnzeige()
numComments=6
+79
View File
@@ -0,0 +1,79 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class MyWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MyWorld extends World
{
Player1 player1;
Player2 player2;
int charakterP1;
int charakterP2;
Lebensanzeige l1;
Lebensanzeige l2;
/**
* Constructor for objects of class MyWorld.
*
*/
public MyWorld(int pCharakterP1, int pCharakterP2)
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
charakterP1 = pCharakterP1;
charakterP2 = pCharakterP2;
prepare();
}
/**
* Prepare the world for the start of the program.
* That is: create the initial objects and add them to the world.
*/
private void prepare()
{
player1 = new Player1(charakterP1);
addObject(player1,125,153);
player2 = new Player2(charakterP2);
addObject(player2,429,152);
l1 = new Lebensanzeige();
addObject(l1,150,50);
l2 = new Lebensanzeige();
addObject(l2,450,50);
}
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(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;
}
}
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);
gameEnd();
}
public void gameEnd(){
if(player1.leben == 0){
Greenfoot.setWorld(new EndWorld("Player Two"));
}
if(player2.leben == 0){
Greenfoot.setWorld(new EndWorld("Player One"));
}
}
public void lebensAnzeige(){
}
}
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
#BlueJ class context
comment0.target=Pfeil
comment0.text=\r\n\ Write\ a\ description\ of\ class\ Pfeil\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=
comment1.target=void\ act()
comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ Pfeil\ 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\ Pfeil()
numComments=3
+22
View File
@@ -0,0 +1,22 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Pfeil here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Pfeil extends Actor
{
/**
* Act - do whatever the Pfeil wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
}
public void Pfeil(){
}
}
+12
View File
@@ -0,0 +1,12 @@
------------------------------------------------------------------------
This is the project README file. Here, you should describe your project.
Tell the reader (someone who does not know anything about this project)
all they need to know. The comments should usually include at least:
------------------------------------------------------------------------
PROJECT TITLE:
PURPOSE OF PROJECT:
VERSION or DATE:
HOW TO START THIS PROJECT:
AUTHORS:
USER INSTRUCTIONS:
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
#BlueJ class context
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()
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
+108
View File
@@ -0,0 +1,108 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class StartWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class StartWorld extends World
{
/**
* 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();
}
public void act(){
SpielerWahl1();
SpielerWahl2();
if (Greenfoot.isKeyDown("enter")){
if(aktuellerSpieler1 > 0 && aktuellerSpieler2 > 0){
Greenfoot.setWorld(new MyWorld(aktuellerSpieler1, aktuellerSpieler2));
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
#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=pCharakter
comment1.target=Player1(int)
comment2.params=
comment2.target=void\ act()
comment3.params=
comment3.target=void\ bewegung()
comment4.params=
comment4.target=void\ springen()
comment5.params=
comment5.target=boolean\ attacke()
comment6.params=
comment6.target=void\ animation1()
comment7.params=
comment7.target=void\ anitmationLaufen()
comment8.params=
comment8.target=void\ gravitation()
comment9.params=
comment9.target=void\ charakter()
numComments=10
+251
View File
@@ -0,0 +1,251 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class player here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Player1 extends Actor
{
/**
* Act - do whatever the player wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
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;
Player1(int pCharakter){
charakter = pCharakter;
leben = 100;
schautNachRechts = true;
charakter();
}
public void act()
{
bewegung();
gravitation();
springen();
animation1();
anitmationLaufen();
}
public void bewegung(){
if(Greenfoot.isKeyDown("d")){
setRotation(0);
move(5);
if(!schautNachRechts && attackPhase == 0){
getImage().mirrorHorizontally();
schautNachRechts = true;
}
laeuft = true;
}
if(Greenfoot.isKeyDown("a")){
setRotation(0);
move(-5);
if(schautNachRechts && attackPhase == 0){
getImage().mirrorHorizontally();
schautNachRechts = false;
}
laeuft = true;
}
}
public void springen(){
if(Greenfoot.isKeyDown("space") && this.getY() > 289 ){
for(int i = 12; i > -12; i--){
setRotation(270);
move(i);
setRotation(0);
Greenfoot.delay(1);
bewegung();
}
}
}
public boolean attacke(){
if(Greenfoot.isKeyDown("e")){
if(System.currentTimeMillis() >= c){
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{
return false;
}
}
else{
return false;
}
}
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() < 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);
}
}
}
Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
#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=pCharakter
comment1.target=Player2(int)
comment2.params=
comment2.target=void\ act()
comment3.params=
comment3.target=void\ bewegung()
comment4.params=
comment4.target=void\ springen()
comment5.params=
comment5.target=boolean\ attacke()
comment6.params=
comment6.target=void\ animation1()
comment7.params=
comment7.target=void\ anitmationLaufen()
comment8.params=
comment8.target=void\ gravitation()
comment9.params=
comment9.target=void\ charakter()
numComments=10
+251
View File
@@ -0,0 +1,251 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class player here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Player2 extends Actor
{
/**
* Act - do whatever the player wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
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(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(5);
if(!schautNachRechts && attackPhase == 0){
getImage().mirrorHorizontally();
schautNachRechts = true;
}
laeuft = true;
}
if(Greenfoot.isKeyDown("left")){
setRotation(0);
move(-5);
if(schautNachRechts && attackPhase == 0){
getImage().mirrorHorizontally();
schautNachRechts = false;
}
laeuft = true;
}
}
public void springen(){
if(Greenfoot.isKeyDown("up") && this.getY() > 289 ){
for(int i = 12; i > -12; i--){
setRotation(270);
move(i);
setRotation(0);
Greenfoot.delay(1);
bewegung();
}
}
}
public boolean attacke(){
if(Greenfoot.isKeyDown(".")){
if(System.currentTimeMillis() >= c){
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{
return false;
}
}
else{
return false;
}
}
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() < 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();
}
}
}
+101
View File
@@ -0,0 +1,101 @@
#Greenfoot project file
class.Lebensanzeige.image=Lebensanzeige.png
class.MyWorld.image=IMG_7841.png
class.Player1.image=man01.png
class.Player2.image=man01.png
dependency1.from=EndWorld
dependency1.to=StartWorld
dependency1.type=UsesDependency
dependency2.from=StartWorld
dependency2.to=Pfeil
dependency2.type=UsesDependency
dependency3.from=StartWorld
dependency3.to=MyWorld
dependency3.type=UsesDependency
dependency4.from=MyWorld
dependency4.to=Player1
dependency4.type=UsesDependency
dependency5.from=MyWorld
dependency5.to=Player2
dependency5.type=UsesDependency
dependency6.from=MyWorld
dependency6.to=Lebensanzeige
dependency6.type=UsesDependency
dependency7.from=MyWorld
dependency7.to=EndWorld
dependency7.type=UsesDependency
editor.fx.0.height=686
editor.fx.0.width=1294
editor.fx.0.x=-7
editor.fx.0.y=-7
height=686
package.numDependencies=7
package.numTargets=7
project.charset=UTF-8
publish.hasSource=false
publish.locked=true
publish.longDesc=
publish.shortDesc=
publish.tags=
publish.title=
publish.url=
readme.height=60
readme.name=@README
readme.width=48
readme.x=10
readme.y=10
simulation.speed=48
target1.height=70
target1.name=Pfeil
target1.showInterface=false
target1.type=ClassTarget
target1.width=120
target1.x=0
target1.y=0
target2.height=70
target2.name=EndWorld
target2.showInterface=false
target2.type=ClassTarget
target2.width=120
target2.x=0
target2.y=0
target3.height=70
target3.name=Lebensanzeige
target3.showInterface=false
target3.type=ClassTarget
target3.width=120
target3.x=0
target3.y=0
target4.height=70
target4.name=StartWorld
target4.showInterface=false
target4.type=ClassTarget
target4.width=120
target4.x=0
target4.y=0
target5.height=70
target5.name=Player2
target5.showInterface=false
target5.type=ClassTarget
target5.width=120
target5.x=0
target5.y=0
target6.height=70
target6.name=Player1
target6.showInterface=false
target6.type=ClassTarget
target6.width=120
target6.x=0
target6.y=0
target7.height=70
target7.name=MyWorld
target7.showInterface=false
target7.type=ClassTarget
target7.width=120
target7.x=0
target7.y=0
version=3.1.0
width=1294
world.lastInstantiated=StartWorld
xPosition=0
yPosition=0
-1
View File
@@ -1 +0,0 @@
Hier kommt etwas hinein