Merge remote-tracking branch 'origin/main'
# Conflicts: # SMIMS-Game/project.greenfoot
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,7 @@
|
|||||||
|
#BlueJ class context
|
||||||
|
comment0.target=Enemy
|
||||||
|
comment1.params=
|
||||||
|
comment1.target=void\ act()
|
||||||
|
comment2.params=
|
||||||
|
comment2.target=void\ shootAtPlayer()
|
||||||
|
numComments=3
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
||||||
|
|
||||||
|
public class Enemy extends Actor
|
||||||
|
{
|
||||||
|
int shootTimer;
|
||||||
|
public void act()
|
||||||
|
{
|
||||||
|
shootAtPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void shootAtPlayer(){
|
||||||
|
shootTimer++;
|
||||||
|
if (shootTimer >= 100){
|
||||||
|
Player player = getWorld().getObjects(Player.class).get(0);
|
||||||
|
EnemyProjectile enemyProjectile = new EnemyProjectile();
|
||||||
|
getWorld().addObject(enemyProjectile, getX(), getY());
|
||||||
|
enemyProjectile.turnTowards(player.getX(), player.getY());
|
||||||
|
shootTimer = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -0,0 +1,9 @@
|
|||||||
|
#BlueJ class context
|
||||||
|
comment0.target=EnemyProjectile
|
||||||
|
comment0.text=\r\n\ Write\ a\ description\ of\ class\ EnemyProjectile\ 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\ EnemyProjectile\ 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=boolean\ isProjectileOnScreen()
|
||||||
|
numComments=3
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a description of class EnemyProjectile here.
|
||||||
|
*
|
||||||
|
* @author (your name)
|
||||||
|
* @version (a version number or a date)
|
||||||
|
*/
|
||||||
|
public class EnemyProjectile extends Projectile
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Act - do whatever the EnemyProjectile wants to do. This method is called whenever
|
||||||
|
* the 'Act' or 'Run' button gets pressed in the environment.
|
||||||
|
*/
|
||||||
|
public void act()
|
||||||
|
{
|
||||||
|
move(10);
|
||||||
|
if (!isProjectileOnScreen()){
|
||||||
|
getWorld().removeObject(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isProjectileOnScreen(){
|
||||||
|
//Check Y-Value
|
||||||
|
if (getY() <= 0 || getY() >= getWorld().getHeight()-1){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//Check X-Value
|
||||||
|
if (getX() <= 0 || getX() >= getWorld().getHeight()-1){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -107,7 +107,8 @@ public class Player extends Actor
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean collision(){
|
public boolean collision(){
|
||||||
if (getIntersectingObjects(Projectile.class).size()>0)
|
if (getIntersectingObjects(Projectile.class).size()>0
|
||||||
|
|| getIntersectingObjects(Enemy.class).size()>0)
|
||||||
{
|
{
|
||||||
Greenfoot.setWorld(new GameOverWorld());
|
Greenfoot.setWorld(new GameOverWorld());
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Binary file not shown.
@@ -5,5 +5,7 @@ comment1.params=
|
|||||||
comment1.target=void\ act()
|
comment1.target=void\ act()
|
||||||
comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ PlayerProjectile\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n
|
comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ PlayerProjectile\ 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=boolean\ isProjectileOnScreen()
|
comment2.target=void\ checkForEnemyCollision()
|
||||||
numComments=3
|
comment3.params=
|
||||||
|
comment3.target=boolean\ isProjectileOnScreen()
|
||||||
|
numComments=4
|
||||||
|
|||||||
@@ -18,6 +18,14 @@ public class PlayerProjectile extends Actor
|
|||||||
if (!isProjectileOnScreen()){
|
if (!isProjectileOnScreen()){
|
||||||
getWorld().removeObject(this);
|
getWorld().removeObject(this);
|
||||||
}
|
}
|
||||||
|
checkForEnemyCollision();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkForEnemyCollision(){
|
||||||
|
if (getOneIntersectingObject(Enemy.class) != null){
|
||||||
|
getWorld().removeObject(getOneIntersectingObject(Enemy.class));
|
||||||
|
getWorld().removeObject(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isProjectileOnScreen(){
|
public boolean isProjectileOnScreen(){
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 269 B |
@@ -1,12 +1,19 @@
|
|||||||
#Greenfoot project file
|
#Greenfoot project file
|
||||||
class.BreakingPlattform.image=Unbenannt2.png
|
class.BreakingPlattform.image=Unbenannt2.png
|
||||||
|
class.Button.image=button-red.png
|
||||||
|
class.GameOverWorld.image=GameOverBackground.png
|
||||||
class.Ground.image=weave.jpg
|
class.Ground.image=weave.jpg
|
||||||
|
class.JumpBoostItem.image=mushroom.png
|
||||||
class.MovingPlattform.image=Unbenannt.png
|
class.MovingPlattform.image=Unbenannt.png
|
||||||
|
class.MyWorld.image=GameBackground.png
|
||||||
class.Plattform.image=Plattform.png
|
class.Plattform.image=Plattform.png
|
||||||
class.Player.image=ppl2.png
|
class.Player.image=ppl2.png
|
||||||
|
class.Projectile.image=Projectile1.png
|
||||||
class.Spike.image=Spike.png
|
class.Spike.image=Spike.png
|
||||||
class.SpikedPlattform.image=SpikedPlattform.png
|
class.SpikedPlattform.image=SpikedPlattform.png
|
||||||
class.UnactiveSpike.image=Spike_Copy.png
|
class.StartWorld.image=StartBackground.png
|
||||||
|
class.TargetingProjectile.image=blue-draught.png
|
||||||
|
class.UnactiveSpike.image=SpikeUnactive.png
|
||||||
dependency1.from=GameOverWorld
|
dependency1.from=GameOverWorld
|
||||||
dependency1.to=Button
|
dependency1.to=Button
|
||||||
dependency1.type=UsesDependency
|
dependency1.type=UsesDependency
|
||||||
@@ -23,74 +30,53 @@ dependency13.from=Spike
|
|||||||
dependency13.to=GameOverWorld
|
dependency13.to=GameOverWorld
|
||||||
dependency13.type=UsesDependency
|
dependency13.type=UsesDependency
|
||||||
dependency14.from=Spike
|
dependency14.from=Spike
|
||||||
dependency14.to=MyWorld
|
dependency14.to=Player
|
||||||
dependency14.type=UsesDependency
|
dependency14.type=UsesDependency
|
||||||
dependency15.from=Spike
|
dependency15.from=Player
|
||||||
dependency15.to=Player
|
dependency15.to=GameOverWorld
|
||||||
dependency15.type=UsesDependency
|
dependency15.type=UsesDependency
|
||||||
dependency16.from=Player
|
dependency16.from=Player
|
||||||
dependency16.to=GameOverWorld
|
dependency16.to=Plattform
|
||||||
dependency16.type=UsesDependency
|
dependency16.type=UsesDependency
|
||||||
dependency17.from=Player
|
dependency17.from=Player
|
||||||
dependency17.to=Plattform
|
dependency17.to=Projectile
|
||||||
dependency17.type=UsesDependency
|
dependency17.type=UsesDependency
|
||||||
dependency18.from=Player
|
dependency18.from=Plattform
|
||||||
dependency18.to=PlayerProjectile
|
dependency18.to=MyWorld
|
||||||
dependency18.type=UsesDependency
|
dependency18.type=UsesDependency
|
||||||
dependency19.from=Player
|
dependency19.from=Plattform
|
||||||
dependency19.to=Projectile
|
dependency19.to=Player
|
||||||
dependency19.type=UsesDependency
|
dependency19.type=UsesDependency
|
||||||
dependency2.from=PlayerTestWorld
|
dependency2.from=PlayerTestWorld
|
||||||
dependency2.to=Ground
|
dependency2.to=Ground
|
||||||
dependency2.type=UsesDependency
|
dependency2.type=UsesDependency
|
||||||
dependency20.from=UnactiveSpike
|
dependency20.from=MovingPlattform
|
||||||
dependency20.to=SpikedPlattform
|
dependency20.to=MyWorld
|
||||||
dependency20.type=UsesDependency
|
dependency20.type=UsesDependency
|
||||||
dependency21.from=UnactiveSpike
|
dependency21.from=SpikedPlattform
|
||||||
dependency21.to=MyWorld
|
dependency21.to=Spike
|
||||||
dependency21.type=UsesDependency
|
dependency21.type=UsesDependency
|
||||||
dependency22.from=UnactiveSpike
|
dependency22.from=SpikedPlattform
|
||||||
dependency22.to=Spike
|
dependency22.to=GameOverWorld
|
||||||
dependency22.type=UsesDependency
|
dependency22.type=UsesDependency
|
||||||
dependency23.from=Plattform
|
dependency23.from=SpikedPlattform
|
||||||
dependency23.to=MyWorld
|
dependency23.to=MyWorld
|
||||||
dependency23.type=UsesDependency
|
dependency23.type=UsesDependency
|
||||||
dependency24.from=Plattform
|
dependency24.from=TargetingProjectile
|
||||||
dependency24.to=Player
|
dependency24.to=Player
|
||||||
dependency24.type=UsesDependency
|
dependency24.type=UsesDependency
|
||||||
dependency25.from=MovingPlattform
|
dependency25.from=Button
|
||||||
dependency25.to=MyWorld
|
dependency25.to=MyWorld
|
||||||
dependency25.type=UsesDependency
|
dependency25.type=UsesDependency
|
||||||
dependency26.from=MovingPlattform
|
dependency26.from=PowerUps
|
||||||
dependency26.to=Player
|
dependency26.to=Player
|
||||||
dependency26.type=UsesDependency
|
dependency26.type=UsesDependency
|
||||||
dependency27.from=SpikedPlattform
|
dependency27.from=JumpBoostItem
|
||||||
dependency27.to=Spike
|
dependency27.to=Player
|
||||||
dependency27.type=UsesDependency
|
dependency27.type=UsesDependency
|
||||||
dependency28.from=SpikedPlattform
|
|
||||||
dependency28.to=GameOverWorld
|
|
||||||
dependency28.type=UsesDependency
|
|
||||||
dependency29.from=SpikedPlattform
|
|
||||||
dependency29.to=MyWorld
|
|
||||||
dependency29.type=UsesDependency
|
|
||||||
dependency3.from=PlayerTestWorld
|
dependency3.from=PlayerTestWorld
|
||||||
dependency3.to=Player
|
dependency3.to=Player
|
||||||
dependency3.type=UsesDependency
|
dependency3.type=UsesDependency
|
||||||
dependency30.from=SpikedPlattform
|
|
||||||
dependency30.to=UnactiveSpike
|
|
||||||
dependency30.type=UsesDependency
|
|
||||||
dependency31.from=TargetingProjectile
|
|
||||||
dependency31.to=Player
|
|
||||||
dependency31.type=UsesDependency
|
|
||||||
dependency32.from=Button
|
|
||||||
dependency32.to=MyWorld
|
|
||||||
dependency32.type=UsesDependency
|
|
||||||
dependency33.from=PowerUps
|
|
||||||
dependency33.to=Player
|
|
||||||
dependency33.type=UsesDependency
|
|
||||||
dependency34.from=JumpBoostItem
|
|
||||||
dependency34.to=Player
|
|
||||||
dependency34.type=UsesDependency
|
|
||||||
dependency4.from=PlayerTestWorld
|
dependency4.from=PlayerTestWorld
|
||||||
dependency4.to=JumpBoostItem
|
dependency4.to=JumpBoostItem
|
||||||
dependency4.type=UsesDependency
|
dependency4.type=UsesDependency
|
||||||
@@ -109,13 +95,13 @@ dependency8.type=UsesDependency
|
|||||||
dependency9.from=MyWorld
|
dependency9.from=MyWorld
|
||||||
dependency9.to=MovingPlattform
|
dependency9.to=MovingPlattform
|
||||||
dependency9.type=UsesDependency
|
dependency9.type=UsesDependency
|
||||||
editor.fx.0.height=0
|
editor.fx.0.height=737
|
||||||
editor.fx.0.width=0
|
editor.fx.0.width=814
|
||||||
editor.fx.0.x=0
|
editor.fx.0.x=360
|
||||||
editor.fx.0.y=0
|
editor.fx.0.y=26
|
||||||
height=736
|
height=830
|
||||||
package.numDependencies=34
|
package.numDependencies=27
|
||||||
package.numTargets=19
|
package.numTargets=18
|
||||||
project.charset=UTF-8
|
project.charset=UTF-8
|
||||||
publish.hasSource=false
|
publish.hasSource=false
|
||||||
publish.locked=true
|
publish.locked=true
|
||||||
@@ -187,26 +173,19 @@ target16.width=120
|
|||||||
target16.x=0
|
target16.x=0
|
||||||
target16.y=0
|
target16.y=0
|
||||||
target17.height=70
|
target17.height=70
|
||||||
target17.name=PlayerProjectile
|
target17.name=SpikedPlattform
|
||||||
target17.showInterface=false
|
target17.showInterface=false
|
||||||
target17.type=ClassTarget
|
target17.type=ClassTarget
|
||||||
target17.width=120
|
target17.width=120
|
||||||
target17.x=0
|
target17.x=0
|
||||||
target17.y=0
|
target17.y=0
|
||||||
target18.height=70
|
target18.height=70
|
||||||
target18.name=SpikedPlattform
|
target18.name=MyWorld
|
||||||
target18.showInterface=false
|
target18.showInterface=false
|
||||||
target18.type=ClassTarget
|
target18.type=ClassTarget
|
||||||
target18.width=120
|
target18.width=120
|
||||||
target18.x=0
|
target18.x=0
|
||||||
target18.y=0
|
target18.y=0
|
||||||
target19.height=70
|
|
||||||
target19.name=MyWorld
|
|
||||||
target19.showInterface=false
|
|
||||||
target19.type=ClassTarget
|
|
||||||
target19.width=120
|
|
||||||
target19.x=0
|
|
||||||
target19.y=0
|
|
||||||
target2.height=70
|
target2.height=70
|
||||||
target2.name=Player
|
target2.name=Player
|
||||||
target2.showInterface=false
|
target2.showInterface=false
|
||||||
@@ -264,7 +243,7 @@ target9.width=120
|
|||||||
target9.x=0
|
target9.x=0
|
||||||
target9.y=0
|
target9.y=0
|
||||||
version=3.1.0
|
version=3.1.0
|
||||||
width=856
|
width=1550
|
||||||
world.lastInstantiated=StartWorld
|
world.lastInstantiated=MyWorld
|
||||||
xPosition=481
|
xPosition=0
|
||||||
yPosition=94
|
yPosition=0
|
||||||
|
|||||||
Reference in New Issue
Block a user