Compare commits

..

2 Commits

Author SHA1 Message Date
Caspar e63fc5cadc Merge remote-tracking branch 'origin/main'
# Conflicts:
#	SMIMS-Game/MyWorld.class
#	SMIMS-Game/MyWorld.java
#	SMIMS-Game/project.greenfoot
2026-09-15 11:55:52 +02:00
Caspar d9f0219cf1 Plattform Verssion 1 2026-09-15 11:53:27 +02:00
16 changed files with 55 additions and 112 deletions
Binary file not shown.
+7 -5
View File
@@ -1,9 +1,11 @@
#BlueJ class context #BlueJ class context
comment0.target=BreakingPlattform comment0.target=BreakingPlattform
comment0.text=\r\n\ Write\ a\ description\ of\ class\ BreakingPlattform\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n comment0.text=\r\n\ Write\ a\ description\ of\ class\ BreakingPlattform\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params= comment1.params=pBreakingCountdown
comment1.target=void\ act() comment1.target=BreakingPlattform(int)
comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ BreakingPlattform\ 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.params=
comment2.target=void\ breakPlattform() comment2.target=void\ act()
numComments=3 comment2.text=\r\n\ Act\ -\ do\ whatever\ the\ BreakingPlattform\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n
comment3.params=
comment3.target=void\ breakPlattform()
numComments=4
+20 -5
View File
@@ -9,24 +9,39 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class BreakingPlattform extends Plattform public class BreakingPlattform extends Plattform
{ {
boolean IsBreaking= false; boolean IsBreaking= false;
int BreakingCountdown;
public BreakingPlattform(int pBreakingCountdown)
{
BreakingCountdown=pBreakingCountdown;
}
/** /**
* Act - do whatever the BreakingPlattform wants to do. This method is called whenever * Act - do whatever the BreakingPlattform wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment. * the 'Act' or 'Run' button gets pressed in the environment.
*/ */
public void act() public void act()
{ {
super.act();
if(this.PlayerOnPlattform() && IsBreaking==false) if(this.PlayerOnPlattform() && IsBreaking==false)
{ {
IsBreaking= true; IsBreaking= true;
//Greenfoot.playSound("...")
this.setImage("BreakingPlattform2.png"); //untested
} }
if(IsBreaking)
{
BreakingCountdown--;
if(BreakingCountdown==0)
{
this.breakPlattform();
}
}
super.act();
} }
public void breakPlattform() public void breakPlattform()
{ {
if(this.PlayerOnPlattform()) //Animation
{ geloescht=true;
}
} }
} }
Binary file not shown.
+4 -4
View File
@@ -22,17 +22,17 @@ public class MovingPlattform extends Plattform
public void act() public void act()
{ {
// Add your action code here. // Add your action code here.
super.act();
this.bewege(); this.bewege();
super.act();
} }
public void bewege() public void bewege()
{ {
MyWorld theWorld= (MyWorld) this.getWorld(); MyWorld theWorld= (MyWorld) this.getWorld();
move(speed); this.setLocation(this.getX()+speed, this.getY());
if(this.getX()<5 || this.getX()<=theWorld.getWidth()) if(this.getX()<5 || this.getX()>=theWorld.getWidth()-5)
{ {
this.loescheMich(); speed=speed*(-1);
} }
} }
} }
-12
View File
@@ -8,7 +8,6 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
*/ */
public class MyWorld extends World public class MyWorld extends World
{ {
int timer = 200;
/** /**
* Constructor for objects of class MyWorld. * Constructor for objects of class MyWorld.
@@ -29,15 +28,4 @@ public class MyWorld extends World
Player player = new Player(); Player player = new Player();
addObject(player,302,320); addObject(player,302,320);
} }
public void act(){
if(timer > 0){
timer = timer - 1;
}
else{
Projectile projectile = new Projectile();
addObject(projectile,Greenfoot.getRandomNumber(300)+50,0);
timer = 200;
}
}
} }
Binary file not shown.
+10 -4
View File
@@ -8,6 +8,7 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
*/ */
public class Plattform extends Actor public class Plattform extends Actor
{ {
boolean geloescht= false;
/** /**
* Act - do whatever the Plattform wants to do. This method is called whenever * Act - do whatever the Plattform wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment. * the 'Act' or 'Run' button gets pressed in the environment.
@@ -15,6 +16,10 @@ public class Plattform extends Actor
public void act() public void act()
{ {
this.scrollNachUnten(); this.scrollNachUnten();
if(geloescht)
{
this.loescheMich();
}
// Add your action code here. // Add your action code here.
} }
@@ -24,7 +29,7 @@ public class Plattform extends Actor
setLocation(this.getX(),this.getY()+2); // Nach unten turnen setLocation(this.getX(),this.getY()+2); // Nach unten turnen
if(this.getY()>= welt.getHeight()-5 ||this.getY()<=0) if(this.getY()>= welt.getHeight()-5 ||this.getY()<=0)
{ {
this.loescheMich(); geloescht= true;
} }
} }
@@ -35,10 +40,10 @@ public class Plattform extends Actor
public boolean PlayerOnPlattform() public boolean PlayerOnPlattform()
{ {
Actor Spieler= getOneObjectAtOffset(0, 5, Player.class); Player Spieler= (Player) getOneIntersectingObject(Player.class);
if(Spieler!= null) if(this.isTouching(Player.class))
{ {
if(Spieler.equals(Player.class)) if(Spieler.getY()<this.getY()-20)
{ {
return true; return true;
} }
@@ -51,5 +56,6 @@ public class Plattform extends Actor
{ {
return false; return false;
} }
} }
} }
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 981 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 971 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

+10 -78
View File
@@ -1,44 +1,25 @@
#Greenfoot project file #Greenfoot project file
class.Ground.image=weave.jpg class.Ground.image=weave.jpg
class.JumpBoostItem.image=mushroom.png
class.Player.image=ppl2.png class.Player.image=ppl2.png
dependency1.from=PlayerTestWorld dependency1.from=PlayerTestWorld
dependency1.to=Ground dependency1.to=Ground
dependency1.type=UsesDependency dependency1.type=UsesDependency
dependency10.from=MovingPlattform
dependency10.to=MyWorld
dependency10.type=UsesDependency
dependency2.from=PlayerTestWorld dependency2.from=PlayerTestWorld
dependency2.to=Player dependency2.to=Player
dependency2.type=UsesDependency dependency2.type=UsesDependency
dependency3.from=MyWorld dependency3.from=MyWorld
dependency3.to=Player dependency3.to=Player
dependency3.type=UsesDependency dependency3.type=UsesDependency
dependency4.from=MyWorld dependency4.from=Player
dependency4.to=Projectile dependency4.to=Ground
dependency4.type=UsesDependency dependency4.type=UsesDependency
dependency5.from=Player editor.fx.0.height=737
dependency5.to=GameOverWorld
dependency5.type=UsesDependency
dependency6.from=Player
dependency6.to=Ground
dependency6.type=UsesDependency
dependency7.from=Player
dependency7.to=Projectile
dependency7.type=UsesDependency
dependency8.from=Plattform
dependency8.to=MyWorld
dependency8.type=UsesDependency
dependency9.from=Plattform
dependency9.to=Player
dependency9.type=UsesDependency
editor.fx.0.height=672
editor.fx.0.width=814 editor.fx.0.width=814
editor.fx.0.x=456 editor.fx.0.x=360
editor.fx.0.y=64 editor.fx.0.y=26
height=830 height=830
package.numDependencies=10 package.numDependencies=4
package.numTargets=11 package.numTargets=4
project.charset=UTF-8 project.charset=UTF-8
publish.hasSource=false publish.hasSource=false
publish.locked=true publish.locked=true
@@ -60,76 +41,27 @@ target1.type=ClassTarget
target1.width=120 target1.width=120
target1.x=0 target1.x=0
target1.y=0 target1.y=0
target10.height=70
target10.name=MyWorld
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
target2.height=70 target2.height=70
target2.name=MovingPlattform target2.name=Ground
target2.showInterface=false target2.showInterface=false
target2.type=ClassTarget target2.type=ClassTarget
target2.width=120 target2.width=120
target2.x=0 target2.x=0
target2.y=0 target2.y=0
target3.height=70 target3.height=70
target3.name=Ground target3.name=PlayerTestWorld
target3.showInterface=false target3.showInterface=false
target3.type=ClassTarget target3.type=ClassTarget
target3.width=120 target3.width=120
target3.x=0 target3.x=0
target3.y=0 target3.y=0
target4.height=70 target4.height=70
target4.name=PowerUps target4.name=MyWorld
target4.showInterface=false target4.showInterface=false
target4.type=ClassTarget target4.type=ClassTarget
target4.width=120 target4.width=120
target4.x=0 target4.x=0
target4.y=0 target4.y=0
target5.height=70
target5.name=JumpBoostItem
target5.showInterface=false
target5.type=ClassTarget
target5.width=120
target5.x=0
target5.y=0
target6.height=70
target6.name=BreakingPlattform
target6.showInterface=false
target6.type=ClassTarget
target6.width=120
target6.x=0
target6.y=0
target7.height=70
target7.name=GameOverWorld
target7.showInterface=false
target7.type=ClassTarget
target7.width=120
target7.x=0
target7.y=0
target8.height=70
target8.name=PlayerTestWorld
target8.showInterface=false
target8.type=ClassTarget
target8.width=120
target8.x=0
target8.y=0
target9.height=70
target9.name=Plattform
target9.showInterface=false
target9.type=ClassTarget
target9.width=120
target9.x=0
target9.y=0
version=3.1.0 version=3.1.0
width=1550 width=1550
world.lastInstantiated=PlayerTestWorld world.lastInstantiated=PlayerTestWorld