Skip to content
Snippets Groups Projects
Commit fb9f1a79 authored by Johannes's avatar Johannes
Browse files

Test Commit
parent c40d6ddd
No related branches found
No related tags found
No related merge requests found
Showing
with 382 additions and 0 deletions
File added
#BlueJ class context
comment0.target=Airplain
comment0.text=\n\ Write\ a\ description\ of\ class\ Airplain\ here.\n\ \n\ @author\ (your\ name)\ \n\ @version\ (a\ version\ number\ or\ a\ date)\n
comment1.params=
comment1.target=void\ act()
comment1.text=\n\ Act\ -\ do\ whatever\ the\ Airplain\ wants\ to\ do.\ This\ method\ is\ called\ whenever\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\n
numComments=2
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Airplain here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Airplain extends Actor
{
/**
* Act - do whatever the Airplain wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(5);
setLocation(getX(), getY() -2);
if(this.getX() <= 10 || this.getX() >= 690 )
{
turn(180);
}// Add your action code here.
}
}
File added
#BlueJ class context
comment0.target=Ballon
comment0.text=\n\ Write\ a\ description\ of\ class\ Ballon\ here.\n\ \n\ @author\ (your\ name)\ \n\ @version\ (a\ version\ number\ or\ a\ date)\n
comment1.params=
comment1.target=void\ act()
comment1.text=\n\ Act\ -\ do\ whatever\ the\ Ballon\ wants\ to\ do.\ This\ method\ is\ called\ whenever\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\n
numComments=2
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Ballon here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Ballon extends Actor
{
/**
* Act - do whatever the Ballon wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
setLocation(getX() + Greenfoot.getRandomNumber(10) - 3, getY() - Greenfoot.getRandomNumber(5));
// Add your action code here.
}
}
File added
#BlueJ class context
comment0.target=Coins
comment0.text=\n\ Write\ a\ description\ of\ class\ Coins\ here.\n\ \n\ @author\ (your\ name)\ \n\ @version\ (a\ version\ number\ or\ a\ date)\n
comment1.params=
comment1.target=void\ act()
comment1.text=\n\ Act\ -\ do\ whatever\ the\ Coins\ wants\ to\ do.\ This\ method\ is\ called\ whenever\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\n
numComments=2
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Coins here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Coins extends Actor
{
/**
* Act - do whatever the Coins 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.
}
}
File added
#BlueJ class context
comment0.target=LoveRocket
comment0.text=\n\ Write\ a\ description\ of\ class\ LoveRocket\ here.\n\ \n\ @author\ (your\ name)\ \n\ @version\ (a\ version\ number\ or\ a\ date)\n
comment1.params=
comment1.target=void\ act()
comment2.params=
comment2.target=void\ checkKeys()
comment3.params=
comment3.target=void\ kollision()
comment4.params=
comment4.target=void\ leben()
comment4.text=Die\ Leben\ des\ Spielers\ werden\ als\ Text\ angezeigt.
comment5.params=
comment5.target=void\ touchcoins()
numComments=6
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class LoveRocket here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class LoveRocket extends Actor
{/**
* Act - do whatever the LoveRocket wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
int leben = 3;
public void act()
{
// Add your action code here.
checkKeys();
this.kollision();
this.leben();
touchcoins();
}
public void checkKeys()
{
SpaceWorld meineWelt;
meineWelt = (SpaceWorld)this.getWorld();
meineWelt.changeBackgroundY(-3);
if (this.getY() < 650)
{
setLocation(getX(), getY() + 1);
}
if(Greenfoot.isKeyDown("d"))
{
if (this.getX() < 700)
{
setLocation(getX() + 5, getY());
}
}
if(Greenfoot.isKeyDown("a"))
{
if (this.getX() > 0)
{
setLocation(getX() - 5, getY());
}
}
if(Greenfoot.isKeyDown("w"))
{
this.setImage("rocketFire.png");
if (this.getY() > 0)
{
setLocation(getX(), getY() - 5);
}
}
if(Greenfoot.isKeyDown("s"))
{
if (this.getY() < 720)
{
setLocation(getX(), getY() + 2);
}
}
}
public void kollision() {
/* Das vom Spieler getroffene Objekt wird im Actor zwischengespeichert.*/
Actor airplain = this.getOneIntersectingObject(Airplain.class);
Actor ballon = this.getOneIntersectingObject(Ballon.class);
/* Das in Actor gespeicherte Object wird entfernt.*/
if(isTouching(Airplain.class)) {
getWorld().removeObject(airplain);
leben--;
}
if(isTouching(Ballon.class)) {
getWorld().removeObject(ballon);
leben--;
}
}
/* Die Leben des Spielers werden als Text angezeigt.*/
public void leben() {
if(leben == 3) {
this.getWorld().showText("Leben = 3", 100, 20);
}
if(leben == 2) {
this.getWorld().showText("Leben = 2", 100, 20);
}
if(leben == 1) {
this.getWorld().showText("Leben = 1", 100, 20);
}
if (leben == 0) {
this.getWorld().showText("Leben = 0", 100, 20);
this.getWorld().showText("Game Over", 300, 200);
Greenfoot.stop();
}
}
//methode die abprüft ob der spieler food berührt
public void touchcoins()
{
//checkt ob player Coins anfässt, wenn er es tut wird
//food removed
if (isTouching(Coins.class) == true)
{
removeTouching(Coins.class);
Scoreboard.score++;
}
}
}
------------------------------------------------------------------------
This is the project README file. Here, you should describe your project.
Tell the reader (someone who does not know anything about this project)
all they need to know. The comments should usually include at least:
------------------------------------------------------------------------
PROJECT TITLE:
PURPOSE OF PROJECT:
VERSION or DATE:
HOW TO START THIS PROJECT:
AUTHORS:
USER INSTRUCTIONS:
File added
#BlueJ class context
comment0.target=Scoreboard
comment0.text=\n\ Write\ a\ description\ of\ class\ Scoreboard\ here.\n\ \n\ @author\ (your\ name)\ \n\ @version\ (a\ version\ number\ or\ a\ date)\n
comment1.params=
comment1.target=void\ act()
numComments=2
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Scoreboard here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Scoreboard extends Actor
{
/**
* Act - do whatever the Scoreboard wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public static int score = 0;
public void act()
{
//größe des bildes wird eingestellt
GreenfootImage image = getImage();
image.scale(100,100);
//scoreboard text wird geoutputtet
this.getWorld().showText("Score: " + score, 77, 650);// Add your action code here.
}
}
File added
#BlueJ class context
comment0.target=SpaceWorld
comment0.text=\n\ Write\ a\ description\ of\ class\ SpaceWorld\ here.\n\ \n\ @author\ (your\ name)\ \n\ @version\ (a\ version\ number\ or\ a\ date)\n
comment1.params=
comment1.target=SpaceWorld()
comment2.params=
comment2.target=void\ act()
comment3.params=
comment3.target=void\ fillWorld()
comment4.params=changeY
comment4.target=void\ changeBackgroundY(int)
comment5.params=
comment5.target=void\ drawBackground()
comment6.params=
comment6.target=java.util.List\ showAllActors()
numComments=7
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.*;
/**
* Write a description of class SpaceWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class SpaceWorld extends World
{
/**
* Constructor for objects of class SpaceWorld.
*
*/
GreenfootImage hintergrund; // Variable Hintergrundbild
private int hintergrundY = - 5000; // y-Koordinate des Hintergrund
public SpaceWorld()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(700, 700, 1, false); /* Größe der Welt, false=Möglichkeit Objekte
ausserhalb des Sichtbereiches zu platzieren
*/
hintergrund = new GreenfootImage("background.jpg"); // Fuellt die background Variable
this.getBackground().drawImage(hintergrund, 0 , -5000);/* gibt leeren Hintergrund
wieder und zeichnet das Bild der Variablen hintergrund an die Position 0, -1000
*/
this.fillWorld(); // Fügt Objekte in die Welt ein
}
public void act()
{
this.drawBackground();
}
public void fillWorld() {
Scoreboard.score = 0;
Scoreboard scoreboard = new Scoreboard();
this.addObject(scoreboard, 70, 650);
LoveRocket myLoveRocket;
myLoveRocket = new LoveRocket();
this.addObject(myLoveRocket, this.getWidth() / 2, 650);
myLoveRocket.turn(270);
Airplain myAirplain01;
myAirplain01 = new Airplain();
this.addObject(myAirplain01, 50, 180);
Airplain myAirplain02;
myAirplain02 = new Airplain();
this.addObject(myAirplain02, 250, 300);
Ballon myBallon01;
myBallon01 = new Ballon();
this.addObject(myBallon01, 500, 100);
Ballon myBallon02;
myBallon02 = new Ballon();
this.addObject(myBallon02, 200, 200);
Ballon myBallon03;
myBallon03 = new Ballon();
this.addObject(myBallon03, 100, 100);
Ballon myBallon04;
myBallon04 = new Ballon();
this.addObject(myBallon04, 700, 50);
Ballon myBallon05;
myBallon05 = new Ballon();
this.addObject(myBallon05, 50, 400);
Ballon myBallon06;
myBallon06 = new Ballon();
this.addObject(myBallon06, 600, 300);
Ballon myBallon07;
myBallon07 = new Ballon();
this.addObject(myBallon07, 280, 10);
Ballon myBallon08;
myBallon08 = new Ballon();
this.addObject(myBallon08, 800, 0);
}
public void changeBackgroundY(int changeY)
{
hintergrundY = hintergrundY -changeY;
for(int zaehler = 0; zaehler < this.showAllActors().size();zaehler++)
{
if(this.showAllActors().get(zaehler).getClass() != LoveRocket.class && this.showAllActors().get(zaehler).getClass() != Scoreboard.class)
{
this.showAllActors().get(zaehler).setLocation(
this.showAllActors().get(zaehler).getX(),
this.showAllActors().get(zaehler).getY() - changeY);
}
}
}
public void drawBackground()
{
this.getBackground().drawImage(hintergrund, 0, hintergrundY);
}
public List<Actor> showAllActors()
{
List<Actor> allActors;
allActors = this.getObjects(Actor.class);
return allActors;
}
}
LoveRocket3-copy-2/airplane.png

7.09 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment