Der Spieler kann nun Projectile schießen

This commit is contained in:
2026-09-16 10:40:42 +02:00
parent 8fad77b878
commit 963fa43986
9 changed files with 69 additions and 6 deletions
+34
View File
@@ -0,0 +1,34 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class PlayerProjectile here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class PlayerProjectile extends Actor
{
/**
* Act - do whatever the PlayerProjectile wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(7);
if (!isProjectileOnScreen()){
getWorld().removeObject(this);
}
}
public boolean isProjectileOnScreen(){
//Check Y-Value
if (getY() <= 0 || getY() >= getWorld().getHeight()-1){
return false;
}
//Check X-Value
if (getX() <= 0 || getX() >= getWorld().getHeight()-1){
return false;
}
return true;
}
}