Compare commits

..

2 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
51 changed files with 412 additions and 66 deletions
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.
+3 -1
View File
@@ -11,4 +11,6 @@ comment3.params=
comment3.target=void\ act()
comment4.params=
comment4.target=void\ gameEnd()
numComments=5
comment5.params=
comment5.target=void\ lebensAnzeige()
numComments=6
+20 -4
View File
@@ -12,6 +12,8 @@ public class MyWorld extends World
Player2 player2;
int charakterP1;
int charakterP2;
Lebensanzeige l1;
Lebensanzeige l2;
/**
* Constructor for objects of class MyWorld.
*
@@ -20,9 +22,10 @@ public class MyWorld extends World
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
prepare();
charakterP1 = pCharakterP1;
charakterP2 = pCharakterP2;
prepare();
}
/**
@@ -31,10 +34,14 @@ public class MyWorld extends World
*/
private void prepare()
{
player1 = new Player1();
player1 = new Player1(charakterP1);
addObject(player1,125,153);
player2 = new Player2();
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(){
@@ -48,7 +55,12 @@ public class MyWorld extends World
player1.leben = player1.leben -10;
}
}
showText(String.valueOf(player2.leben),300,300);
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();
}
@@ -60,4 +72,8 @@ public class MyWorld extends World
Greenfoot.setWorld(new EndWorld("Player One"));
}
}
public void lebensAnzeige(){
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

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.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

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: 686 B

Binary file not shown.
+2 -2
View File
@@ -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=
+94 -18
View File
@@ -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);
@@ -78,14 +81,24 @@ public class Player1 extends Actor
attackPhase = 1;
attackTimer = System.currentTimeMillis();
if(schautNachRechts){
setImage("1Combo2.png");
GreenfootImage image = getImage();
image.scale(80, 80);
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) {
if (attacking && attackPhase == 1 && System.currentTimeMillis() - attackTimer >= 200) {
if(schautNachRechts){
attackPhase = 2;
setImage("2Combo1.png");
GreenfootImage image = getImage();
image.scale(80, 80);
image.scale(160, 160);
setImage(image);
}
if (attacking && attackPhase == 2 && System.currentTimeMillis() - attackTimer >= 600) {
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;
}
@@ -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);
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);
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(){
if(charakter == 1){
setImage("2Combo1.png");
GreenfootImage image = getImage();
image.scale(80,80);
image.scale(160,160);
setImage(image);
}
}
}
Binary file not shown.
+10 -4
View File
@@ -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
View File
@@ -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();
}
}
}
+41 -17
View File
@@ -1,26 +1,36 @@
#Greenfoot project file
class.MyWorld.image=crumpled-paper.jpg
class.Lebensanzeige.image=Lebensanzeige.png
class.MyWorld.image=IMG_7841.png
class.Player1.image=man01.png
class.Player2.image=man01.png
dependency1.from=StartWorld
dependency1.to=Pfeil
dependency1.from=EndWorld
dependency1.to=StartWorld
dependency1.type=UsesDependency
dependency2.from=StartWorld
dependency2.to=MyWorld
dependency2.to=Pfeil
dependency2.type=UsesDependency
dependency3.from=MyWorld
dependency3.to=Player1
dependency3.from=StartWorld
dependency3.to=MyWorld
dependency3.type=UsesDependency
dependency4.from=MyWorld
dependency4.to=Player2
dependency4.to=Player1
dependency4.type=UsesDependency
editor.fx.0.height=737
editor.fx.0.width=814
editor.fx.0.x=168
editor.fx.0.y=39
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=4
package.numTargets=5
package.numDependencies=7
package.numTargets=7
project.charset=UTF-8
publish.hasSource=false
publish.locked=true
@@ -43,33 +53,47 @@ target1.width=120
target1.x=0
target1.y=0
target2.height=70
target2.name=StartWorld
target2.name=EndWorld
target2.showInterface=false
target2.type=ClassTarget
target2.width=120
target2.x=0
target2.y=0
target3.height=70
target3.name=Player2
target3.name=Lebensanzeige
target3.showInterface=false
target3.type=ClassTarget
target3.width=120
target3.x=0
target3.y=0
target4.height=70
target4.name=Player1
target4.name=StartWorld
target4.showInterface=false
target4.type=ClassTarget
target4.width=120
target4.x=0
target4.y=0
target5.height=70
target5.name=MyWorld
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