Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Banik1103 authored May 22, 2022
1 parent 2e83d56 commit a2a827d
Show file tree
Hide file tree
Showing 100 changed files with 631 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Moon.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#BlueJ class context
comment0.target=Moon
comment1.params=
comment1.target=void\ act()
numComments=2
26 changes: 26 additions & 0 deletions Moon.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import greenfoot.*;


public class Moon extends Actor
{
int a = 3;
public void act()
{
setLocation(getX() + a, getY());

if(isAtEdge()){
a = a * -1;
setLocation(getX() - a * 5, getY());
}

if(isTouching(PlayerProjectile.class)){
getWorld().removeObject(getOneIntersectingObject(PlayerProjectile.class));
getWorld().addObject(new Bomb(), getX(), getY() + 4);
}

if(Greenfoot.getRandomNumber(500)==1){
getWorld().addObject(new Bomb(), getX(), getY() + 4);

}
}
}
Binary file added Player.class
Binary file not shown.
29 changes: 29 additions & 0 deletions Player.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#BlueJ class context
comment0.target=Player
comment1.params=
comment1.target=void\ Player()
comment10.params=i
comment10.target=void\ setPower(int)
comment11.params=
comment11.target=int\ getPower()
comment12.params=
comment12.target=int\ getDiff()
comment13.params=
comment13.target=void\ setDiff()
comment2.params=
comment2.target=void\ act()
comment3.params=
comment3.target=void\ move()
comment4.params=
comment4.target=void\ shoot()
comment5.params=
comment5.target=void\ dying()
comment6.params=
comment6.target=void\ bePower()
comment7.params=
comment7.target=int\ getScore()
comment8.params=s
comment8.target=void\ setScore(int)
comment9.params=
comment9.target=int\ getLifes()
numComments=14
120 changes: 120 additions & 0 deletions Player.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot und MouseInfo)

public class Player extends Actor
{
private int lifes = 3;
private int speed = 1;
private int power = 0;
private int count;

private int score;
public static int diff = 1;

GreenfootSound shootSound = new GreenfootSound("sfx3.wav");
GreenfootSound deadP = new GreenfootSound("sfx20.wav");

void Player()
{
setImage("plyer_01.png");
}

public void act()
{
move();
count++;

if (count % 10 == 0) {
shoot();
count = 0;
}

dying();
bePower();
}

private void move()
{
if(getX() > 50 && Greenfoot.isKeyDown("left")) {
setLocation​(getX() - (5 * speed), getY());
} else if(getX() < 550 && Greenfoot.isKeyDown("right")) {
setLocation​(getX() + (5 * speed), getY());
}
}

private void shoot()
{
if(getWorld().getObjects(PlayerProjectile.class).size() == 0 || power == 1) {
try {
if(Greenfoot.isKeyDown("space")) {
shootSound.play();
getWorld().addObject(new PlayerProjectile(), getX(), getY() - 45);
}
} catch (Exception e) {}
}
}

private void dying(){
if(isTouching(EnemyProjectile.class)){
getWorld().addObject(new HealthAnimation(false), ((Space)getWorld()).getPlayer().getX() + 20, ((Space)getWorld()).getPlayer().getY() - 25);
lifes -= 1;
getWorld().removeObject(getOneIntersectingObject(EnemyProjectile.class));
}

if(isTouching(Bomb.class)){
getWorld().addObject(new HealthAnimation(false), ((Space)getWorld()).getPlayer().getX() + 20, ((Space)getWorld()).getPlayer().getY() - 25);
lifes -= 1;
getWorld().removeObject(getOneIntersectingObject(Bomb.class));
}

if(lifes <= 0){
deadP.play();
Greenfoot.setWorld( new Dead());
Greenfoot.delay(500);
Greenfoot.setWorld(new Screen());
}
}

private void bePower(){
if(power == 0){
speed = 1;
}else if(power == 2){
getWorld().addObject(new HealthAnimation(true), ((Space)getWorld()).getPlayer().getX() + 20, ((Space)getWorld()).getPlayer().getY() - 25);
lifes++;
setPower(0);
} else if (power == 3){
speed = 2;
}
}

public int getScore(){
return score;
}

public void setScore(int s){
score += s;
}

public int getLifes() {
return lifes;
}

public void setPower(int i){
if(power >= 0 && power < 4){
power = i;
}
}

public int getPower(){
return power;
}

public int getDiff()
{
return diff;
}

public void setDiff()
{
diff = diff + 1;
}
}
Binary file added PlayerProjectile.class
Binary file not shown.
3 changes: 3 additions & 0 deletions PlayerProjectile.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#BlueJ class context
comment0.target=PlayerProjectile
numComments=1
5 changes: 5 additions & 0 deletions PlayerProjectile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot und MouseInfo)

