Files
SMIMS_2026_1/fighter/player2.java
T
2026-09-15 19:13:35 +02:00

76 lines
1.6 KiB
Java

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;
Player2(){
leben = 100;
}
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 boolean attacke(){
if(Greenfoot.isKeyDown("e")){
if(System.currentTimeMillis() >= c){
c = System.currentTimeMillis() + 2000;
return true;
}
else{
return false;
}
}
else{
return false;
}
}
public void gravitation(){
if(this.getY() < 370){
setRotation(90);
move(4);
setRotation(0);
}
}
}