Bewegung des 1. und 2. Spielers
This commit is contained in:
@@ -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 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 void act()
|
||||
{
|
||||
bewegung();
|
||||
gravitation();
|
||||
springen();
|
||||
}
|
||||
|
||||
public void bewegung(){
|
||||
if(Greenfoot.isKeyDown("d")){
|
||||
setRotation(0);
|
||||
move(3);
|
||||
}
|
||||
if(Greenfoot.isKeyDown("a")){
|
||||
setRotation(0);
|
||||
move(-3);
|
||||
}
|
||||
}
|
||||
|
||||
public void springen(){
|
||||
if(Greenfoot.isKeyDown("space") && 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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user