SpikedPlattforms1

This commit is contained in:
2026-09-15 20:24:24 +02:00
parent 086274bc82
commit 8eeb32af40
18 changed files with 280 additions and 19 deletions
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
#BlueJ class context
comment0.target=Spike
comment0.text=\r\n\ Write\ a\ description\ of\ class\ Spike\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=pSpeed
comment1.target=Spike(int)
comment2.params=
comment2.target=void\ act()
comment2.text=\r\n\ Act\ -\ do\ whatever\ the\ Spike\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n
numComments=3
+30
View File
@@ -0,0 +1,30 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Spike here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Spike extends Actor
{
int speed;
public Spike(int pSpeed)
{
speed=pSpeed;
}
/**
* Act - do whatever the Spike wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
this.setLocation(this.getX(), this.getY()+speed);
if(this.isTouching(Player.class))
{
Greenfoot.setWorld(new GameOverWorld());
}
}
}
Binary file not shown.
+11
View File
@@ -0,0 +1,11 @@
#BlueJ class context
comment0.target=SpikedPlattform
comment0.text=\r\n\ Write\ a\ description\ of\ class\ SpikedPlattform\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=pSpikeCountdown
comment1.target=void\ act(int)
comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ SpikedPlattform\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n
comment2.params=
comment2.target=void\ activateSpikes()
comment3.params=
comment3.target=void\ spikeTheSurface()
numComments=4
+61
View File
@@ -0,0 +1,61 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class SpikedPlattform here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class SpikedPlattform extends Plattform
{
int SpikeCountdown;
boolean spikesActivated=false;
boolean isSpiked=false;
Spike[] hasSpikes= new Spike[5];
/**
* Act - do whatever the SpikedPlattform wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act(int pSpikeCountdown)
{
// Add your action code here.
if(this.PlayerOnPlattform() && spikesActivated== false)
{
this.activateSpikes();
}
if(spikesActivated)
{
SpikeCountdown--;
}
if(SpikeCountdown==0)
{
this.spikeTheSurface();
}
if(isSpiked && this.PlayerOnPlattform())
{
Greenfoot.setWorld(new GameOverWorld());
}
super.act();
}
public void activateSpikes()
{
spikesActivated=true;
//Sound
//setImage
}
public void spikeTheSurface()
{
isSpiked=true;
MyWorld theWorld= (MyWorld) this.getWorld();
for(int i=0; i<3; i++)
{
theWorld.addObject(new Spike(2), this.getX()-this.getImage().getWidth()+ i*this.getImage().getWidth()/3, this.getX()-this.getImage().getHeight()/2);
}
//Sound
//setImage
}
}
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
#BlueJ class context
comment0.target=UnactiveSpike
comment0.text=\r\n\ Write\ a\ description\ of\ class\ UnactiveSpike\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=
comment1.target=void\ act()
comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ UnactiveSpike\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n
numComments=2
+19
View File
@@ -0,0 +1,19 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class UnactiveSpike here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class UnactiveSpike extends Actor
{
/**
* Act - do whatever the UnactiveSpike wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 981 B

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 971 B

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 610 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

+143 -19
View File
@@ -1,25 +1,79 @@
#Greenfoot project file
class.BreakingPlattform.image=Unbenannt2.png
class.Ground.image=weave.jpg
class.MovingPlattform.image=Unbenannt.png
class.Plattform.image=Plattform.png
class.Player.image=ppl2.png
class.Spike.image=Spike.png
class.SpikedPlattform.image=Unbenannt.png
class.UnactiveSpike.image=SpikeUnactive.png
dependency1.from=PlayerTestWorld
dependency1.to=Ground
dependency1.type=UsesDependency
dependency10.from=Player
dependency10.to=GameOverWorld
dependency10.type=UsesDependency
dependency11.from=Player
dependency11.to=Ground
dependency11.type=UsesDependency
dependency12.from=Player
dependency12.to=Projectile
dependency12.type=UsesDependency
dependency13.from=Plattform
dependency13.to=MyWorld
dependency13.type=UsesDependency
dependency14.from=Plattform
dependency14.to=Player
dependency14.type=UsesDependency
dependency15.from=MovingPlattform
dependency15.to=MyWorld
dependency15.type=UsesDependency
dependency16.from=SpikedPlattform
dependency16.to=Spike
dependency16.type=UsesDependency
dependency17.from=SpikedPlattform
dependency17.to=GameOverWorld
dependency17.type=UsesDependency
dependency18.from=SpikedPlattform
dependency18.to=MyWorld
dependency18.type=UsesDependency
dependency19.from=PowerUps
dependency19.to=Player
dependency19.type=UsesDependency
dependency2.from=PlayerTestWorld
dependency2.to=Player
dependency2.type=UsesDependency
dependency3.from=MyWorld
dependency3.to=Player
dependency20.from=JumpBoostItem
dependency20.to=Player
dependency20.type=UsesDependency
dependency3.from=PlayerTestWorld
dependency3.to=JumpBoostItem
dependency3.type=UsesDependency
dependency4.from=Player
dependency4.to=Ground
dependency4.from=MyWorld
dependency4.to=Player
dependency4.type=UsesDependency
editor.fx.0.height=737
editor.fx.0.width=814
editor.fx.0.x=360
editor.fx.0.y=26
height=830
package.numDependencies=4
package.numTargets=4
dependency5.from=MyWorld
dependency5.to=Plattform
dependency5.type=UsesDependency
dependency6.from=MyWorld
dependency6.to=MovingPlattform
dependency6.type=UsesDependency
dependency7.from=MyWorld
dependency7.to=BreakingPlattform
dependency7.type=UsesDependency
dependency8.from=Spike
dependency8.to=GameOverWorld
dependency8.type=UsesDependency
dependency9.from=Spike
dependency9.to=Player
dependency9.type=UsesDependency
editor.fx.0.height=810
editor.fx.0.width=816
editor.fx.0.x=647
editor.fx.0.y=172
height=736
package.numDependencies=20
package.numTargets=14
project.charset=UTF-8
publish.hasSource=false
publish.locked=true
@@ -35,35 +89,105 @@ readme.x=10
readme.y=10
simulation.speed=50
target1.height=70
target1.name=Player
target1.name=Spike
target1.showInterface=false
target1.type=ClassTarget
target1.width=120
target1.x=0
target1.y=0
target10.height=70
target10.name=Plattform
target10.showInterface=false
target10.type=ClassTarget
target10.width=120
target10.x=0
target10.y=0
target11.height=70
target11.name=Projectile
target11.showInterface=false
target11.type=ClassTarget
target11.width=120
target11.x=0
target11.y=0
target12.height=70
target12.name=PowerUps
target12.showInterface=false
target12.type=ClassTarget
target12.width=120
target12.x=0
target12.y=0
target13.height=70
target13.name=SpikedPlattform
target13.showInterface=false
target13.type=ClassTarget
target13.width=120
target13.x=0
target13.y=0
target14.height=70
target14.name=MyWorld
target14.showInterface=false
target14.type=ClassTarget
target14.width=120
target14.x=0
target14.y=0
target2.height=70
target2.name=Ground
target2.name=Player
target2.showInterface=false
target2.type=ClassTarget
target2.width=120
target2.x=0
target2.y=0
target3.height=70
target3.name=PlayerTestWorld
target3.name=MovingPlattform
target3.showInterface=false
target3.type=ClassTarget
target3.width=120
target3.x=0
target3.y=0
target4.height=70
target4.name=MyWorld
target4.name=Ground
target4.showInterface=false
target4.type=ClassTarget
target4.width=120
target4.x=0
target4.y=0
target5.height=70
target5.name=UnactiveSpike
target5.showInterface=false
target5.type=ClassTarget
target5.width=120
target5.x=0
target5.y=0
target6.height=70
target6.name=JumpBoostItem
target6.showInterface=false
target6.type=ClassTarget
target6.width=120
target6.x=0
target6.y=0
target7.height=70
target7.name=BreakingPlattform
target7.showInterface=false
target7.type=ClassTarget
target7.width=120
target7.x=0
target7.y=0
target8.height=70
target8.name=GameOverWorld
target8.showInterface=false
target8.type=ClassTarget
target8.width=120
target8.x=0
target8.y=0
target9.height=70
target9.name=PlayerTestWorld
target9.showInterface=false
target9.type=ClassTarget
target9.width=120
target9.x=0
target9.y=0
version=3.1.0
width=1550
world.lastInstantiated=PlayerTestWorld
xPosition=0
yPosition=0
width=856
world.lastInstantiated=MyWorld
xPosition=418
yPosition=223