Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eae3e92d60 | |||
| 963fa43986 |
Binary file not shown.
@@ -8,7 +8,7 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
|||||||
*/
|
*/
|
||||||
public class JumpBoostItem extends PowerUps
|
public class JumpBoostItem extends PowerUps
|
||||||
{
|
{
|
||||||
int duration = 60*30;
|
int duration = 60*60;
|
||||||
public void act()
|
public void act()
|
||||||
{
|
{
|
||||||
touchedByPlayer();
|
touchedByPlayer();
|
||||||
|
|||||||
Binary file not shown.
@@ -10,9 +10,11 @@ comment3.target=void\ jump()
|
|||||||
comment4.params=
|
comment4.params=
|
||||||
comment4.target=void\ fall()
|
comment4.target=void\ fall()
|
||||||
comment5.params=
|
comment5.params=
|
||||||
comment5.target=boolean\ collision()
|
comment5.target=void\ shootProjectile()
|
||||||
comment6.params=
|
comment6.params=
|
||||||
comment6.target=void\ handlePowerUps()
|
comment6.target=boolean\ collision()
|
||||||
comment7.params=duration\ type
|
comment7.params=
|
||||||
comment7.target=void\ reveivePowerUp(int,\ java.lang.String)
|
comment7.target=void\ handlePowerUps()
|
||||||
numComments=8
|
comment8.params=duration\ type
|
||||||
|
comment8.target=void\ reveivePowerUp(int,\ java.lang.String)
|
||||||
|
numComments=9
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ public class Player extends Actor
|
|||||||
int jumpBoostDuration = -1;
|
int jumpBoostDuration = -1;
|
||||||
int jumpBoostStrength = 5;
|
int jumpBoostStrength = 5;
|
||||||
|
|
||||||
|
boolean projectileReady = false;
|
||||||
|
int projectileTimer;
|
||||||
|
|
||||||
private int speed = 6;
|
private int speed = 6;
|
||||||
private int currentJumpStrength;
|
private int currentJumpStrength;
|
||||||
@@ -27,6 +29,7 @@ public class Player extends Actor
|
|||||||
jump();
|
jump();
|
||||||
fall();
|
fall();
|
||||||
handlePowerUps();
|
handlePowerUps();
|
||||||
|
shootProjectile();
|
||||||
|
|
||||||
//Check ob der Spieler am unteren Fensterrand ist
|
//Check ob der Spieler am unteren Fensterrand ist
|
||||||
if (getY()+1 >= getWorld().getHeight()){
|
if (getY()+1 >= getWorld().getHeight()){
|
||||||
@@ -87,6 +90,21 @@ public class Player extends Actor
|
|||||||
}
|
}
|
||||||
onGround = landed;
|
onGround = landed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void shootProjectile(){
|
||||||
|
projectileTimer++;
|
||||||
|
MouseInfo mouse = Greenfoot.getMouseInfo();
|
||||||
|
if (Greenfoot.mousePressed(null)){
|
||||||
|
PlayerProjectile playerProjectile = new PlayerProjectile();
|
||||||
|
getWorld().addObject(playerProjectile, getX(), getY());
|
||||||
|
playerProjectile.turnTowards(Greenfoot.getMouseInfo().getX(), Greenfoot.getMouseInfo().getY());
|
||||||
|
projectileReady = false;
|
||||||
|
}
|
||||||
|
if (projectileTimer >= 10){
|
||||||
|
projectileReady = true;
|
||||||
|
projectileTimer = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean collision(){
|
public boolean collision(){
|
||||||
if (getIntersectingObjects(Projectile.class).size()>0)
|
if (getIntersectingObjects(Projectile.class).size()>0)
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,9 @@
|
|||||||
|
#BlueJ class context
|
||||||
|
comment0.target=PlayerProjectile
|
||||||
|
comment0.text=\r\n\ Write\ a\ description\ of\ class\ PlayerProjectile\ 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\ 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.target=boolean\ isProjectileOnScreen()
|
||||||
|
numComments=3
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a description of class PlayerProjectile here.
|
||||||
|
*
|
||||||
|
* @author (your name)
|
||||||
|
* @version (a version number or a date)
|
||||||
|
*/
|
||||||
|
public class PlayerProjectile extends Actor
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Act - do whatever the PlayerProjectile wants to do. This method is called whenever
|
||||||
|
* the 'Act' or 'Run' button gets pressed in the environment.
|
||||||
|
*/
|
||||||
|
public void act()
|
||||||
|
{
|
||||||
|
move(7);
|
||||||
|
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.
|
After Width: | Height: | Size: 776 B |
Reference in New Issue
Block a user