Skip to content
Snippets Groups Projects
Commit d7687076 authored by Simon's avatar Simon
Browse files

platform

parent a6df44cb
Branches
No related tags found
No related merge requests found
.DS_Store 0 → 100644
File added
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* Write a description of class Platform here.
*
......@@ -15,6 +15,39 @@ public class Platform extends Interactables
public void act()
{
disappear();
spawnFaceMask();
}
public void spawnFaceMask(){
if(Greenfoot.getRandomNumber(100) < 5){
spawnItem(new DispoMask());
}
else if(Greenfoot.getRandomNumber(100) < 2){
spawnItem(new DispoMask());
}
}
public void spawnSanitizer(){}
public void spawnToiletPaper(){}
public boolean hasNoItem(){
List<Item> items = getObjectsAtOffset(50, 50, Item.class);
return items.isEmpty();
}
public void spawnItem(Item item){
if(hasNoItem()){
int x = getX();
int y = getY();
getWorld().addObject(item, x, y + 10);
}
}
}
......@@ -27,7 +27,17 @@ public class Welt extends World
public void act() {
scroll();
spawnCoronaVirus();
spawnPlatform();
}
public void spawnPlatform(){
List<Platform> platforms = getObjects(Platform.class);
if(platforms.isEmpty()){
int width = WIDTH-10;
int height = Greenfoot.getRandomNumber(HEIGHT-10);
this.addObject(new Platform(),width, height);
}
}
public void spawnCoronaVirus(){
......
......@@ -4,6 +4,7 @@ class.Crowd.image=Menschenmenge.png
class.DispoMask.image=Maske.png
class.FaceMask.image=Maske.png
class.GasMask.image=gasmaske.png
class.Platform.image=Unbenannt-2.png
class.Player.image=Player1.png
class.Sanitizer.image=sanitizer.png
class.Spit.image=SpitterSpit.png
......@@ -19,12 +20,18 @@ dependency2.type=UsesDependency
dependency3.from=Welt
dependency3.to=Player
dependency3.type=UsesDependency
editor.fx.0.height=0
editor.fx.0.width=0
editor.fx.0.x=0
editor.fx.0.y=0
height=741
package.numDependencies=3
dependency4.from=Platform
dependency4.to=DispoMask
dependency4.type=UsesDependency
dependency5.from=Platform
dependency5.to=Item
dependency5.type=UsesDependency
editor.fx.0.height=739
editor.fx.0.width=816
editor.fx.0.x=407
editor.fx.0.y=25
height=817
package.numDependencies=5
package.numTargets=19
project.charset=UTF-8
publish.hasSource=false
......@@ -69,17 +76,17 @@ target12.width=80
target12.x=0
target12.y=0
target13.height=50
target13.name=Spitter
target13.name=Scroller
target13.showInterface=false
target13.type=ClassTarget
target13.width=80
target13.x=0
target13.y=0
target14.height=50
target14.name=Interactables
target14.name=Spitter
target14.showInterface=false
target14.type=ClassTarget
target14.width=120
target14.width=80
target14.x=0
target14.y=0
target15.height=50
......@@ -90,10 +97,10 @@ target15.width=80
target15.x=0
target15.y=0
target16.height=50
target16.name=Scroller
target16.name=Interactables
target16.showInterface=false
target16.type=ClassTarget
target16.width=80
target16.width=120
target16.x=0
target16.y=0
target17.height=50
......@@ -174,7 +181,7 @@ target9.width=80
target9.x=0
target9.y=0
version=3.0.0
width=1366
width=1440
world.lastInstantiated=Welt
xPosition=0
yPosition=27
yPosition=25
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment