Bewegung des 1. und 2. Spielers

This commit is contained in:
Max
2026-09-15 09:49:28 +02:00
parent 48b3ce212f
commit a53a0a22c6
13 changed files with 156 additions and 33 deletions
+53
View File
@@ -0,0 +1,53 @@
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 void act()
{
bewegung();
gravitation();
springen();
}
public void bewegung(){
if(Greenfoot.isKeyDown("right")){
setRotation(0);
move(3);
}
if(Greenfoot.isKeyDown("left")){
setRotation(0);
move(-3);
}
}
public void springen(){
if(Greenfoot.isKeyDown("-") && this.getY() > 370 ){
for(int i = 12; i > -12; i--){
setRotation(270);
move(i);
setRotation(0);
Greenfoot.delay(1);
bewegung();
}
}
}
public void gravitation(){
if(this.getY() < 370){
setRotation(90);
move(4);
setRotation(0);
}
}
}