Compare commits

...

5 Commits

Author SHA1 Message Date
Caspar cdc2e107d5 Merge remote-tracking branch 'origin/main'
# Conflicts:
#	SMIMS-Game/project.greenfoot
2026-09-16 11:59:40 +02:00
Caspar 51725cd2b8 SpikedPlattforms3 2026-09-16 11:59:02 +02:00
Caspar cdcb5a5bac Merge remote-tracking branch 'origin/main'
# Conflicts:
#	SMIMS-Game/MyWorld.class
#	SMIMS-Game/MyWorld.java
#	SMIMS-Game/project.greenfoot
2026-09-16 11:54:37 +02:00
Caspar afdeede498 SpikedPlattforms2 2026-09-16 11:48:37 +02:00
Caspar 56b755b3d6 SpikedPlattforms2 2026-09-16 11:48:19 +02:00
19 changed files with 154 additions and 105 deletions
Binary file not shown.
+3 -1
View File
@@ -8,4 +8,6 @@ comment2.target=void\ act()
comment2.text=\r\n\ Act\ -\ do\ whatever\ the\ MovingPlattform\ 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\ bewege()
numComments=4
comment4.params=
comment4.target=void\ bewegeSpielerMit()
numComments=5
+14
View File
@@ -23,6 +23,7 @@ public class MovingPlattform extends Plattform
{
// Add your action code here.
this.bewege();
this.bewegeSpielerMit();
super.act();
}
@@ -34,5 +35,18 @@ public class MovingPlattform extends Plattform
{
speed=speed*(-1);
}
}
public void bewegeSpielerMit()
{
if(this.PlayerOnPlattform())
{
Actor DerSpieler = this.getOneObjectAtOffset(0, -40, Player.class);
if(DerSpieler!=null)
{
DerSpieler.setLocation(DerSpieler.getX()+speed, DerSpieler.getY());
}
}
}
}
Binary file not shown.
+9 -13
View File
@@ -9,9 +9,9 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class MyWorld extends World
{
int PlattformCountdown;
int timer = 300; //Zeit, bevor das erste Projektil auftaucht
int timer = 200; //Zeit, bevor das erste Projektil auftaucht
//kann später noch beliebig angepasst werden
int targetTimer = 1000;
int targetTimer = 100;
/**
* Constructor for objects of class MyWorld.
*
@@ -50,14 +50,6 @@ public class MyWorld extends World
plattform2.setLocation(320,367);
plattform2.setLocation(312,371);
plattform2.setLocation(308,382);
JumpBoostItem jumpBoostItem = new JumpBoostItem();
addObject(jumpBoostItem,312,427);
jumpBoostItem.setLocation(308,304);
player.setLocation(308,354);
player.setLocation(308,320);
player.setLocation(248,337);
player.setLocation(288,346);
player.setLocation(292,337);
}
public void act()
@@ -67,7 +59,7 @@ public class MyWorld extends World
if(PlattformCountdown==0) //Damit in regelmäßigen Abständen auf jeden Fall eine Plattform auftaucht
{
addObject(new Plattform(), Greenfoot.getRandomNumber(400), 5);
PlattformCountdown=100;
PlattformCountdown=50;
}
PlattformCountdown--;
if(Greenfoot.getRandomNumber(100000)>=99800)
@@ -86,6 +78,10 @@ public class MyWorld extends World
{
addObject(new BreakingPlattform(50), Greenfoot.getRandomNumber(400), 6); //Nach Links bewegende Plattform
}
if(Greenfoot.getRandomNumber(100000)>=99750)
{
addObject(new SpikedPlattform(100), Greenfoot.getRandomNumber(400), 6); //Nach Links bewegende Plattform
}
}
@@ -93,7 +89,7 @@ public class MyWorld extends World
if(timer == 0){
Projectile projectile = new Projectile();
addObject(projectile,Greenfoot.getRandomNumber(300)+50,0);
timer = 300; //zeitlicher Abstand
timer = 200; //zeitlicher Abstand
}
else{
timer = timer - 1;
@@ -104,7 +100,7 @@ public class MyWorld extends World
if(targetTimer == 0){
TargetingProjectile targetingProjectile = new TargetingProjectile();
addObject(targetingProjectile, Greenfoot.getRandomNumber(300)+50,0);
targetTimer = 1000;
targetTimer = 100;
}
else{
targetTimer = targetTimer - 1;
Binary file not shown.
+5 -1
View File
@@ -6,4 +6,8 @@ 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
comment3.params=
comment3.target=void\ loescheMich()
comment4.params=
comment4.target=void\ bewege()
numComments=5
+17 -1
View File
@@ -21,10 +21,26 @@ public class Spike extends Actor
public void act()
{
// Add your action code here.
this.setLocation(this.getX(), this.getY()+speed);
if(this.isTouching(Player.class))
{
Greenfoot.setWorld(new GameOverWorld());
}
this.bewege();
}
public void loescheMich()
{
MyWorld theWorld= (MyWorld) this.getWorld();
theWorld.removeObject(this);
}
public void bewege()
{
this.setLocation(this.getX(), this.getY()+speed);
MyWorld theWorld= (MyWorld) this.getWorld();
if(this.getY()>=theWorld.getHeight()-5)
{
this.loescheMich();
}
}
}
Binary file not shown.
+7 -5
View File
@@ -2,10 +2,12 @@
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
comment1.target=SpikedPlattform(int)
comment2.params=
comment2.target=void\ activateSpikes()
comment2.target=void\ act()
comment2.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
comment3.params=
comment3.target=void\ spikeTheSurface()
numComments=4
comment3.target=void\ activateSpikes()
comment4.params=
comment4.target=void\ spikeTheSurface()
numComments=5
+13 -7
View File
@@ -12,11 +12,16 @@ public class SpikedPlattform extends Plattform
boolean spikesActivated=false;
boolean isSpiked=false;
Spike[] hasSpikes= new Spike[5];
public SpikedPlattform(int pSpikeCountdown)
{
SpikeCountdown=pSpikeCountdown;
}
/**
* 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)
public void act()
{
// Add your action code here.
if(this.PlayerOnPlattform() && spikesActivated== false)
@@ -41,6 +46,11 @@ public class SpikedPlattform extends Plattform
public void activateSpikes()
{
spikesActivated=true;
MyWorld theWorld= (MyWorld) this.getWorld();
for(int i=-6; i<7; i++)
{
theWorld.addObject(new UnactiveSpike(2,SpikeCountdown, this ), this.getX()+i* (this.getImage().getWidth()/13), this.getY()-(this.getImage().getHeight()/2));
}
//Sound
//setImage
@@ -49,12 +59,8 @@ public class SpikedPlattform extends Plattform
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
//Soun)
//setImage
}
Binary file not shown.
+10 -4
View File
@@ -1,7 +1,13 @@
#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
comment1.params=pSpeed\ pCoundown\ pPlattform
comment1.target=UnactiveSpike(int,\ int,\ SpikedPlattform)
comment2.params=
comment2.target=void\ act()
comment2.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
comment3.params=
comment3.target=void\ loescheMich()
comment4.params=
comment4.target=void\ bewege()
numComments=5
+40 -1
View File
@@ -8,12 +8,51 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
*/
public class UnactiveSpike extends Actor
{
int countdown;
int speed;
boolean geloescht=false;
public UnactiveSpike(int pSpeed, int pCoundown, SpikedPlattform pPlattform)
{
speed=pSpeed;
countdown=pCoundown;
}
/**
* 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.
this.bewege();
countdown--;
if(countdown==0)
{
MyWorld theWorld= (MyWorld) this.getWorld();
Spike BeispielSpike=new Spike(1);
GreenfootImage SpikeImage= BeispielSpike.getImage();
theWorld.addObject(new Spike(speed), this.getX(), (this.getY()- this.getImage().getHeight()/2)-10); //die Zahl Minus damit ist endlich passt
geloescht=true;
}
if(geloescht)
{
this.loescheMich();
}
}
public void loescheMich()
{
MyWorld theWorld= (MyWorld) this.getWorld();
theWorld.removeObject(this);
}
public void bewege()
{
this.setLocation(this.getX(), this.getY()+speed);
MyWorld theWorld= (MyWorld) this.getWorld();
if(this.getY()>=theWorld.getHeight()-5)
{
geloescht=true;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 751 B

+36 -72
View File
@@ -1,8 +1,6 @@
#Greenfoot project file
class.BreakingPlattform.image=Unbenannt2.png
class.Button.image=button-red.png
class.Enemy.image=bee.png
class.EnemyProjectile.image=yellow-draught.png
class.GameOverWorld.image=GameOverBackground.png
class.Ground.image=weave.jpg
class.JumpBoostItem.image=mushroom.png
@@ -10,7 +8,6 @@ class.MovingPlattform.image=Unbenannt.png
class.MyWorld.image=GameBackground.png
class.Plattform.image=Plattform.png
class.Player.image=ppl2.png
class.PlayerProjectile.image=beeper.png
class.Projectile.image=Projectile1.png
class.Spike.image=Spike.png
class.SpikedPlattform.image=SpikedPlattform.png
@@ -21,77 +18,65 @@ dependency1.from=GameOverWorld
dependency1.to=Button
dependency1.type=UsesDependency
dependency10.from=MyWorld
dependency10.to=Enemy
dependency10.to=BreakingPlattform
dependency10.type=UsesDependency
dependency11.from=MyWorld
dependency11.to=MovingPlattform
dependency11.to=Projectile
dependency11.type=UsesDependency
dependency12.from=MyWorld
dependency12.to=BreakingPlattform
dependency12.to=TargetingProjectile
dependency12.type=UsesDependency
dependency13.from=MyWorld
dependency13.to=Projectile
dependency13.from=Spike
dependency13.to=GameOverWorld
dependency13.type=UsesDependency
dependency14.from=MyWorld
dependency14.to=TargetingProjectile
dependency14.from=Spike
dependency14.to=Player
dependency14.type=UsesDependency
dependency15.from=Spike
dependency15.from=Player
dependency15.to=GameOverWorld
dependency15.type=UsesDependency
dependency16.from=Spike
dependency16.to=Player
dependency16.from=Player
dependency16.to=Plattform
dependency16.type=UsesDependency
dependency17.from=Player
dependency17.to=GameOverWorld
dependency17.to=Projectile
dependency17.type=UsesDependency
dependency18.from=Player
dependency18.to=Plattform
dependency18.from=Plattform
dependency18.to=MyWorld
dependency18.type=UsesDependency
dependency19.from=Player
dependency19.to=PlayerProjectile
dependency19.from=Plattform
dependency19.to=Player
dependency19.type=UsesDependency
dependency2.from=PlayerTestWorld
dependency2.to=Ground
dependency2.type=UsesDependency
dependency20.from=Player
dependency20.to=Projectile
dependency20.from=MovingPlattform
dependency20.to=MyWorld
dependency20.type=UsesDependency
dependency21.from=Player
dependency21.to=Enemy
dependency21.from=SpikedPlattform
dependency21.to=Spike
dependency21.type=UsesDependency
dependency22.from=Plattform
dependency22.to=MyWorld
dependency22.from=SpikedPlattform
dependency22.to=GameOverWorld
dependency22.type=UsesDependency
dependency23.from=Plattform
dependency23.to=Player
dependency23.from=SpikedPlattform
dependency23.to=MyWorld
dependency23.type=UsesDependency
dependency24.from=MovingPlattform
dependency24.to=MyWorld
dependency24.from=TargetingProjectile
dependency24.to=Player
dependency24.type=UsesDependency
dependency25.from=SpikedPlattform
dependency25.to=Spike
dependency25.from=Button
dependency25.to=MyWorld
dependency25.type=UsesDependency
dependency26.from=SpikedPlattform
dependency26.to=GameOverWorld
dependency26.from=PowerUps
dependency26.to=Player
dependency26.type=UsesDependency
dependency27.from=SpikedPlattform
dependency27.to=MyWorld
dependency27.from=JumpBoostItem
dependency27.to=Player
dependency27.type=UsesDependency
dependency28.from=TargetingProjectile
dependency28.to=Player
dependency28.type=UsesDependency
dependency29.from=Button
dependency29.to=MyWorld
dependency29.type=UsesDependency
dependency3.from=PlayerTestWorld
dependency3.to=Player
dependency3.type=UsesDependency
dependency30.from=PowerUps
dependency30.to=Player
dependency30.type=UsesDependency
dependency31.from=JumpBoostItem
dependency31.to=Player
dependency31.type=UsesDependency
dependency4.from=PlayerTestWorld
dependency4.to=JumpBoostItem
dependency4.type=UsesDependency
@@ -108,15 +93,15 @@ dependency8.from=MyWorld
dependency8.to=Plattform
dependency8.type=UsesDependency
dependency9.from=MyWorld
dependency9.to=JumpBoostItem
dependency9.to=MovingPlattform
dependency9.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=31
package.numTargets=21
package.numDependencies=27
package.numTargets=18
project.charset=UTF-8
publish.hasSource=false
publish.locked=true
@@ -188,26 +173,19 @@ target16.width=120
target16.x=0
target16.y=0
target17.height=70
target17.name=EnemyProjectile
target17.name=SpikedPlattform
target17.showInterface=false
target17.type=ClassTarget
target17.width=120
target17.x=0
target17.y=0
target18.height=70
target18.name=Enemy
target18.name=MyWorld
target18.showInterface=false
target18.type=ClassTarget
target18.width=120
target18.x=0
target18.y=0
target19.height=70
target19.name=PlayerProjectile
target19.showInterface=false
target19.type=ClassTarget
target19.width=120
target19.x=0
target19.y=0
target2.height=70
target2.name=Player
target2.showInterface=false
@@ -215,20 +193,6 @@ target2.type=ClassTarget
target2.width=120
target2.x=0
target2.y=0
target20.height=70
target20.name=SpikedPlattform
target20.showInterface=false
target20.type=ClassTarget
target20.width=120
target20.x=0
target20.y=0
target21.height=70
target21.name=MyWorld
target21.showInterface=false
target21.type=ClassTarget
target21.width=120
target21.x=0
target21.y=0
target3.height=70
target3.name=MovingPlattform
target3.showInterface=false