Compare commits
2 Commits
9cef598196
...
e63fc5cadc
| Author | SHA1 | Date | |
|---|---|---|---|
| e63fc5cadc | |||
| d9f0219cf1 |
@@ -1,9 +1,11 @@
|
||||
#BlueJ class context
|
||||
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
|
||||
comment1.params=
|
||||
comment1.target=void\ act()
|
||||
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
|
||||
comment1.params=pBreakingCountdown
|
||||
comment1.target=BreakingPlattform(int)
|
||||
comment2.params=
|
||||
comment2.target=void\ breakPlattform()
|
||||
numComments=3
|
||||
comment2.target=void\ act()
|
||||
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
|
||||
|
||||
@@ -8,25 +8,40 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
||||
*/
|
||||
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
|
||||
* the 'Act' or 'Run' button gets pressed in the environment.
|
||||
*/
|
||||
public void act()
|
||||
{
|
||||
super.act();
|
||||
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()
|
||||
{
|
||||
if(this.PlayerOnPlattform())
|
||||
{
|
||||
|
||||
}
|
||||
//Animation
|
||||
geloescht=true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,17 +22,17 @@ public class MovingPlattform extends Plattform
|
||||
public void act()
|
||||
{
|
||||
// Add your action code here.
|
||||
super.act();
|
||||
this.bewege();
|
||||
super.act();
|
||||
}
|
||||
|
||||
public void bewege()
|
||||
{
|
||||
MyWorld theWorld= (MyWorld) this.getWorld();
|
||||
move(speed);
|
||||
if(this.getX()<5 || this.getX()<=theWorld.getWidth())
|
||||
this.setLocation(this.getX()+speed, this.getY());
|
||||
if(this.getX()<5 || this.getX()>=theWorld.getWidth()-5)
|
||||
{
|
||||
this.loescheMich();
|
||||
speed=speed*(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,7 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
||||
*/
|
||||
public class MyWorld extends World
|
||||
{
|
||||
int timer = 200;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for objects of class MyWorld.
|
||||
*
|
||||
@@ -29,15 +28,4 @@ public class MyWorld extends World
|
||||
Player player = new Player();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
||||
*/
|
||||
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.
|
||||
@@ -15,6 +16,10 @@ public class Plattform extends Actor
|
||||
public void act()
|
||||
{
|
||||
this.scrollNachUnten();
|
||||
if(geloescht)
|
||||
{
|
||||
this.loescheMich();
|
||||
}
|
||||
// Add your action code here.
|
||||
}
|
||||
|
||||
@@ -24,7 +29,7 @@ public class Plattform extends Actor
|
||||
setLocation(this.getX(),this.getY()+2); // Nach unten turnen
|
||||
if(this.getY()>= welt.getHeight()-5 ||this.getY()<=0)
|
||||
{
|
||||
this.loescheMich();
|
||||
geloescht= true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,12 +40,12 @@ public class Plattform extends Actor
|
||||
|
||||
public boolean PlayerOnPlattform()
|
||||
{
|
||||
Actor Spieler= getOneObjectAtOffset(0, 5, Player.class);
|
||||
if(Spieler!= null)
|
||||
Player Spieler= (Player) getOneIntersectingObject(Player.class);
|
||||
if(this.isTouching(Player.class))
|
||||
{
|
||||
if(Spieler.equals(Player.class))
|
||||
if(Spieler.getY()<this.getY()-20)
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -51,5 +56,6 @@ public class Plattform extends Actor
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 167 B |
|
After Width: | Height: | Size: 981 B |
|
After Width: | Height: | Size: 6.9 KiB |
|
After Width: | Height: | Size: 971 B |
|
After Width: | Height: | Size: 610 B |
|
After Width: | Height: | Size: 167 B |
@@ -1,44 +1,25 @@
|
||||
#Greenfoot project file
|
||||
class.Ground.image=weave.jpg
|
||||
class.JumpBoostItem.image=mushroom.png
|
||||
class.Player.image=ppl2.png
|
||||
dependency1.from=PlayerTestWorld
|
||||
dependency1.to=Ground
|
||||
dependency1.type=UsesDependency
|
||||
dependency10.from=MovingPlattform
|
||||
dependency10.to=MyWorld
|
||||
dependency10.type=UsesDependency
|
||||
dependency2.from=PlayerTestWorld
|
||||
dependency2.to=Player
|
||||
dependency2.type=UsesDependency
|
||||
dependency3.from=MyWorld
|
||||
dependency3.to=Player
|
||||
dependency3.type=UsesDependency
|
||||
dependency4.from=MyWorld
|
||||
dependency4.to=Projectile
|
||||
dependency4.from=Player
|
||||
dependency4.to=Ground
|
||||
dependency4.type=UsesDependency
|
||||
dependency5.from=Player
|
||||
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.height=737
|
||||
editor.fx.0.width=814
|
||||
editor.fx.0.x=456
|
||||
editor.fx.0.y=64
|
||||
editor.fx.0.x=360
|
||||
editor.fx.0.y=26
|
||||
height=830
|
||||
package.numDependencies=10
|
||||
package.numTargets=11
|
||||
package.numDependencies=4
|
||||
package.numTargets=4
|
||||
project.charset=UTF-8
|
||||
publish.hasSource=false
|
||||
publish.locked=true
|
||||
@@ -60,76 +41,27 @@ target1.type=ClassTarget
|
||||
target1.width=120
|
||||
target1.x=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.name=MovingPlattform
|
||||
target2.name=Ground
|
||||
target2.showInterface=false
|
||||
target2.type=ClassTarget
|
||||
target2.width=120
|
||||
target2.x=0
|
||||
target2.y=0
|
||||
target3.height=70
|
||||
target3.name=Ground
|
||||
target3.name=PlayerTestWorld
|
||||
target3.showInterface=false
|
||||
target3.type=ClassTarget
|
||||
target3.width=120
|
||||
target3.x=0
|
||||
target3.y=0
|
||||
target4.height=70
|
||||
target4.name=PowerUps
|
||||
target4.name=MyWorld
|
||||
target4.showInterface=false
|
||||
target4.type=ClassTarget
|
||||
target4.width=120
|
||||
target4.x=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
|
||||
width=1550
|
||||
world.lastInstantiated=PlayerTestWorld
|
||||
|
||||