Files
SMIMS_2026_2/SMIMS-Game/Plattform.java
T
2026-09-17 09:24:04 +02:00

62 lines
1.4 KiB
Java

import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Plattform here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Plattform extends Actor
{
boolean geloescht= false;
/**
* Act - do whatever the Plattform wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
this.scrollNachUnten();
if(geloescht)
{
this.loescheMich();
}
// Add your action code here.
}
public void scrollNachUnten()
{
MyWorld welt= (MyWorld) getWorld();
setLocation(this.getX(),this.getY()+2); // Nach unten turnen
if(this.getY()>= welt.getHeight()-5 ||this.getY()<=0)
{
geloescht= true;
}
}
public void loescheMich()
{
getWorld().removeObject(this);
}
public boolean PlayerOnPlattform()
{
Player Spieler= (Player) getOneIntersectingObject(Player.class);
if(this.isTouching(Player.class))
{
if(Spieler.getY()<this.getY()-39)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
}