public class PlayerProjectile extends Projectile
{
}
Binary file added Powerup.class
Binary file not shown.
11 changes: 11 additions & 0 deletions Powerup.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#BlueJ class context
comment0.target=Powerup
comment1.params=
comment1.target=Powerup()
comment2.params=
comment2.target=void\ act()
comment3.params=
comment3.target=void\ move()
comment4.params=
comment4.target=void\ dying()
numComments=5
63 changes: 63 additions & 0 deletions Powerup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot und MouseInfo)

public class Powerup extends Actor
{
private int lifes = 1;
private int type = 0;
private int direction = 3;
private int timer = 0;
GreenfootSound item = new GreenfootSound("sfx17.wav");

Powerup(){
type = Greenfoot.getRandomNumber(3) + 1;

if(type == 1){
setImage("rapid.png");
}else if(type == 2){
setImage("heart.png");
}else if(type == 3){
setImage("speed.png");
}
}

public void act()
{
if(lifes > 0){
move();
}
dying();
}

private void move(){
setLocation(getX() + direction, getY() + 1);
if(isAtEdge()){
direction = direction * -1;
setLocation(getX() - direction * 5, getY());
}
}

private void dying(){
if(getY() > 650){
getWorld().removeObject(this);
}
if(lifes > 0){
try{
if(isTouching(PlayerProjectile.class)){
((Space)getWorld()).getPlayer().setPower(type);
lifes--;
item.play();
}
}catch(Exception e){}
} else {
getImage().setTransparency(0);
timer ++;
if(timer == 500){
try{
((Space)getWorld()).getPlayer().setPower(0);
getWorld().removeObject(this);
getWorld().removeObject(getOneIntersectingObject(PlayerProjectile.class));
}catch(Exception e){}
}
}
}
}
Binary file added Projectile.class
Binary file not shown.
7 changes: 7 additions & 0 deletions Projectile.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#BlueJ class context
comment0.target=Projectile
comment1.params=
comment1.target=Projectile()
comment2.params=
comment2.target=void\ act()
numComments=3
17 changes: 17 additions & 0 deletions Projectile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import greenfoot.*;

public class Projectile extends Actor
{
Projectile() {
turn(270);
}
public void act()
{
if(isAtEdge()) {
getWorld().removeObject(this);
} else {
move(5);
}

}
}
14 changes: 14 additions & 0 deletions README.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
------------------------------------------------------------------------
Dies ist die README-Datei des Projekts. Hier sollten Sie Ihr Projekt
beschreiben.
Erzählen Sie dem Leser (jemand, der nichts über dieses Projekt weiss),
alles, was er/sie wissen muss. Üblicherweise sollte der Kommentar
zumindest die folgenden Angaben umfassen:
------------------------------------------------------------------------

PROJEKTBEZEICHNUNG:
PROJEKTZWECK:
VERSION oder DATUM:
WIE IST DAS PROJEKT ZU STARTEN:
AUTOR(EN):
BENUTZERHINWEISE:
Binary file added Screen.class
Binary file not shown.
7 changes: 7 additions & 0 deletions Screen.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#BlueJ class context
comment0.target=Screen
comment1.params=
comment1.target=Screen()
comment2.params=
comment2.target=void\ act()
numComments=3
30 changes: 30 additions & 0 deletions Screen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot und MouseInfo)


public class Screen extends World
{
int i;
GreenfootSound screenSound = new GreenfootSound("screen.mp3");
public Screen()
{
super(600, 800, 1);
setBackground("logo.png");
//screenSound.play();

}

public void act(){
i++;
Greenfoot.delay(12);

if(Greenfoot.isKeyDown("space")){
Greenfoot.setWorld(new Space());
}
if(i%2==1){
setBackground("logo2.png");
}
if(i%2==0){
setBackground("logo.png");
}
}
}
Binary file added Space.class
Binary file not shown.
25 changes: 25 additions & 0 deletions Space.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#BlueJ class context
comment0.target=Space
comment1.params=
comment1.target=Space()
comment10.params=
comment10.target=void\ checkEnemies()
comment11.params=
comment11.target=Player\ getPlayer()
comment2.params=
comment2.target=void\ act()
comment3.params=
comment3.target=void\ createEnemies()
comment4.params=
comment4.target=void\ createBoss()
comment5.params=
comment5.target=void\ createBoxes()
comment6.params=
comment6.target=void\ createPowerup()
comment7.params=
comment7.target=void\ moveEnemy()
comment8.params=
comment8.target=void\ checkLists()
comment9.params=
comment9.target=void\ shootEnemy()
numComments=12
Loading

0 comments on commit a2a827d

Please sign in to comment.