first commit
3
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
6
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="corretto-1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
17
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Democracy/Democracy.iml" filepath="$PROJECT_DIR$/Democracy/Democracy.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Dino/Dino.iml" filepath="$PROJECT_DIR$/Dino/Dino.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/FindTheHole/FindTheHole.iml" filepath="$PROJECT_DIR$/FindTheHole/FindTheHole.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Paint/Paint.iml" filepath="$PROJECT_DIR$/Paint/Paint.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/RaketeGame/RaketeGame.iml" filepath="$PROJECT_DIR$/RaketeGame/RaketeGame.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/RollTheDice/RollTheDice.iml" filepath="$PROJECT_DIR$/RollTheDice/RollTheDice.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Rotkeappchengame/Rotkeappchengame.iml" filepath="$PROJECT_DIR$/Rotkeappchengame/Rotkeappchengame.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/SpaceFighter/SpaceFighter.iml" filepath="$PROJECT_DIR$/SpaceFighter/SpaceFighter.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/TOOLS/TOOLS.iml" filepath="$PROJECT_DIR$/TOOLS/TOOLS.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/TicTacToe/TicTacToe.iml" filepath="$PROJECT_DIR$/TicTacToe/TicTacToe.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
12
Democracy/Democracy.iml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="TOOLS" exported="" />
|
||||
</component>
|
||||
</module>
|
||||
51
Democracy/src/DayCounter.java
Normal file
@@ -0,0 +1,51 @@
|
||||
import basis.*;
|
||||
|
||||
public class DayCounter implements Runnable {
|
||||
|
||||
private Stift pen;
|
||||
private TextFeld textField;
|
||||
|
||||
private int days;
|
||||
private int discussion;
|
||||
|
||||
public DayCounter(Output output) {
|
||||
pen = new Stift();
|
||||
textField = new TextFeld();
|
||||
//Customizing the textfield
|
||||
textField.setzeGroesse(140, 20);
|
||||
textField.setzePosition(output.getFrame().breite()-textField.breite()-15, output.getFrame().hoehe()-textField.hoehe()-10);
|
||||
textField.setzeText(" Days passed: 0");
|
||||
textField.setzeHintergrundFarbe(output.getFrame().hintergrundFarbe());
|
||||
textField.setzeSchriftFarbe(Farbe.rgb(217, 219, 66));
|
||||
textField.setzeSchriftStil(Schrift.FETT);
|
||||
textField.setzeRand(textField.schriftFarbe(), 2);
|
||||
|
||||
days = 0;
|
||||
discussion = 0;
|
||||
}
|
||||
|
||||
public void countDays(){
|
||||
discussion++;
|
||||
//If 100 discussions were made one day passes
|
||||
if (discussion % 100 == 1){
|
||||
days++;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateDays(){
|
||||
textField.setzeText("");
|
||||
textField.setzeText(" Days passed: " + days);
|
||||
}
|
||||
|
||||
public int getDays() {
|
||||
return days;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (!Thread.currentThread().isInterrupted()){
|
||||
updateDays();
|
||||
Hilfe.kurzePause();
|
||||
}
|
||||
}
|
||||
}
|
||||
102
Democracy/src/Operator.java
Normal file
@@ -0,0 +1,102 @@
|
||||
import basis.Hilfe;
|
||||
import util.Timer;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* @Author BiteCoding --> https://github.com/BiteCoding/JavaCode
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
public class Operator {
|
||||
|
||||
//--------------------------------------------------Needed classes--------------------------------------------------
|
||||
private Output output;
|
||||
private Render render;
|
||||
private Person villagers;
|
||||
private DayCounter dayCounter;
|
||||
private Timer timer;
|
||||
|
||||
private ExecutorService executor = Executors.newCachedThreadPool();
|
||||
//----------------------------------------Array that represents the village-----------------------------------------
|
||||
private Person[][] village;
|
||||
|
||||
//---------------------------------------------------Constructor----------------------------------------------------
|
||||
public Operator() {
|
||||
output = new Output();
|
||||
village = new Person[50][50];
|
||||
render = new Render(village,output.getFrame().breite());
|
||||
dayCounter = new DayCounter(output);
|
||||
output.setRenderer(render);
|
||||
timer = new Timer();
|
||||
//dummy for operating methods
|
||||
villagers = new Person(-1, -1, -1);
|
||||
}
|
||||
|
||||
private boolean isAutocracy(int border) {
|
||||
int value = village[0][0].getParty();
|
||||
for (int i = 0; i < village.length; i++) {
|
||||
for (int j = 0; j < village.length; j++) {
|
||||
if (value > border != village[i][j].getParty() > border){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void fillVillage() {
|
||||
for (int i = 0; i < village.length; i++) {
|
||||
for (int j = 0; j < village.length; j++) {
|
||||
//Positions the Person in between a rectangle with x:50, y:50, w:framewidth - 100, h: frameheight - 100
|
||||
Person villager = new Person(
|
||||
//------------------------------------------ x -------------------------------------------------
|
||||
((1 + i) * (output.getFrame().breite() - 100) / village.length) + 50 - 7,
|
||||
//------------------------------------------ y -------------------------------------------------
|
||||
((1 + j) * (output.getFrame().hoehe() - 100) / village.length) + 50 - 7,
|
||||
//----------------------------------------random------------------------------------------------
|
||||
Hilfe.zufall(1, 100));
|
||||
village[i][j] = villager;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawBorder() {
|
||||
output.setBorder(village[0][0].getPosition().getX(), village[0][0].getPosition().getX(),
|
||||
village[village.length - 1][village.length - 1].getPosition().getX()
|
||||
- village[0][0].getPosition().getX(),
|
||||
village[village.length - 1][village.length - 1].getPosition().getY()
|
||||
- village[0][0].getPosition().getY(), render.getRadius() + render.getRadius() * 0.5);
|
||||
}
|
||||
|
||||
//-------------------------------------------------operating method-------------------------------------------------
|
||||
private void start(){
|
||||
while (!output.isStartButtonPressed() || !output.textChanged()) {
|
||||
Hilfe.kurzePause();
|
||||
}
|
||||
timer.start();
|
||||
render.renderAll(output.getPercentageRed());
|
||||
output.setFirstValues(village);
|
||||
executor.execute(dayCounter);
|
||||
while (!output.isEndButtonPressed() && !this.isAutocracy(output.getPercentageRed())) {
|
||||
villagers.discuss(village, output.getPercentageRed(), render);
|
||||
dayCounter.countDays();
|
||||
}
|
||||
timer.end();
|
||||
System.out.println(timer.timeNeeded());
|
||||
output.setEndValues(village);
|
||||
output.displayResults(dayCounter);
|
||||
Hilfe.warte(500);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------main method--------------------------------------------------
|
||||
public static void main(String[] args) {
|
||||
Operator op = new Operator();
|
||||
op.fillVillage();
|
||||
op.drawBorder();
|
||||
op.start();
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
}
|
||||
261
Democracy/src/Output.java
Normal file
@@ -0,0 +1,261 @@
|
||||
import basis.*;
|
||||
import util.Timer;
|
||||
|
||||
import java.awt.*;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* @Author BiteCoding --> https://github.com/BiteCoding/JavaCode
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
public class Output {
|
||||
private Fenster frame;
|
||||
private Stift pen;
|
||||
private TextFeld textField;
|
||||
private Knopf startButton;
|
||||
private Knopf endButton;
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
private boolean startButtonPressed, endButtonPressed, textChange;
|
||||
private int percentageRed, width, height, startReds, startBlacks, endReds, endBlacks;
|
||||
private String text;
|
||||
|
||||
private Render render;
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
public Output() {
|
||||
this.initFrame();
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
this.initPen();
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
this.initTextFields();
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
this.initButtons();
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
startButtonPressed = textChange = false;
|
||||
percentageRed = -1;
|
||||
text = textField.text();
|
||||
}
|
||||
|
||||
public void setRenderer(Render render){
|
||||
this.render = render;
|
||||
pen.setzeLinienBreite((int)render.getRadius());
|
||||
}
|
||||
|
||||
private void initFrame(){
|
||||
frame = new Fenster();
|
||||
//Scaling the frame
|
||||
frame.setzeGroesse(900, 900);
|
||||
this.getMonitorSize();
|
||||
//Centering the frame in the middle of the screen
|
||||
//this.getMonitorSizes();
|
||||
frame.setzePosition(width / 2 - frame.breite() / 2,
|
||||
height / 2 - frame.hoehe() / 2);
|
||||
frame.setzeHintergrundFarbe(Farbe.rgb(61, 50, 91));
|
||||
//naming the frame
|
||||
frame.setzeTitel("~~~~ DEMOCRACY ~~~~");
|
||||
}
|
||||
|
||||
private void initPen(){
|
||||
pen = new Stift();
|
||||
}
|
||||
|
||||
private void initTextFields(){
|
||||
textField = new TextFeld();
|
||||
//Customizing the textfield
|
||||
textField.setzeGroesse(140, 20);
|
||||
//Centering the textfield
|
||||
this.getMonitorSize();
|
||||
textField.setzePosition(15, 5);
|
||||
textField.setzeText(" Proportion red: ");
|
||||
textField.setzeHintergrundFarbe(frame.hintergrundFarbe());
|
||||
textField.setzeSchriftFarbe(Farbe.rgb(217, 219, 66));
|
||||
textField.setzeSchriftStil(Schrift.FETT);
|
||||
textField.setzeRand(textField.schriftFarbe(), 2);
|
||||
}
|
||||
|
||||
private void initButtons(){
|
||||
//START
|
||||
startButton = new Knopf();
|
||||
//Customizing the startButton
|
||||
startButton.setzeGroesse(100, 20);
|
||||
//Setting the position of the startButton relative to the position of the textfield
|
||||
startButton.setzePosition(frame.breite() / 2 - startButton.breite()/2,
|
||||
textField.vPosition());
|
||||
startButton.setzeText("START");
|
||||
startButton.setzeRand(Farbe.rgb(217, 219, 66), 2);
|
||||
startButton.setzeSchriftFarbe(Farbe.rgb(217, 219, 66));
|
||||
startButton.setzeHintergrundFarbe(frame.hintergrundFarbe());
|
||||
|
||||
//END
|
||||
endButton = new Knopf();
|
||||
//Customizing the startButton
|
||||
endButton.setzeGroesse(100, 20);
|
||||
//Setting the position of the startButton relative to the position of the textfield
|
||||
endButton.setzePosition(frame.breite()/2 - endButton.breite()/2,
|
||||
frame.hoehe() - 20 - endButton.hoehe() / 2);
|
||||
endButton.setzeText("END");
|
||||
endButton.setzeRand(Farbe.rgb(217, 219, 66), 2);
|
||||
endButton.setzeSchriftFarbe(Farbe.rgb(217, 219, 66));
|
||||
endButton.setzeHintergrundFarbe(frame.hintergrundFarbe());
|
||||
}
|
||||
|
||||
/**
|
||||
* Created my own Method to detect the displaysize because the Method provided by the {@link basis.Hilfe} library
|
||||
* detected my dual monitor setup as one giant monitor
|
||||
*/
|
||||
public void getMonitorSize() {
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
GraphicsDevice[] gs = ge.getScreenDevices();
|
||||
for (int i = 0; i < gs.length; i++) {
|
||||
DisplayMode dm = gs[i].getDisplayMode();
|
||||
width = dm.getWidth();
|
||||
height = dm.getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
private int reds(Person[][] villager) {
|
||||
int reds = 0;
|
||||
for (int i = 0; i < villager.length; i++) {
|
||||
for (int j = 0; j < villager.length; j++) {
|
||||
if (villager[i][j].getParty() <= this.getPercentageRed()) {
|
||||
reds++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return reds;
|
||||
}
|
||||
|
||||
private int blacks(Person[][] villager) {
|
||||
int blacks = 0;
|
||||
for (int i = 0; i < villager.length; i++) {
|
||||
for (int j = 0; j < villager.length; j++) {
|
||||
if (villager[i][j].getParty() > this.getPercentageRed()) {
|
||||
blacks++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return blacks;
|
||||
}
|
||||
|
||||
public void setBorder(double x, double y, double lastX, double lastY, double radius){
|
||||
pen.rechteck(x - radius-pen.linienBreite(),y - radius - pen.linienBreite(),
|
||||
lastX + 2*(radius + pen.linienBreite()),lastY + 2*(radius+pen.linienBreite()));
|
||||
}
|
||||
|
||||
public void setFirstValues(Person[][] villagers) {
|
||||
startBlacks = blacks(villagers);
|
||||
startReds = reds(villagers);
|
||||
}
|
||||
|
||||
public void setEndValues(Person[][] villagers) {
|
||||
endBlacks = blacks(villagers);
|
||||
endReds = reds(villagers);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
public Fenster getFrame() {
|
||||
return frame;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
private String getNumber(String str) {
|
||||
String number = "";
|
||||
for (int i = text.length(); i < str.length(); i++) {
|
||||
number += (str.charAt(i));
|
||||
}
|
||||
return number;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
/*METHOD THAT RETURNS IF THE TEXT IN THE TEXTBOX CHANGED AND SETS THE CHANGED VALUE
|
||||
AS THE PERCENTAGE OF THE VOTERS WHO VOTE FOR THE RED PARTY*/
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
public boolean textChanged() {
|
||||
//checking if the text changed
|
||||
if (!textField.text().equals(text) && textField.fokusVerloren()) {
|
||||
textChange = true;
|
||||
//is the value a valid value?
|
||||
try {
|
||||
percentageRed = Integer.parseInt(getNumber(textField.text()));
|
||||
//values that are not between 0 and 100 are not allowed
|
||||
if (percentageRed < 0 || percentageRed > 100) {
|
||||
textField.setzeText(text);
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
textField.setzeEditierbar(false);
|
||||
} catch (Exception e1) {
|
||||
System.err.println("NOT A VALID VALUE!");
|
||||
//resetting the text in the textbox
|
||||
textField.setzeText(text);
|
||||
//repeat loop until a valid value got inserted
|
||||
boolean validValue = false;
|
||||
while (!validValue) {
|
||||
//checking if text changed
|
||||
if (!textField.text().equals(text) && textField.fokusVerloren()) {
|
||||
//is the value a valid value?
|
||||
try {
|
||||
percentageRed = Integer.parseInt(getNumber(textField.text()));
|
||||
//values that are not between 0 and 100 are not allowed
|
||||
if (percentageRed < 0 || percentageRed > 100) {
|
||||
textField.setzeText(text);
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
textField.setzeEditierbar(false);
|
||||
validValue = true;
|
||||
} catch (Exception e2) {
|
||||
System.err.println("NOT A VALID VALUE!");
|
||||
textField.setzeText(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return textChange;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
public int getPercentageRed() {
|
||||
return percentageRed;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
public boolean isStartButtonPressed() {
|
||||
if (startButton.wurdeGedrueckt()) {
|
||||
startButtonPressed = true;
|
||||
}
|
||||
return startButtonPressed;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
public boolean isEndButtonPressed() {
|
||||
if (endButton.wurdeGedrueckt()) {
|
||||
endButtonPressed = true;
|
||||
}
|
||||
return endButtonPressed;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
public void displayResults(DayCounter dayCounter) {
|
||||
DecimalFormat dc = new DecimalFormat("#.##");
|
||||
String timeTaken = "The simulation has ended after " + dayCounter.getDays() + " days.";
|
||||
String first = "Red starting value: " + startReds + " | " + "Black starting value: " + startBlacks;
|
||||
String last = "Red ending value: " + endReds + " | " + "Black ending value: " + endBlacks;
|
||||
String totalChange = "Red: " + (endReds - startReds) + " | " + "Black: " + (endBlacks - startBlacks);
|
||||
String percentages = "Red: " + dc.format((double)endReds/2500 *100) + "% | "
|
||||
+ " Blacks: " + dc.format((double)endBlacks/2500 *100)+ "%";
|
||||
System.out.println(timeTaken);
|
||||
System.out.println(first);
|
||||
System.out.println(last);
|
||||
System.out.println(totalChange);
|
||||
System.out.println(percentages);
|
||||
}
|
||||
}
|
||||
54
Democracy/src/Person.java
Normal file
@@ -0,0 +1,54 @@
|
||||
import basis.Hilfe;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @Author BiteCoding --> https://github.com/BiteCoding/JavaCode
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
class Person {
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
private Point position;
|
||||
private int party;
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
Person(int x, int y, int rand) {
|
||||
position = new Point(x, y);
|
||||
party = rand;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
void discuss(Person[][] persons, int redBorder, Render render) {
|
||||
Person person1 = persons[Hilfe.zufall(0, 49)][Hilfe.zufall(0, 49)];
|
||||
Person person2 = persons[Hilfe.zufall(0, 49)][Hilfe.zufall(0, 49)];
|
||||
//if person1.getParty() <= redBorder ==> member of the red party
|
||||
//if person1.getParty() > redBorder ==> member of the black party
|
||||
if (person1.getParty() > redBorder != person2.getParty() > redBorder) {
|
||||
int randValue = Hilfe.zufall(0, 1);
|
||||
if (randValue == 1) {
|
||||
person1.setParty(person2.getParty());
|
||||
render.renderOne(person1, redBorder);
|
||||
} else {
|
||||
person2.setParty(person1.getParty());
|
||||
render.renderOne(person2, redBorder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
Point getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
int getParty() {
|
||||
return party;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
private void setParty(int party) {
|
||||
this.party = party;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
}
|
||||
56
Democracy/src/Render.java
Normal file
@@ -0,0 +1,56 @@
|
||||
import basis.Farbe;
|
||||
import basis.Muster;
|
||||
import basis.Stift;
|
||||
|
||||
/**
|
||||
* @Author BiteCoding --> https://github.com/BiteCoding/JavaCode
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
public class Render {
|
||||
Stift pen;
|
||||
Person [][] villager;
|
||||
double radius;
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
public Render(Person[][] villager, int frameWidth) {
|
||||
pen = new Stift();
|
||||
pen.setzeFuellMuster(Muster.GEFUELLT);
|
||||
this.villager = villager;
|
||||
radius = ((frameWidth-50)/ villager.length) / 2 - (frameWidth/villager.length)*0.05;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
//DRAWING THE VILLAGERS TO THE FRAME
|
||||
public void renderAll(int redPercentage) {
|
||||
for (int i = 0; i < villager.length; i++) {
|
||||
for (int j = 0; j < villager.length; j++) {
|
||||
if (villager[i][j].getParty() <= redPercentage) {
|
||||
pen.setzeFarbe(Farbe.ROT);
|
||||
} else {
|
||||
pen.setzeFarbe(Farbe.SCHWARZ);
|
||||
}
|
||||
pen.kreis(villager[i][j].getPosition().getX(),
|
||||
villager[i][j].getPosition().getY(),
|
||||
radius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void renderOne(Person villager, int redPercentage) {
|
||||
if (villager.getParty() <= redPercentage) {
|
||||
pen.setzeFarbe(Farbe.ROT);
|
||||
} else {
|
||||
pen.setzeFarbe(Farbe.SCHWARZ);
|
||||
}
|
||||
pen.kreis(villager.getPosition().getX(),
|
||||
villager.getPosition().getY(),
|
||||
radius);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
public double getRadius() {
|
||||
return radius;
|
||||
}
|
||||
}
|
||||
12
Dino/Dino.iml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="TOOLS" exported="" />
|
||||
</component>
|
||||
</module>
|
||||
3
Dino/src/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path: /home/simon/Dokumente/JavaCode/_Library_/basisUTF8151112.jar
|
||||
Main-Class: github.stringBoy.Logic
|
||||
72
Dino/src/github/stringBoy/Animation.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package github.stringBoy;
|
||||
|
||||
import basis.SpriteBild;
|
||||
|
||||
public class Animation implements Runnable {
|
||||
Dino dino;
|
||||
int i;
|
||||
private SpriteBild spriteLinks;
|
||||
private SpriteBild spriteRechts;
|
||||
private SpriteBild spriteMitte;
|
||||
|
||||
public Animation(Dino dino) {
|
||||
this.dino = dino;
|
||||
|
||||
spriteLinks = new SpriteBild("/home/simon/Dokumente/JavaCode/Dino/src/res/DinoLinks.png");
|
||||
spriteLinks.setzeGroesse(spriteLinks.breite() / 2, spriteLinks.hoehe() / 2);
|
||||
spriteLinks.spiegeleBild(false);
|
||||
|
||||
spriteMitte = new SpriteBild("/home/simon/Dokumente/JavaCode/Dino/src/res/Dino.png");
|
||||
spriteMitte.setzeGroesse(spriteMitte.breite() / 2, spriteMitte.hoehe() / 2);
|
||||
spriteMitte.spiegeleBild(false);
|
||||
|
||||
spriteRechts = new SpriteBild("/home/simon/Dokumente/JavaCode/Dino/src/res/DinoRechts.png");
|
||||
spriteRechts.setzeGroesse(spriteRechts.breite() / 2, spriteRechts.hoehe() / 2);
|
||||
spriteRechts.spiegeleBild(false);
|
||||
|
||||
i = 0;
|
||||
}
|
||||
|
||||
public void placeDino(int x, int y) {
|
||||
spriteLinks.setzePosition(x - spriteLinks.mittelpunkt().getX(), y - spriteLinks.mittelpunkt().getY() * 2);
|
||||
spriteMitte.setzePosition(x - spriteMitte.mittelpunkt().getX(), y - spriteMitte.mittelpunkt().getY() * 2);
|
||||
spriteRechts.setzePosition(x - spriteRechts.mittelpunkt().getX(), y - spriteRechts.mittelpunkt().getY() * 2);
|
||||
}
|
||||
|
||||
public SpriteBild getSprite() {
|
||||
return spriteLinks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
placeDino(dino.getX(), dino.getY());
|
||||
if (!dino.isJumping) {
|
||||
if (i == 0) {
|
||||
spriteLinks.setzeSichtbar(true);
|
||||
spriteMitte.setzeSichtbar(false);
|
||||
spriteRechts.setzeSichtbar(false);
|
||||
i = 1;
|
||||
} else if (i == 1) {
|
||||
spriteLinks.setzeSichtbar(false);
|
||||
spriteMitte.setzeSichtbar(true);
|
||||
spriteRechts.setzeSichtbar(false);
|
||||
i = 2;
|
||||
} else if (i == 2) {
|
||||
spriteLinks.setzeSichtbar(false);
|
||||
spriteMitte.setzeSichtbar(false);
|
||||
spriteRechts.setzeSichtbar(true);
|
||||
i = 0;
|
||||
}
|
||||
try {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Thread.sleep(10);
|
||||
placeDino(dino.getX(), dino.getY());
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Dino/src/github/stringBoy/Background.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package github.stringBoy;
|
||||
|
||||
import basis.*;
|
||||
|
||||
public class Background {
|
||||
private Stift pen;
|
||||
private Frame frame;
|
||||
private Bild sonne;
|
||||
private int y;
|
||||
|
||||
public Background(Frame frame, int y) {
|
||||
this.frame = frame;
|
||||
pen = new Stift();
|
||||
pen.setzeLinienBreite(5);
|
||||
pen.setzeFuellMuster(1);
|
||||
sonne = new Bild("/home/simon/Dokumente/JavaCode/Dino/src/res/Sonne.png");
|
||||
sonne.setzeGroesse(sonne.breite() / 2.5, sonne.hoehe() / 2.5);
|
||||
sonne.setzePosition(frame.width() - sonne.breite() - 50, 50);
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void drawGround() {
|
||||
pen.setzeFarbe(Farbe.rgb(235, 255, 86));
|
||||
pen.rechteck(0, y, frame.width(), frame.height() - y);
|
||||
}
|
||||
}
|
||||
58
Dino/src/github/stringBoy/Cactus.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package github.stringBoy;
|
||||
|
||||
import basis.*;
|
||||
|
||||
public class Cactus extends Obstacle {
|
||||
private SpriteBild obstacleSprite;
|
||||
private Highscore highscore;
|
||||
|
||||
private int width, height;
|
||||
|
||||
public Cactus(int px, int py, Highscore highscore) {
|
||||
super(px, py);
|
||||
obstacleSprite = new SpriteBild("/home/simon/Dokumente/JavaCode/Dino/src/res/Cactus.png");
|
||||
|
||||
width = obstacleSprite.breite();
|
||||
height = obstacleSprite.hoehe();
|
||||
|
||||
obstacleSprite.setzeGroesse(width / 5, height / 7);
|
||||
this.highscore = highscore;
|
||||
|
||||
place();
|
||||
}
|
||||
|
||||
public SpriteBild getSprite() {
|
||||
return obstacleSprite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void move(int score) {
|
||||
setX(((int) getX() - 5 - score / 50));
|
||||
place();
|
||||
if (getX() < 0) {
|
||||
if (Hilfe.zufall(0,1) == 1){
|
||||
obstacleSprite.setzeGroesse(width/5,height/10);
|
||||
} else {
|
||||
obstacleSprite.setzeGroesse(width/5,height/7);
|
||||
}
|
||||
setX(Hilfe.zufall(800 + highscore.getScore(), 1920));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place() {
|
||||
obstacleSprite.setzePosition(getX() - obstacleSprite.mittelpunkt().getX(), getY() - obstacleSprite.mittelpunkt().getY() * 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
move(highscore.getScore());
|
||||
try {
|
||||
Thread.sleep(5);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
43
Dino/src/github/stringBoy/CrashDetection.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package github.stringBoy;
|
||||
|
||||
import basis.SpriteBild;
|
||||
|
||||
public class CrashDetection implements Runnable {
|
||||
private SpriteBild dinoSprite;
|
||||
private SpriteBild obstacleSprite;
|
||||
|
||||
private Dino dino;
|
||||
private Obstacle obstacle;
|
||||
|
||||
private boolean crashed;
|
||||
|
||||
public CrashDetection(SpriteBild dinoSp, SpriteBild obstacleSp, Dino dino, Obstacle obstacle) {
|
||||
this.dinoSprite = dinoSp;
|
||||
this.obstacleSprite = obstacleSp;
|
||||
|
||||
this.dino = dino;
|
||||
this.obstacle = obstacle;
|
||||
|
||||
crashed = false;
|
||||
|
||||
obstacleSprite.setzeVereinfachteKollisionerkennung(false);
|
||||
}
|
||||
|
||||
public void crashed() {
|
||||
if (obstacleSprite.kollisionErkanntMit(dinoSprite)) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCrashed() {
|
||||
return crashed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
crashed();
|
||||
}
|
||||
crashed = true;
|
||||
}
|
||||
}
|
||||
68
Dino/src/github/stringBoy/Dino.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package github.stringBoy;
|
||||
|
||||
import basis.*;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class Dino implements Runnable {
|
||||
public boolean isJumping;
|
||||
private Point dino;
|
||||
|
||||
SpriteBild[] sprites;
|
||||
|
||||
private Tastatur keyboard;
|
||||
|
||||
public Dino(int x, int y) {
|
||||
dino = new Point(x, y);
|
||||
|
||||
keyboard = new Tastatur();
|
||||
|
||||
isJumping = false;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return (int) dino.getX();
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return (int) dino.getY();
|
||||
}
|
||||
|
||||
public void setY(int y) {
|
||||
dino.y = y;
|
||||
}
|
||||
|
||||
|
||||
public void jump() {
|
||||
isJumping = true;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
setY((int) dino.getY() - 20);
|
||||
Hilfe.warte(12);
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
setY((int) dino.getY() - 4);
|
||||
Hilfe.warte(15);
|
||||
}
|
||||
for (int i = 5; i > 0; i--) {
|
||||
setY((int) dino.getY() + 4);
|
||||
Hilfe.warte(15);
|
||||
}
|
||||
for (int i = 9; i > 0; i--) {
|
||||
setY((int) dino.getY() + 20);
|
||||
Hilfe.warte(12 );
|
||||
}
|
||||
isJumping = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int i = 0;
|
||||
Hilfe.kurzePause();
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
Hilfe.kurzePause();
|
||||
if (keyboard.istGedrueckt(' ')) {
|
||||
jump();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
87
Dino/src/github/stringBoy/Frame.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package github.stringBoy;
|
||||
|
||||
import basis.*;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class Frame {
|
||||
public boolean isVisible;
|
||||
private Fenster frame;
|
||||
private Stift pen;
|
||||
private Bild deadDino;
|
||||
|
||||
public Frame(boolean normalFrame) {
|
||||
frame = new Fenster();
|
||||
frame.setzeGroesse(Hilfe.monitorBreite(), Hilfe.monitorHoehe());
|
||||
frame.setzeTitel("Dino Jump & Run");
|
||||
frame.setzeHintergrundFarbe(Farbe.rgb(154, 210, 255));
|
||||
|
||||
if (!normalFrame){
|
||||
deadDino = new Bild("Dino/src/res/DeadDino.png");
|
||||
deadDino.setzeGroesse(deadDino.breite()*1.5,deadDino.hoehe()*1.5);
|
||||
deadDino.spiegeleBild(false);
|
||||
deadDino.setzePosition(frame.breite()/2-deadDino.breite()/2,frame.hoehe()/2-deadDino.hoehe()/2);
|
||||
}
|
||||
|
||||
pen = new Stift(frame);
|
||||
}
|
||||
|
||||
public Frame(Color customColor, boolean normalFrame) {
|
||||
frame = new Fenster();
|
||||
frame.setzeGroesse(Hilfe.monitorBreite(), Hilfe.monitorHoehe());
|
||||
frame.setzeTitel("Dino Jump & Run");
|
||||
frame.setzeHintergrundFarbe(customColor);
|
||||
|
||||
if (!normalFrame){
|
||||
deadDino = new Bild("Dino/src/res/DeadDino.png");
|
||||
deadDino.setzeGroesse(deadDino.breite()*1.5,deadDino.hoehe()*1.5);
|
||||
deadDino.spiegeleBild(false);
|
||||
deadDino.setzePosition(frame.breite()/2-deadDino.breite()/2,frame.hoehe()/2-deadDino.hoehe()/2);
|
||||
}
|
||||
|
||||
pen = new Stift(frame);
|
||||
}
|
||||
|
||||
public void visible(boolean isVisible) {
|
||||
this.isVisible = isVisible;
|
||||
if (isVisible == true) {
|
||||
frame.setzeSichtbar(true);
|
||||
} else {
|
||||
frame.setzeSichtbar(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void makeDinoInvis(boolean invis) {
|
||||
if (invis) {
|
||||
deadDino.setzeSichtbar(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeText(String text, boolean centered, int size, Color color, int y){
|
||||
pen.setzeFarbe(color);
|
||||
if (centered){
|
||||
pen.bewegeAuf(this.width()/2 - text.length()*size/4,this.height()/2-y);
|
||||
} else {
|
||||
pen.bewegeAuf(0,100);
|
||||
}
|
||||
pen.setzeSchriftGroesse(size);
|
||||
pen.schreibeText(text);
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return isVisible;
|
||||
}
|
||||
|
||||
public int width() {
|
||||
return frame.breite();
|
||||
}
|
||||
|
||||
public int height() {
|
||||
return frame.hoehe();
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
frame.gibFrei();
|
||||
}
|
||||
|
||||
}
|
||||
58
Dino/src/github/stringBoy/Highscore.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package github.stringBoy;
|
||||
|
||||
import basis.*;
|
||||
import reader.NumberReader;
|
||||
|
||||
public class Highscore implements Runnable {
|
||||
private TextFeld scoreFeld;
|
||||
private TextFeld highscoreFeld;
|
||||
private NumberReader reader;
|
||||
private int score;
|
||||
private int highscore;
|
||||
|
||||
public Highscore() {
|
||||
scoreFeld = new TextFeld();
|
||||
scoreFeld.setzeHintergrundFarbe(Farbe.rgb(154, 210, 255));
|
||||
scoreFeld.setzeText("Score: " + String.format("%03d",score));
|
||||
scoreFeld.setzeSchriftGroesse(35);
|
||||
scoreFeld.setzeGroesse(230, 50);
|
||||
scoreFeld.setzePosition(960 - scoreFeld.breite() / 2, 50);
|
||||
scoreFeld.setzeSchriftStil(Schrift.FETT);
|
||||
scoreFeld.entferneRand();
|
||||
|
||||
reader = new NumberReader("/home/simon/Dokumente/JavaCode/Dino/src/res/.highscore.txt");
|
||||
highscore = reader.read();
|
||||
|
||||
highscoreFeld = new TextFeld();
|
||||
highscoreFeld.setzeHintergrundFarbe(Farbe.rgb(154, 210, 255));
|
||||
highscoreFeld.setzeText("Highscore: " + highscore);
|
||||
highscoreFeld.setzeSchriftGroesse(15);
|
||||
highscoreFeld.setzeGroesse(150, 30);
|
||||
highscoreFeld.setzePosition(960 - highscoreFeld.breite() / 2, 100);
|
||||
highscoreFeld.setzeSchriftStil(Schrift.FETT);
|
||||
highscoreFeld.entferneRand();
|
||||
|
||||
score = 0;
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public int getHighscore() {
|
||||
return highscore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
++score;
|
||||
scoreFeld.setzeText("Score: " + String.format("%03d",score));
|
||||
}
|
||||
}
|
||||
}
|
||||
120
Dino/src/github/stringBoy/Logic.java
Normal file
@@ -0,0 +1,120 @@
|
||||
package github.stringBoy;
|
||||
|
||||
import basis.*;
|
||||
import writer.Writer;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class Logic {
|
||||
private Frame startFrame;
|
||||
private Animation animation;
|
||||
private Frame gameFrame;
|
||||
private Dino dino;
|
||||
private Background background;
|
||||
private Obstacle cactus;
|
||||
private Frame endFrame;
|
||||
private CrashDetection crashDetection;
|
||||
private Highscore highscore;
|
||||
private Writer writer;
|
||||
//Threads
|
||||
private ExecutorService executor = Executors.newCachedThreadPool();
|
||||
|
||||
private Runnable[] runables;
|
||||
|
||||
private Tastatur keyboard;
|
||||
|
||||
boolean interrupted;
|
||||
|
||||
public Logic() {
|
||||
startFrame = new Frame(Color.BLACK,true);
|
||||
gameFrame = new Frame(true);
|
||||
gameFrame.visible(false);
|
||||
highscore = new Highscore();
|
||||
dino = new Dino(200, gameFrame.height() - 200);
|
||||
background = new Background(gameFrame, gameFrame.height() - 200);
|
||||
cactus = new Cactus(1800, gameFrame.height() - 200, highscore);
|
||||
animation = new Animation(dino);
|
||||
crashDetection = new CrashDetection(animation.getSprite(), (SpriteBild) cactus.getSprite(), dino, cactus);
|
||||
endFrame = new Frame(Color.RED,false);
|
||||
endFrame.visible(false);
|
||||
|
||||
writer = new Writer("Dino/src/res/.highscore.txt");
|
||||
|
||||
keyboard = new Tastatur();
|
||||
|
||||
runables = new Runnable[]{highscore, dino, crashDetection, cactus, animation};
|
||||
|
||||
interrupted = false;
|
||||
}
|
||||
|
||||
/*TODO: Make a function that enables the player to play the game
|
||||
multiple times without having to start a new game every Time.*/
|
||||
|
||||
public static void main(String[] args) {
|
||||
Logic l;
|
||||
l = new Logic();
|
||||
l.runThis();
|
||||
}
|
||||
|
||||
private void prepEndFrame(){
|
||||
if (highscore.getScore() < highscore.getHighscore()) {
|
||||
endFrame.writeText("YOU DIED!", true, 100, Farbe.WEISS, 400);
|
||||
endFrame.writeText("Dein Score: " + highscore.getScore(), true, 75, Farbe.WEISS, -endFrame.height() / 2 + 150);
|
||||
endFrame.writeText("Dein Highscore: " + highscore.getHighscore(), true, 25, Farbe.WEISS, -endFrame.height() / 2 + 100);
|
||||
} else {
|
||||
endFrame.writeText("YOU DIED!", true, 100, Farbe.WEISS, 400);
|
||||
}
|
||||
}
|
||||
|
||||
private void prepInterruptFrame(){
|
||||
endFrame.writeText("INTERRUPTED", true, 100, Farbe.WEISS, 0);
|
||||
endFrame.makeDinoInvis(true);
|
||||
}
|
||||
|
||||
public void runThis() {
|
||||
boolean stopped = false;
|
||||
startFrame.writeText("Press ENTER to start the game!", true, 75, Farbe.WEISS, 0);
|
||||
while (!stopped){
|
||||
Hilfe.kurzePause();
|
||||
if (keyboard.istGedrueckt(Zeichen.ENTER)){
|
||||
startFrame.visible(false);
|
||||
gameFrame.visible(true);
|
||||
stopped = true;
|
||||
}
|
||||
}
|
||||
background.drawGround();
|
||||
for (Runnable r : runables) {
|
||||
executor.execute(r);
|
||||
}
|
||||
new Sound();
|
||||
while (!executor.isShutdown()) {
|
||||
if (keyboard.istGedrueckt(Zeichen.ESC)) {
|
||||
executor.shutdown();
|
||||
executor.shutdownNow();
|
||||
interrupted = true;
|
||||
} else if (crashDetection.isCrashed()) {
|
||||
executor.shutdown();
|
||||
executor.shutdownNow();
|
||||
}
|
||||
}
|
||||
if (highscore.getHighscore() < highscore.getScore()) {
|
||||
writer.write("" + highscore.getScore(), false);
|
||||
System.out.println("NEW HIGHSCORE!");
|
||||
}
|
||||
if (!interrupted) {
|
||||
endFrame.visible(true);
|
||||
gameFrame.visible(false);
|
||||
prepEndFrame();
|
||||
Hilfe.warte(2000);
|
||||
System.exit(0);
|
||||
} else {
|
||||
endFrame.visible(true);
|
||||
gameFrame.visible(false);
|
||||
prepInterruptFrame();
|
||||
Hilfe.warte(2000);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Dino/src/github/stringBoy/Obstacle.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package github.stringBoy;
|
||||
|
||||
import basis.Bild;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public abstract class Obstacle implements Runnable {
|
||||
private Point obstacle;
|
||||
|
||||
public Obstacle(int x, int y) {
|
||||
obstacle = new Point(x, y);
|
||||
}
|
||||
|
||||
abstract public void move(int score);
|
||||
|
||||
abstract public void place();
|
||||
|
||||
abstract public void run();
|
||||
|
||||
abstract Bild getSprite();
|
||||
|
||||
public double getX() {
|
||||
return obstacle.getX();
|
||||
}
|
||||
|
||||
public void setX(int x) {
|
||||
obstacle.x = x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return obstacle.getY();
|
||||
}
|
||||
|
||||
public void setY(int y) {
|
||||
obstacle.y = y;
|
||||
}
|
||||
}
|
||||
|
||||
9
Dino/src/github/stringBoy/Sound.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package github.stringBoy;
|
||||
import javax.sound.sampled.*;
|
||||
public class Sound {
|
||||
Clip clip;
|
||||
public Sound(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
1
Dino/src/res/.highscore.txt
Executable file
@@ -0,0 +1 @@
|
||||
591
|
||||
BIN
Dino/src/res/Cactus.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
Dino/src/res/DeadDino.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
Dino/src/res/Dino.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Dino/src/res/DinoLinks.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Dino/src/res/DinoRechts.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Dino/src/res/Sonne.png
Normal file
|
After Width: | Height: | Size: 75 KiB |
BIN
Dino/src/res/jump.mp3
Normal file
BIN
Dino/src/res/jump2.wav
Normal file
11
FindTheHole/FindTheHole.iml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
27
FindTheHole/src/Distance.java
Normal file
@@ -0,0 +1,27 @@
|
||||
import basis.TextFeld;
|
||||
|
||||
import java.awt.*;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class Distance {
|
||||
TextFeld textFeld;
|
||||
Player player;
|
||||
Player target;
|
||||
DecimalFormat dc;
|
||||
public Distance(Player player, Player target, int frameWidth, Color framColor) {
|
||||
this.player = player;
|
||||
this.target = target;
|
||||
textFeld = new TextFeld();
|
||||
textFeld.setzeGroesse(200,50);
|
||||
textFeld.setzeHintergrundFarbe(framColor);
|
||||
textFeld.setzeSchriftFarbe(player.getColor());
|
||||
textFeld.setzePosition(frameWidth/2-textFeld.breite()/2,textFeld.hoehe());
|
||||
textFeld.setzeSchriftGroesse(25);
|
||||
textFeld.entferneRand();
|
||||
dc = new DecimalFormat("0");
|
||||
}
|
||||
|
||||
public void getValue(){
|
||||
textFeld.setzeText("Distance: " + dc.format(player.getPlayerPos().distance(target.getPlayerPos())));
|
||||
}
|
||||
}
|
||||
18
FindTheHole/src/Hitdetection.java
Normal file
@@ -0,0 +1,18 @@
|
||||
public class Hitdetection implements Runnable {
|
||||
Player player;
|
||||
Player target;
|
||||
public Hitdetection(Player player1, Player player2) {
|
||||
player = player1;
|
||||
target = player2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (!Thread.currentThread().isInterrupted()){
|
||||
if (player.getPlayerPos().distance(target.getPlayerPos())<50){
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
46
FindTheHole/src/Operator.java
Normal file
@@ -0,0 +1,46 @@
|
||||
import basis.Hilfe;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class Operator {
|
||||
private Output out;
|
||||
private Player player;
|
||||
private Player target;
|
||||
private Render playerRender;
|
||||
private Hitdetection hitdetection;
|
||||
private Distance distance;
|
||||
|
||||
private Runnable[] runnables;
|
||||
|
||||
private ExecutorService executor = Executors.newCachedThreadPool();
|
||||
public Operator() {
|
||||
out = new Output();
|
||||
player = new Player(Hilfe.zufall(50, 1870), Hilfe.zufall(50, 1030), Color.GREEN);
|
||||
target = new Player(Hilfe.zufall(50, 1870), Hilfe.zufall(50, 1030), Color.BLACK);
|
||||
playerRender = new Render(player);
|
||||
hitdetection = new Hitdetection(player,target);
|
||||
distance = new Distance(player,target,out.getFrame().breite(),
|
||||
out.getFrame().hintergrundFarbe());
|
||||
runnables = new Runnable[]{playerRender, hitdetection};
|
||||
}
|
||||
|
||||
private void operate() {
|
||||
player.move();
|
||||
for (Runnable r : runnables
|
||||
) {
|
||||
executor.execute(r);
|
||||
}
|
||||
while (true){
|
||||
player.move();
|
||||
distance.getValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Operator op = new Operator();
|
||||
op.operate();
|
||||
}
|
||||
}
|
||||
16
FindTheHole/src/Output.java
Normal file
@@ -0,0 +1,16 @@
|
||||
import basis.Farbe;
|
||||
import basis.Fenster;
|
||||
import basis.Hilfe;
|
||||
|
||||
public class Output {
|
||||
private Fenster frame;
|
||||
|
||||
public Output() {
|
||||
frame = new Fenster(Hilfe.monitorBreite(), Hilfe.monitorHoehe());
|
||||
frame.setzeHintergrundFarbe(Farbe.rgb(40, 40, 40));
|
||||
}
|
||||
|
||||
public Fenster getFrame() {
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
83
FindTheHole/src/Player.java
Normal file
@@ -0,0 +1,83 @@
|
||||
import basis.Hilfe;
|
||||
import basis.Maus;
|
||||
import basis.Stift;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class Player {
|
||||
private Point playerPos;
|
||||
private Maus mouse;
|
||||
private Stift pen;
|
||||
private Color c;
|
||||
|
||||
private Point[] positions;
|
||||
private double[] angles;
|
||||
private int times;
|
||||
private boolean updated;
|
||||
|
||||
public Player(int x, int y, Color color) {
|
||||
playerPos = new Point(x, y);
|
||||
mouse = new Maus();
|
||||
pen = new Stift();
|
||||
pen.bewegeAuf(playerPos.getX(),playerPos.getY());
|
||||
c = color;
|
||||
|
||||
times = 0;
|
||||
updated = false;
|
||||
positions = new Point[200];
|
||||
angles = new double[positions.length];
|
||||
}
|
||||
|
||||
public void move(){
|
||||
pen.dreheInRichtung(mouse.hPosition(),mouse.vPosition());
|
||||
pen.bewegeUm(1);
|
||||
playerPos.setLocation(pen.hPosition(),pen.vPosition());
|
||||
updated = false;
|
||||
|
||||
Point temp = new Point(playerPos);
|
||||
if (positions[positions.length-1] == null){
|
||||
positions[times] = temp;
|
||||
angles[times] = penOrientation();
|
||||
} else {
|
||||
System.arraycopy(positions,1,positions,0,positions.length-1);
|
||||
positions[positions.length-1] = temp;
|
||||
|
||||
System.arraycopy(angles,1,angles,0,angles.length-1);
|
||||
angles[angles.length-1] = penOrientation();
|
||||
}
|
||||
times++;
|
||||
Hilfe.warte(1);
|
||||
}
|
||||
|
||||
public double[] getAngles() {
|
||||
return angles;
|
||||
}
|
||||
|
||||
public double penOrientation(){
|
||||
return pen.winkel()+90;
|
||||
}
|
||||
|
||||
public boolean isUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
public Point[] getPositions() {
|
||||
return positions;
|
||||
}
|
||||
|
||||
public void setUpdated(boolean updated) {
|
||||
this.updated = updated;
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
return c;
|
||||
}
|
||||
|
||||
public Point getPlayerPos() {
|
||||
return playerPos;
|
||||
}
|
||||
|
||||
public void setPlayerPos(Point playerPos) {
|
||||
this.playerPos = playerPos;
|
||||
}
|
||||
}
|
||||
48
FindTheHole/src/Render.java
Normal file
@@ -0,0 +1,48 @@
|
||||
import basis.Hilfe;
|
||||
import basis.Muster;
|
||||
import basis.Stift;
|
||||
|
||||
public class Render implements Runnable {
|
||||
private Stift pen;
|
||||
private Player posPlayer;
|
||||
|
||||
private int times;
|
||||
|
||||
public Render(Player player) {
|
||||
pen = new Stift();
|
||||
pen.setzeFarbe(player.getColor());
|
||||
pen.setzeFuellMuster(Muster.GEFUELLT);
|
||||
|
||||
posPlayer = player;
|
||||
|
||||
times = 0;
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
pen.kreis(posPlayer.getPlayerPos().getX(), posPlayer.getPlayerPos().getY(), 20);
|
||||
pen.setzeTransparenzGrad(0.05);
|
||||
pen.kreis(posPlayer.getPlayerPos().getX(), posPlayer.getPlayerPos().getY(), 30);
|
||||
}
|
||||
|
||||
private void erase(){
|
||||
pen.radiere();
|
||||
pen.setzeFuellMuster(Muster.DURCHSICHTIG);
|
||||
pen.kreisBogen(posPlayer.getPositions()[0].getX(),posPlayer.getPositions()[0].getY(),30,posPlayer.getAngles()[0],180);
|
||||
pen.setzeFuellMuster(Muster.GEFUELLT);
|
||||
pen.normal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (!Thread.currentThread().isInterrupted()){
|
||||
if (!posPlayer.isUpdated()) {
|
||||
draw();
|
||||
posPlayer.setUpdated(true);
|
||||
if (posPlayer.getPositions()[posPlayer.getPositions().length-1] != null) {
|
||||
this.erase();
|
||||
}
|
||||
times++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Paint/Paint.iml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
45
Paint/src/Brush.java
Normal file
@@ -0,0 +1,45 @@
|
||||
import basis.*;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class Brush {
|
||||
Stift stift;
|
||||
|
||||
public Brush() {
|
||||
stift = new Stift();
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
stift.runter();
|
||||
}
|
||||
|
||||
public void dontDraw(){
|
||||
stift.hoch();
|
||||
}
|
||||
|
||||
public int getBreite(){
|
||||
return stift.linienBreite();
|
||||
}
|
||||
|
||||
public void setBreite(int breite){
|
||||
stift.setzeLinienBreite(breite);
|
||||
}
|
||||
|
||||
public void setzePosition(int x, int y){
|
||||
stift.bewegeAuf(x,y);
|
||||
}
|
||||
|
||||
public void color(int r, int g, int b){
|
||||
stift.setzeFarbe(Farbe.rgb(r,g,b));
|
||||
}
|
||||
|
||||
public Color getColor(){
|
||||
return stift.farbe();
|
||||
}
|
||||
|
||||
public void write(String text,int grösse){
|
||||
stift.setzeSchriftGroesse(grösse);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
28
Paint/src/Canvas.java
Normal file
@@ -0,0 +1,28 @@
|
||||
import basis.*;
|
||||
|
||||
public class Canvas
|
||||
{
|
||||
Fenster fenster;
|
||||
public Canvas(int width, int height, String name) {
|
||||
fenster = new Fenster(width, height);
|
||||
fenster.setzeTitel(name);
|
||||
}
|
||||
|
||||
public void setBackColor(int r, int g, int b){
|
||||
fenster.setzeHintergrundFarbe(Farbe.rgb(r,g,b));
|
||||
}
|
||||
|
||||
public java.awt.Color getColor(){
|
||||
return fenster.hintergrundFarbe();
|
||||
}
|
||||
|
||||
|
||||
public double wigth(){
|
||||
return fenster.breite();
|
||||
}
|
||||
|
||||
public void savePicture(){
|
||||
fenster.speichereZeichenflaeche();
|
||||
}
|
||||
|
||||
}
|
||||
53
Paint/src/ColorPicker.java
Normal file
@@ -0,0 +1,53 @@
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class ColorPicker {
|
||||
|
||||
private String input = null;
|
||||
|
||||
private String rgbValues(){
|
||||
String[] choices = {"Rot", "Grün", "Blau", "Lila", "Cyan", "Gelb", "Schwarz", "Weiß", "Rosa", "Selber RGB-Werte eintragen"};
|
||||
input = (String) JOptionPane.showInputDialog(null, "Choose now...",
|
||||
"Choose a Color", JOptionPane.QUESTION_MESSAGE, null, // Use default icon
|
||||
choices, // Initial choice
|
||||
null);
|
||||
|
||||
switch (input){
|
||||
case "Rot":
|
||||
return "255,0,0";
|
||||
case "Grün":
|
||||
return "0,255,0";
|
||||
case "Blau":
|
||||
return "0,0,255";
|
||||
case "Lila":
|
||||
return "187,13,222";
|
||||
case "Cyan":
|
||||
return "18,224,204";
|
||||
case "Gelb":
|
||||
return "246,255,0";
|
||||
case "Schwarz":
|
||||
return "0,0,0";
|
||||
case "Weiß":
|
||||
return "255,255,255";
|
||||
case "Rosa":
|
||||
return "255,84,133";
|
||||
case "Selber RGB-Werte eintragen":
|
||||
String n = JOptionPane.showInputDialog("Set value between 0 to 255 for RED,GREEN,BLUE");
|
||||
return n;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + input);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int[] choseColor(){
|
||||
String value = rgbValues();
|
||||
value = value.replaceAll("\\s", "");
|
||||
String[] parts = value.split(",");
|
||||
int[] rgb = new int[parts.length];
|
||||
for (int i = 0; i < parts.length; i++){
|
||||
rgb[i]= Integer.parseInt(parts[i]);
|
||||
}
|
||||
return rgb;
|
||||
}
|
||||
}
|
||||
|
||||
3
Paint/src/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: PaintMain
|
||||
|
||||
57
Paint/src/Output.java
Normal file
@@ -0,0 +1,57 @@
|
||||
import basis.*;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class Output {
|
||||
|
||||
TextFeld textFeldBreite;
|
||||
TextFeld textFeldFarbe;
|
||||
TextFeld textFeldSchrift;
|
||||
|
||||
public Output(double fensterbreite, int stiftbreite, Color stiftfarbe) {
|
||||
textFeldBreite = new TextFeld();
|
||||
textFeldBreite.setzeText("Stiftbreite: " + stiftbreite);
|
||||
textFeldBreite.setzeSchriftGroesse(20);
|
||||
textFeldBreite.setzeGroesse(textFeldBreite.text().length() * 11, 40);
|
||||
textFeldBreite.setzePosition(fensterbreite - textFeldBreite.breite() - 20, textFeldBreite.hoehe() / 2);
|
||||
textFeldBreite.entferneRand();
|
||||
textFeldBreite.setzeHintergrundFarbe(Farbe.DURCHSICHTIG);
|
||||
|
||||
textFeldSchrift = new TextFeld();
|
||||
textFeldSchrift.setzeText("Stiftfarbe: ");
|
||||
textFeldSchrift.setzeSchriftGroesse(20);
|
||||
textFeldSchrift.setzeGroesse(textFeldSchrift.text().length()*11, 40);
|
||||
textFeldSchrift.setzePosition(fensterbreite - textFeldSchrift.breite() - 40, 45);
|
||||
textFeldSchrift.setzeHintergrundFarbe(Farbe.DURCHSICHTIG);
|
||||
textFeldSchrift.entferneRand();
|
||||
|
||||
textFeldFarbe = new TextFeld();
|
||||
textFeldFarbe.setzeGroesse(20, 20);
|
||||
textFeldFarbe.setzePosition(fensterbreite - 65, 55);
|
||||
textFeldFarbe.setzeHintergrundFarbe(stiftfarbe);
|
||||
textFeldFarbe.entferneRand();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void updateBreite(int stiftbreite) {
|
||||
textFeldBreite.setzeText("Stiftbreite: " + stiftbreite);
|
||||
}
|
||||
|
||||
public void updateFarbe(Color stiftfarbe) {
|
||||
textFeldFarbe.setzeHintergrundFarbe(stiftfarbe);
|
||||
}
|
||||
|
||||
public void readable(Color hintergrundfarbe){
|
||||
System.out.println(hintergrundfarbe);
|
||||
if (hintergrundfarbe.equals(Color.black)){
|
||||
textFeldSchrift.setzeSchriftFarbe(Farbe.WEISS);
|
||||
textFeldBreite.setzeSchriftFarbe(Farbe.WEISS);
|
||||
} else{
|
||||
textFeldSchrift.setzeSchriftFarbe(Farbe.SCHWARZ);
|
||||
textFeldBreite.setzeSchriftFarbe(Farbe.SCHWARZ);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
100
Paint/src/PaintMain.java
Normal file
@@ -0,0 +1,100 @@
|
||||
import basis.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class PaintMain {
|
||||
private Canvas c;
|
||||
private Brush b;
|
||||
private Picture p;
|
||||
private ColorPicker color;
|
||||
private Output o;
|
||||
private Maus m;
|
||||
private Tastatur t;
|
||||
|
||||
private String text;
|
||||
private int number;
|
||||
|
||||
public PaintMain() {
|
||||
c = new Canvas(Hilfe.monitorBreite(), Hilfe.monitorHoehe(), "Paint");
|
||||
b = new Brush();
|
||||
b.setBreite(4);
|
||||
color = new ColorPicker();
|
||||
o = new Output(c.wigth(), b.getBreite(), b.getColor());
|
||||
m = new Maus();
|
||||
t = new Tastatur();
|
||||
text = null;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while (!t.istGedrueckt(Zeichen.ESC)) {
|
||||
Hilfe.kurzePause();
|
||||
b.setzePosition(m.hPosition(), m.vPosition());
|
||||
if (m.istGedrueckt()) {
|
||||
b.draw();
|
||||
} else {
|
||||
b.dontDraw();
|
||||
}
|
||||
if (t.istGedrueckt(Zeichen.PFEILOBEN) && b.getBreite() < 15) {
|
||||
b.setBreite(b.getBreite() + 1);
|
||||
Hilfe.pause(200);
|
||||
System.out.println("Breite: " + b.getBreite());
|
||||
o.updateBreite(b.getBreite());
|
||||
}
|
||||
|
||||
if (t.istGedrueckt(Zeichen.PFEILUNTEN) && b.getBreite() > 1) {
|
||||
b.setBreite(b.getBreite() - 1);
|
||||
Hilfe.pause(200);
|
||||
System.out.println("Breite: " + b.getBreite());
|
||||
o.updateBreite(b.getBreite());
|
||||
}
|
||||
|
||||
if (t.istGedrueckt('f')) {
|
||||
try {
|
||||
int[] rgb = color.choseColor();
|
||||
b.color(rgb[0], rgb[1], rgb[2]);
|
||||
o.updateFarbe(b.getColor());
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to pass values");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (t.istGedrueckt('s')) {
|
||||
c.savePicture();
|
||||
}
|
||||
|
||||
if (t.istGedrueckt('b')) {
|
||||
int[] rgb = color.choseColor();
|
||||
c.setBackColor(rgb[0], rgb[1], rgb[2]);
|
||||
o.readable(c.getColor());
|
||||
}
|
||||
|
||||
if (t.istGedrueckt('p')) {
|
||||
p = new Picture();
|
||||
p.ladeBild();
|
||||
}
|
||||
|
||||
if (t.istGedrueckt('t')) {
|
||||
b.write(text = JOptionPane.showInputDialog(null, "Type in the text you want to print on the screen") ,number = Integer.parseInt(JOptionPane.showInputDialog(null,"How big shall the text be?", 30)));
|
||||
Hilfe.warte(500);
|
||||
}
|
||||
}
|
||||
int n = JOptionPane.showConfirmDialog(null, "Möchten Sie das Projekt vor dem beenden speichern?", "Speichern?", 1, JOptionPane.WARNING_MESSAGE);
|
||||
if (n == 0) {
|
||||
c.savePicture();
|
||||
System.exit(0);
|
||||
} else if (n == 2) {
|
||||
run();
|
||||
} else {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
PaintMain m;
|
||||
m = new PaintMain();
|
||||
m.run();
|
||||
}
|
||||
}
|
||||
|
||||
16
Paint/src/Picture.java
Normal file
@@ -0,0 +1,16 @@
|
||||
import basis.*;
|
||||
public class Picture
|
||||
{
|
||||
Bild bild;
|
||||
public Picture(){
|
||||
bild = new Bild();
|
||||
bild.setzeSichtbar(false);
|
||||
bild.setzeMitMausVerschiebbar(true);
|
||||
}
|
||||
|
||||
public void ladeBild(){
|
||||
bild.ladeBild();
|
||||
bild.setzeSichtbar(true);
|
||||
}
|
||||
|
||||
}
|
||||
7
RaketeGame/.classpath
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/TOOLS"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
1
RaketeGame/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/bin/
|
||||
17
RaketeGame/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>RaketeGame</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
10
RaketeGame/RaketeGame.iml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<content url="file://$MODULE_DIR$/src" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
BIN
RaketeGame/src/RaketeGame/Landscape.java
Normal file
BIN
RaketeGame/src/RaketeGame/Lines.java
Normal file
BIN
RaketeGame/src/RaketeGame/Numbers.java
Normal file
BIN
RaketeGame/src/RaketeGame/Rocket.java
Normal file
BIN
RaketeGame/src/RaketeGame/SimulationRakete.java
Normal file
0
RaketeGame/src/RaketeGame/res/highscores.txt
Normal file
11
RollTheDice/RollTheDice.iml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
77
RollTheDice/src/NumberPicker.java
Normal file
@@ -0,0 +1,77 @@
|
||||
import javax.swing.*;
|
||||
|
||||
public class NumberPicker {
|
||||
|
||||
private String input = null;
|
||||
|
||||
public int chooseNums(){
|
||||
String[] choices = {"100", "1.000", "10.000", "100.000", "1.000.000", "10.000.000", "100.000.000", "1.000.000.000", "Eigener Wert"};
|
||||
input = (String) JOptionPane.showInputDialog(null, "How many times do you want to roll the dice?",
|
||||
"Choose a Number", JOptionPane.QUESTION_MESSAGE, null, // Use default icon
|
||||
choices, // Initial choice
|
||||
"100.000");
|
||||
|
||||
switch (input){
|
||||
case "100":
|
||||
return 100;
|
||||
case "1.000":
|
||||
return 1_000;
|
||||
case "10.000":
|
||||
return 10_000;
|
||||
case "100.000":
|
||||
return 100_000;
|
||||
case "1.000.000":
|
||||
return 1_000_000;
|
||||
case "10.000.000":
|
||||
return 10_000_000;
|
||||
case "100.000.000":
|
||||
return 100_000_000;
|
||||
case "1.000.000.000":
|
||||
return 1_000_000_000;
|
||||
case "Choose Number yourself":
|
||||
int n = Integer.parseInt(JOptionPane.showInputDialog("Set your custom value"));
|
||||
return n;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + input);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int chooseDices(){
|
||||
String[] choices = {"1", "2", "3", "4", "5", "6", "7", "8","9","10", "Custom value"};
|
||||
input = (String) JOptionPane.showInputDialog(null, "How many dices do you want to use?",
|
||||
"Choose a Number", JOptionPane.QUESTION_MESSAGE, null, // Use default icon
|
||||
choices, // Initial choice
|
||||
"2");
|
||||
|
||||
switch (input){
|
||||
case "1":
|
||||
return 1;
|
||||
case "2":
|
||||
return 2;
|
||||
case "3":
|
||||
return 3;
|
||||
case "4":
|
||||
return 4;
|
||||
case "5":
|
||||
return 5;
|
||||
case "6":
|
||||
return 6;
|
||||
case "7":
|
||||
return 7;
|
||||
case "8":
|
||||
return 8;
|
||||
case "9":
|
||||
return 9;
|
||||
case "10":
|
||||
return 10;
|
||||
case "Choose Number yourself":
|
||||
int n = Integer.parseInt(JOptionPane.showInputDialog("Set your custom value"));
|
||||
return n;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + input);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
93
RollTheDice/src/Output.java
Normal file
@@ -0,0 +1,93 @@
|
||||
import basis.*;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class Output {
|
||||
private Fenster frame;
|
||||
private Stift pen;
|
||||
private int values;
|
||||
private int nullSlots;
|
||||
private double YSCALE;
|
||||
private double MAXIMUM;
|
||||
private double GRIDSIZE;
|
||||
|
||||
public Output() {
|
||||
frame = new Fenster("Gamble Results",
|
||||
Hilfe.monitorBreite() / 2 - 400,
|
||||
Hilfe.monitorHoehe() / 2 - 400,
|
||||
800, 800);
|
||||
frame.setzeSichtbar(false);
|
||||
pen = new Stift();
|
||||
pen.setzeFarbe(Farbe.ROT);
|
||||
pen.setzeFuellMuster(Muster.GEFUELLT);
|
||||
}
|
||||
|
||||
public void setVisibility(boolean visible) {
|
||||
frame.setzeSichtbar(visible);
|
||||
}
|
||||
|
||||
public int[] trimArray(int[] array) {
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
if (array[i] != 0) {
|
||||
values++;
|
||||
} else if (values == 0) {
|
||||
nullSlots++;
|
||||
}
|
||||
}
|
||||
int[] trimmedArray = new int[values];
|
||||
for (int i = 0; i < trimmedArray.length; i++) {
|
||||
trimmedArray[i] = array[i + nullSlots];
|
||||
}
|
||||
return trimmedArray;
|
||||
}
|
||||
|
||||
private void makeScala(int[] array, long total) {
|
||||
int max = 0;
|
||||
for (int value : array
|
||||
) {
|
||||
if (max < value) {
|
||||
max = value;
|
||||
}
|
||||
}
|
||||
|
||||
MAXIMUM = max;
|
||||
|
||||
double average = max / array.length;
|
||||
YSCALE = frame.hoehe() / average;
|
||||
|
||||
GRIDSIZE = (frame.breite()-50) / array.length;
|
||||
|
||||
double zahl = 1;
|
||||
for (double i = 0; i < 0.8; i+=0.1) {
|
||||
TextFeld scalaY = new TextFeld(0, frame.hoehe()*i,50,20);
|
||||
scalaY.setzeHintergrundFarbe(Farbe.DURCHSICHTIG);
|
||||
scalaY.setzeEditierbar(false);
|
||||
scalaY.entferneRand();
|
||||
DecimalFormat df = new DecimalFormat("0");
|
||||
String partNumber = df.format(max*zahl);
|
||||
zahl-=0.1;
|
||||
Hilfe.pause(10);
|
||||
scalaY.setzeText(partNumber);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawGraph(int[] array, long total) {
|
||||
makeScala(array, total);
|
||||
Hilfe.kurzePause();
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
double yValue = ((double) array[i] / MAXIMUM) * (frame.hoehe() - 100);
|
||||
pen.rechteck(50+GRIDSIZE * i + GRIDSIZE / 4, frame.breite() - yValue - GRIDSIZE, GRIDSIZE / 2, yValue);
|
||||
Hilfe.kurzePause();
|
||||
|
||||
Hilfe.kurzePause();
|
||||
ZahlenFeld scalaX = new ZahlenFeld(50+GRIDSIZE * i + GRIDSIZE / 2 - 10, frame.breite() - GRIDSIZE, 20, 20);
|
||||
scalaX.setzeGroesse(GRIDSIZE, GRIDSIZE);
|
||||
scalaX.setzeHintergrundFarbe(Farbe.DURCHSICHTIG);
|
||||
scalaX.setzeEditierbar(false);
|
||||
scalaX.entferneRand();
|
||||
scalaX.setzeZahl(i + nullSlots + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
134
RollTheDice/src/rollThem.java
Normal file
@@ -0,0 +1,134 @@
|
||||
import basis.Hilfe;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class rollThem {
|
||||
|
||||
NumberPicker numberPicker;
|
||||
Output output;
|
||||
|
||||
int values[];
|
||||
int pairValues[];
|
||||
int times;
|
||||
int dices;
|
||||
int pairs;
|
||||
|
||||
public rollThem(){
|
||||
numberPicker = new NumberPicker();
|
||||
output = new Output();
|
||||
pairValues = new int[6];
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
rollThem roll;
|
||||
roll = new rollThem();
|
||||
roll.rollIt();
|
||||
}
|
||||
|
||||
private int scanNums() {
|
||||
try {
|
||||
this.times = numberPicker.chooseNums();
|
||||
this.dices = numberPicker.chooseDices();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private String pairProbsForOne(int pairs){
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
return df.format(((double)pairs/(double)times)*100) + "%";
|
||||
}
|
||||
|
||||
private String pairProbsForAll(){
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
return df.format(((double)pairs/(double)times)*100) + "%";
|
||||
}
|
||||
|
||||
private boolean allEqual(int[] array){
|
||||
int num1 = array[0];
|
||||
for (int i = 0; i < array.length; i++){
|
||||
if (num1 == (array[i])){
|
||||
continue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
pairValues[num1-1] += 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void startRolling(int times, int dices) {
|
||||
if (dices == 0 || times == 0) {
|
||||
System.err.println("Value of times or dices cant be 0");
|
||||
System.exit(1);
|
||||
}
|
||||
this.values = new int[dices * 6];
|
||||
for (int i = 0; i < times; i++) {
|
||||
int[] tempVals = new int[dices];
|
||||
int total = 0;
|
||||
for (int j = 0; j < dices; j++) {
|
||||
int value = roll();
|
||||
tempVals[j] = value;
|
||||
total += value;
|
||||
}
|
||||
if (allEqual(tempVals)){
|
||||
pairs++;
|
||||
}
|
||||
values[total - 1] += 1;
|
||||
}
|
||||
print();
|
||||
}
|
||||
|
||||
private void print(){
|
||||
System.out.println("---------- RESULTS -----------");
|
||||
System.out.println("NUMBERS:");
|
||||
for (int i = dices - 1; i < values.length; i++) {
|
||||
System.out.printf("%d: %s | %d%n", i + 1, probabilities()[i], values[i]);
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println("PAIRS:");
|
||||
for (int i = 0; i < pairValues.length; i++){
|
||||
System.out.printf("%d: %d | %s%n", i+1, pairValues[i], pairProbsForOne(pairValues[i]));
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println("STATS:");
|
||||
System.out.printf("Total Pairs: %d | %s%n", pairs, pairProbsForAll());
|
||||
System.out.printf("EyeSum: %d%n", totalEyeSum());
|
||||
System.out.printf("Average Number: %s", averageNum());
|
||||
output.setVisibility(true);
|
||||
output.drawGraph(output.trimArray(values), totalEyeSum());
|
||||
}
|
||||
|
||||
private long totalEyeSum() {
|
||||
long total = 0;
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
total += values[i] * i + i;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
private String averageNum() {
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
return df.format((double) totalEyeSum() / (double) times);
|
||||
}
|
||||
|
||||
private String[] probabilities() {
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
String[] probs = new String[values.length];
|
||||
for (int i = 0; i < probs.length; i++) {
|
||||
probs[i] = df.format(((double) values[i] / (double) times) * 100) + "%";
|
||||
}
|
||||
return probs;
|
||||
}
|
||||
|
||||
private int roll() {
|
||||
return Hilfe.zufall(1, 6);
|
||||
}
|
||||
|
||||
public void rollIt() {
|
||||
scanNums();
|
||||
startRolling(times, dices);
|
||||
}
|
||||
|
||||
}
|
||||
8
Rotkeappchengame/.classpath
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="Rotkeappchengame"/>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/TOOLS"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_65/jre/lib/ext/basisSwing130203UTF8.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
1
Rotkeappchengame/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/bin/
|
||||
17
Rotkeappchengame/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Rotkeappchengame</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
17
Rotkeappchengame/.project~HEAD
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Schule</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
17
Rotkeappchengame/.project~School
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Schule</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
11
Rotkeappchengame/.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
12
Rotkeappchengame/Rotkeappchengame.iml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/Rotkeappchengame" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="TOOLS" exported="" />
|
||||
</component>
|
||||
</module>
|
||||
107
Rotkeappchengame/Rotkeappchengame/game/Jaeger.java
Normal file
@@ -0,0 +1,107 @@
|
||||
package game;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
import com.sun.org.apache.regexp.internal.REDebugCompiler;
|
||||
|
||||
import basis.*;
|
||||
|
||||
public class Jaeger {
|
||||
private Stift meinStift;
|
||||
private Point jaegerPos;
|
||||
private Wolf wolf;
|
||||
private Point house;
|
||||
private Bild jaegerSpriteLinks;
|
||||
private Bild jaegerSpriteRechts;
|
||||
private int fbreite;
|
||||
private int fhoehe;
|
||||
private boolean alive;
|
||||
|
||||
public Jaeger(int fensterbreite, int fensterhoehe, Wolf wolfPos, Point phouse) {
|
||||
meinStift = new Stift();
|
||||
this.fbreite = fensterbreite;
|
||||
this.fhoehe = fensterhoehe;
|
||||
|
||||
alive = true;
|
||||
|
||||
meinStift.setzeSchriftGroesse(30);
|
||||
meinStift.setzeFuellMuster(Muster.GEFUELLT);
|
||||
meinStift.setzeFarbe(Farbe.rgb(180, 249, 167));
|
||||
|
||||
jaegerPos = new Point();
|
||||
|
||||
jaegerSpriteLinks = new Bild("res/Jaeger.png");
|
||||
jaegerSpriteLinks.setzeGroesse(jaegerSpriteLinks.breite() / 7.5, jaegerSpriteLinks.hoehe() / 7.5);
|
||||
|
||||
jaegerSpriteRechts = new Bild("res/Jaeger.png");
|
||||
jaegerSpriteRechts.setzeGroesse(jaegerSpriteRechts.breite() / 7.5, jaegerSpriteRechts.hoehe() / 7.5);
|
||||
jaegerSpriteRechts.spiegeleBild(false);
|
||||
|
||||
this.wolf = wolfPos;
|
||||
this.house = phouse;
|
||||
}
|
||||
|
||||
public double jaegerX() {
|
||||
return jaegerPos.getX();
|
||||
}
|
||||
|
||||
public double jaegerY() {
|
||||
return jaegerPos.getY();
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return alive;
|
||||
}
|
||||
|
||||
public void revive(){
|
||||
alive = true;
|
||||
jaegerSpriteLinks.setzeSichtbar(true);
|
||||
}
|
||||
|
||||
public void entferne() {
|
||||
jaegerSpriteLinks.setzeSichtbar(false);
|
||||
alive = false;
|
||||
}
|
||||
|
||||
public void richtung(boolean b) {
|
||||
if(b) {
|
||||
jaegerSpriteLinks.setzeSichtbar(false);
|
||||
jaegerSpriteRechts.setzeSichtbar(true);
|
||||
} else {
|
||||
jaegerSpriteLinks.setzeSichtbar(true);
|
||||
jaegerSpriteRechts.setzeSichtbar(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void position() {
|
||||
jaegerPos.setLocation(Hilfe.zufall((int) house.getX(),fbreite - jaegerSpriteLinks.breite()),
|
||||
Hilfe.zufall((int) house.getY(),fhoehe - jaegerSpriteLinks.hoehe()));
|
||||
jaegerSpriteLinks.setzePosition(jaegerPos.getX() - jaegerSpriteLinks.breite() / 2, jaegerPos.getY() - jaegerSpriteLinks.hoehe() / 1.5);
|
||||
jaegerSpriteRechts.setzePosition(jaegerPos.getX() - jaegerSpriteRechts.breite() / 2, jaegerPos.getY() - jaegerSpriteRechts.hoehe() / 1.5);
|
||||
}
|
||||
|
||||
public void zeichne() {
|
||||
this.position();
|
||||
meinStift.bewegeAuf(jaegerPos.getX(), jaegerPos.getY());
|
||||
meinStift.zeichneKreis(2);
|
||||
meinStift.setzeSchriftGroesse(30);
|
||||
}
|
||||
|
||||
public void bewege(int px) {
|
||||
meinStift.dreheInRichtung(wolf.wolfX(), wolf.wolfY());
|
||||
Hilfe.kurzePause();
|
||||
meinStift.dreheUm(Hilfe.zufall(-100, 100));
|
||||
meinStift.bewegeUm(px);
|
||||
jaegerSpriteLinks.setzePosition(jaegerPos.getX() - jaegerSpriteLinks.breite() / 2, jaegerPos.getY() - jaegerSpriteLinks.hoehe() / 1.5);
|
||||
jaegerSpriteRechts.setzePosition(jaegerPos.getX() - jaegerSpriteRechts.breite() / 2, jaegerPos.getY() - jaegerSpriteRechts.hoehe() / 1.5);
|
||||
jaegerPos.setLocation(meinStift.hPosition(), meinStift.vPosition());
|
||||
meinStift.setzeFarbe(Farbe.rgb(180, 249, 167));
|
||||
meinStift.setzeTransparenzGrad(0.02);
|
||||
meinStift.zeichneKreis(7.5);
|
||||
meinStift.setzeFarbe(Farbe.rgb(180, 249, 167));
|
||||
meinStift.setzeTransparenzGrad(1);
|
||||
meinStift.zeichneKreis(2);
|
||||
Hilfe.warte(10);
|
||||
}
|
||||
|
||||
}
|
||||
82
Rotkeappchengame/Rotkeappchengame/game/Rotkeappchen.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package game;
|
||||
|
||||
import java.awt.Point;
|
||||
import basis.*;
|
||||
|
||||
public class Rotkeappchen {
|
||||
private Stift meinStift;
|
||||
private Point housePos;
|
||||
private Point redPos;
|
||||
private Bild redSprite;
|
||||
private Bild deadRedSpriteBild;
|
||||
private int fbreite;
|
||||
private int fhoehe;
|
||||
private boolean alive;
|
||||
|
||||
public Rotkeappchen(int fensterbreite, int fensterhoehe, Point house) {
|
||||
meinStift = new Stift();
|
||||
this.fbreite = fensterbreite;
|
||||
this.fhoehe = fensterhoehe;
|
||||
alive = true;
|
||||
meinStift.setzeSchriftGroesse(30);
|
||||
meinStift.setzeFuellMuster(Muster.GEFUELLT);
|
||||
meinStift.setzeFarbe(Farbe.rgb(186, 59, 59));
|
||||
redPos = new Point();
|
||||
redSprite = new Bild("res/RotkeappchenSprite.png");
|
||||
redSprite.setzeGroesse(redSprite.breite() / 8, redSprite.hoehe() / 8);
|
||||
deadRedSpriteBild = new Bild("res/DeadRotkeappchenSprite.png");
|
||||
deadRedSpriteBild.setzeSichtbar(false);
|
||||
deadRedSpriteBild.setzeGroesse(deadRedSpriteBild.breite()/8, deadRedSpriteBild.hoehe()/8);
|
||||
this.housePos = house;
|
||||
}
|
||||
|
||||
public double redX() {
|
||||
return redPos.getX();
|
||||
}
|
||||
|
||||
public double redY() {
|
||||
return redPos.getY();
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return alive;
|
||||
}
|
||||
|
||||
public void revive(){
|
||||
alive = true;
|
||||
deadRedSpriteBild.setzeSichtbar(false);
|
||||
redSprite.setzeSichtbar(true);
|
||||
}
|
||||
|
||||
public void entferne() {
|
||||
redSprite.setzeSichtbar(false);
|
||||
alive = false;
|
||||
deadRedSpriteBild.setzePosition(redX()-deadRedSpriteBild.breite()/2, redY()-deadRedSpriteBild.hoehe()/2);
|
||||
deadRedSpriteBild.setzeSichtbar(true);
|
||||
}
|
||||
|
||||
public void position() {
|
||||
redPos.setLocation(Hilfe.zufall(50,(int) housePos.getX()), Hilfe.zufall(50, (int) housePos.getY()));
|
||||
redSprite.setzePosition(redPos.getX() - redSprite.breite() / 2, redPos.getY() - redSprite.hoehe() / 1.5);
|
||||
}
|
||||
|
||||
public void zeichne() {
|
||||
this.position();
|
||||
meinStift.bewegeAuf(redPos.getX(), redPos.getY());
|
||||
meinStift.zeichneKreis(1);
|
||||
meinStift.setzeSchriftGroesse(30);
|
||||
}
|
||||
|
||||
public void bewege(int px) {
|
||||
meinStift.dreheInRichtung(housePos.getX(), housePos.getY());
|
||||
meinStift.dreheUm(Hilfe.zufall(-100, 100));
|
||||
Hilfe.kurzePause();
|
||||
meinStift.bewegeUm(px);
|
||||
redSprite.setzePosition(redPos.getX() - redSprite.breite() / 2, redPos.getY() - redSprite.hoehe() / 1.5);
|
||||
redPos.setLocation(meinStift.hPosition(), meinStift.vPosition());
|
||||
meinStift.setzeFarbe(Farbe.rgb(186, 59, 59));
|
||||
meinStift.zeichneKreis(2);
|
||||
Hilfe.warte(10);
|
||||
}
|
||||
|
||||
}
|
||||
209
Rotkeappchengame/Rotkeappchengame/game/Wald.java
Normal file
@@ -0,0 +1,209 @@
|
||||
package game;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
import basis.*;
|
||||
import reader.ReaderRotkaeppchen;
|
||||
import writer.WriterRotkaeppchen;
|
||||
|
||||
public class Wald {
|
||||
private Fenster meinFenster;
|
||||
private Tastatur keyboard;
|
||||
private Point house;
|
||||
private Bild houseSprite;
|
||||
private Bild baumSprite;
|
||||
private Bild gunfireSprite;
|
||||
private Bild schriftJaeger;
|
||||
private Bild schriftWolfRed;
|
||||
private Bild schriftWolfOma;
|
||||
private Bild schriftRedDa;
|
||||
private Bild rundeEnde;
|
||||
private Bild explosionSprite;
|
||||
private WriterRotkaeppchen writer;
|
||||
private WriterRotkaeppchen analytics;
|
||||
private ReaderRotkaeppchen reader;
|
||||
private Rotkeappchen red;
|
||||
private Wolf wolf;
|
||||
private Jaeger jaeger;
|
||||
//----------------------------
|
||||
private int anzahl;
|
||||
|
||||
|
||||
public Wald() {
|
||||
meinFenster = new Fenster(1920, 1080);
|
||||
meinFenster.setzeTitel("Rotäppchen");
|
||||
meinFenster.setzeSichtbar(false);
|
||||
meinFenster.ladeBildInZeichenflaeche("res/Background500.png");
|
||||
|
||||
keyboard = new Tastatur();
|
||||
|
||||
anzahl = 1;
|
||||
|
||||
house = new Point();
|
||||
|
||||
rundeEnde = new Bild("res/RundeEnde.png");
|
||||
rundeEnde.setzeSichtbar(false);
|
||||
rundeEnde.setzeGroesse(meinFenster.breite(), meinFenster.hoehe());
|
||||
|
||||
houseSprite = new Bild("res/house.png");
|
||||
houseSprite.setzeGroesse(houseSprite.breite() / 5, houseSprite.hoehe() / 5);
|
||||
|
||||
gunfireSprite = new Bild("res/Gunfire.png");
|
||||
gunfireSprite.setzeSichtbar(false);
|
||||
gunfireSprite.setzeGroesse(gunfireSprite.breite()/4, gunfireSprite.hoehe()/4);
|
||||
|
||||
red = new Rotkeappchen(meinFenster.breite(), meinFenster.hoehe(), house);
|
||||
wolf = new Wolf(meinFenster.breite(), meinFenster.hoehe(), red, house);
|
||||
jaeger = new Jaeger(meinFenster.breite(), meinFenster.hoehe(), wolf, house);
|
||||
|
||||
|
||||
explosionSprite = new Bild("res/explosion.png");
|
||||
explosionSprite.setzeGroesse(explosionSprite.breite()/8, explosionSprite.hoehe()/8);
|
||||
explosionSprite.setzeSichtbar(false);
|
||||
|
||||
schriftJaeger = new Bild("res/JaegerGeschossen.png");
|
||||
schriftRedDa = new Bild("res/RotkaeppchenErreicht.png");
|
||||
schriftWolfOma = new Bild("res/WolfOmaGefressen.png");
|
||||
schriftWolfRed = new Bild("res/WolfGefressenSchrift.png");
|
||||
|
||||
schriftJaeger.setzeGroesse(schriftJaeger.breite()/2, schriftJaeger.hoehe()/2);
|
||||
schriftJaeger.setzePosition(meinFenster.breite()/2-schriftJaeger.breite()/2, meinFenster.hoehe()/2-400);
|
||||
|
||||
schriftRedDa.setzeGroesse(schriftRedDa.breite()/2, schriftRedDa.hoehe()/2);
|
||||
schriftRedDa.setzePosition(meinFenster.breite()/2-schriftRedDa.breite()/2, meinFenster.hoehe()/2-400);
|
||||
|
||||
schriftWolfOma.setzeGroesse(schriftWolfOma.breite()/2, schriftWolfOma.hoehe()/2);
|
||||
schriftWolfOma.setzePosition(meinFenster.breite()/2-schriftWolfOma.breite()/2, meinFenster.hoehe()/2-400);
|
||||
|
||||
schriftWolfRed.setzeGroesse(schriftWolfRed.breite()/2, schriftWolfRed.hoehe()/2);
|
||||
schriftWolfRed.setzePosition(meinFenster.breite()/2-schriftWolfRed.breite()/2, meinFenster.hoehe()/2-400);
|
||||
|
||||
schriftJaeger.setzeSichtbar(false);
|
||||
schriftRedDa.setzeSichtbar(false);
|
||||
schriftWolfOma.setzeSichtbar(false);
|
||||
schriftWolfRed.setzeSichtbar(false);
|
||||
|
||||
for (int i = 0; i < 200; i++) {
|
||||
baumSprite = new Bild("res/Baum.png");
|
||||
baumSprite.setzeGroesse(houseSprite.breite() / 1.5, houseSprite.hoehe() / 1.5);
|
||||
baumSprite.setzePosition(Hilfe.zufall(0, meinFenster.breite() - baumSprite.breite()),
|
||||
Hilfe.zufall(0, meinFenster.hoehe() - baumSprite.hoehe()));
|
||||
}
|
||||
|
||||
//writer = new WriterRotkaeppchen("statistics/Run.txt");
|
||||
//analytics = new WriterRotkaeppchen("statistics/Results.txt");
|
||||
//reader = new ReaderRotkaeppchen("statistics/Run.txt");
|
||||
|
||||
//writer.clear();
|
||||
//analytics.clear();
|
||||
}
|
||||
|
||||
public void zeichneHaus() {
|
||||
meinFenster.ladeBildInZeichenflaeche("res/Background500.png");
|
||||
meinFenster.setzeSichtbar(true);
|
||||
house.setLocation(Hilfe.zufall(50, meinFenster.breite() - 50), Hilfe.zufall(50, meinFenster.hoehe() - 50));
|
||||
houseSprite.setzePosition(house.getX() - houseSprite.breite() / 2, house.getY() - houseSprite.hoehe() / 2);
|
||||
}
|
||||
|
||||
public void fuehreAus() {
|
||||
System.out.println("------ " + "Runde " + anzahl + " ------");
|
||||
//writer.write("------ " + "Runde " + anzahl + " ------\n");
|
||||
this.zeichneHaus();
|
||||
red.zeichne();
|
||||
wolf.zeichne();
|
||||
jaeger.zeichne();
|
||||
while (!keyboard.istGedrueckt(Zeichen.ESC)) {
|
||||
if(red.isAlive()) {
|
||||
if(wolf.isAlive()) {
|
||||
red.bewege(3);
|
||||
}
|
||||
else {
|
||||
red.bewege(2);
|
||||
}
|
||||
}
|
||||
if(wolf.isAlive()) {
|
||||
jaeger.bewege(3);
|
||||
jaeger.richtung(wolf.wolfX() > jaeger.jaegerX());
|
||||
}
|
||||
|
||||
if(red.isAlive()) {
|
||||
if (((red.redX() > wolf.wolfX() - 15) && (red.redX() < wolf.wolfX() + 15)
|
||||
&& (red.redY() > wolf.wolfY() - 15 && red.redY() < wolf.wolfY() + 15))) {
|
||||
System.out.println("Der Wolf hat das Rotk<74>ppchen gefressen!");
|
||||
//writer.write("Der Wolf hat das Rotkaeppchen gefressen!\n");
|
||||
schriftWolfRed.setzeSichtbar(true);
|
||||
red.entferne();
|
||||
Hilfe.warte(1000);
|
||||
schriftWolfRed.setzeSichtbar(false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(wolf.isAlive()) {
|
||||
wolf.bewege(4);
|
||||
if ((wolf.wolfX() > jaeger.jaegerX() - 75 && wolf.wolfX() < jaeger.jaegerX() + 75)
|
||||
&& (wolf.wolfY() > jaeger.jaegerY() - 75 && wolf.wolfY() < jaeger.jaegerY() + 75)) {
|
||||
System.out.println("Der J<>ger hat den Wolf erschossen!");
|
||||
//writer.write("Der Jaeger hat den Wolf erschossen!\n");
|
||||
schriftJaeger.setzeSichtbar(true);
|
||||
wolf.entferne();
|
||||
explosionSprite.setzePosition(jaeger.jaegerX()-explosionSprite.breite()/2, jaeger.jaegerY()-explosionSprite.hoehe()/2);
|
||||
explosionSprite.setzeSichtbar(true);
|
||||
gunfireSprite.setzePosition(wolf.wolfX(), wolf.wolfY());
|
||||
gunfireSprite.setzeSichtbar(true);
|
||||
Hilfe.warte(1000);
|
||||
explosionSprite.setzeSichtbar(false);
|
||||
gunfireSprite.setzeSichtbar(false);
|
||||
schriftJaeger.setzeSichtbar(false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ((red.redX() == house.getX()) && (red.redY() == house.getY())) {
|
||||
System.out.println("Das Rotk<74>ppchen hat das Haus erreicht!");
|
||||
//writer.write("Das Rotkaeppchen hat das Haus erreicht!\n");
|
||||
schriftRedDa.setzeSichtbar(true);
|
||||
Hilfe.warte(1000);
|
||||
schriftRedDa.setzeSichtbar(false);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((wolf.wolfX() == house.getX()) && (wolf.wolfY() == house.getY())) {
|
||||
System.out.println("Der Wolf hat die Oma gefressen!");
|
||||
//writer.write("Der Wolf hat die Oma gefressen!\n");
|
||||
schriftWolfOma.setzeSichtbar(true);
|
||||
Hilfe.warte(1000);
|
||||
schriftWolfOma.setzeSichtbar(false);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!wolf.isAlive() && !red.isAlive()) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
System.err.println(" Runde beendet");
|
||||
//writer.write(" Runde beendet\n");
|
||||
rundeEnde.setzeSichtbar(true);
|
||||
//analytics.clear();
|
||||
//reader.read();
|
||||
//for(int i = 0; i < reader.stringsLength(); i++) {
|
||||
//analytics.write(reader.results()[i]);
|
||||
//}
|
||||
Hilfe.warte(1000);
|
||||
meinFenster.loescheAlles();
|
||||
rundeEnde.setzeSichtbar(false);
|
||||
wolf.revive();
|
||||
jaeger.revive();
|
||||
red.revive();
|
||||
anzahl++;
|
||||
this.fuehreAus();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Wald wald = new Wald();
|
||||
wald.fuehreAus();
|
||||
}
|
||||
|
||||
}
|
||||
120
Rotkeappchengame/Rotkeappchengame/game/Wolf.java
Normal file
@@ -0,0 +1,120 @@
|
||||
package game;
|
||||
|
||||
import java.awt.Point;
|
||||
import basis.*;
|
||||
|
||||
public class Wolf {
|
||||
private Stift meinStift;
|
||||
private Point wolfPos;
|
||||
private Rotkeappchen red;
|
||||
private Point house;
|
||||
private Bild wolfSprite;
|
||||
private Bild deadWolfSprite;
|
||||
private int fbreite;
|
||||
private int fhoehe;
|
||||
private boolean alive;
|
||||
|
||||
public Wolf(int fensterbreite, int fensterhoehe, Rotkeappchen redPos, Point phouse) {
|
||||
meinStift = new Stift();
|
||||
this.fbreite = fensterbreite;
|
||||
this.fhoehe = fensterhoehe;
|
||||
alive = true;
|
||||
meinStift.setzeSchriftGroesse(30);
|
||||
meinStift.setzeFuellMuster(Muster.GEFUELLT);
|
||||
meinStift.setzeFarbe(Farbe.rgb(126,126,126));
|
||||
wolfPos = new Point();
|
||||
wolfSprite = new Bild("res/Wolf.png");
|
||||
wolfSprite.setzeGroesse(wolfSprite.breite() / 13, wolfSprite.hoehe() / 13);
|
||||
deadWolfSprite = new Bild("res/DeadWolf.png");
|
||||
deadWolfSprite.setzeSichtbar(false);
|
||||
deadWolfSprite.setzeGroesse(deadWolfSprite.breite() / 13, deadWolfSprite.hoehe() / 13);
|
||||
this.red = redPos;
|
||||
this.house = phouse;
|
||||
}
|
||||
|
||||
public double wolfX() {
|
||||
return wolfPos.getX();
|
||||
}
|
||||
|
||||
public double wolfY() {
|
||||
return wolfPos.getY();
|
||||
}
|
||||
|
||||
public void position() {
|
||||
wolfPos.setLocation(Hilfe.zufall((int) house.getX(),fbreite - wolfSprite.breite()),
|
||||
Hilfe.zufall((int) house.getY(),fhoehe - wolfSprite.hoehe()));
|
||||
wolfSprite.setzePosition(wolfPos.getX() - wolfSprite.breite() / 2, wolfPos.getY() - wolfSprite.hoehe() / 1.5);
|
||||
}
|
||||
|
||||
public void zeichne() {
|
||||
this.position();
|
||||
meinStift.bewegeAuf(wolfPos.getX(), wolfPos.getY());
|
||||
meinStift.zeichneKreis(2);
|
||||
meinStift.setzeSchriftGroesse(30);
|
||||
}
|
||||
|
||||
public void entferne() {
|
||||
wolfSprite.setzeSichtbar(false);
|
||||
deadWolfSprite.setzePosition(wolfX()-deadWolfSprite.breite()/2, wolfY()-deadWolfSprite.hoehe()/2);
|
||||
deadWolfSprite.setzeSichtbar(true);
|
||||
alive = false;
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return alive;
|
||||
}
|
||||
|
||||
public void revive(){
|
||||
alive = true;
|
||||
deadWolfSprite.setzeSichtbar(false);
|
||||
wolfSprite.setzeSichtbar(true);
|
||||
}
|
||||
|
||||
public void bewege(int px) {
|
||||
if(red.isAlive()) {
|
||||
meinStift.dreheInRichtung(red.redX(), red.redY());
|
||||
meinStift.dreheUm(Hilfe.zufall(-100, 100));
|
||||
Hilfe.kurzePause();
|
||||
meinStift.bewegeUm(px);
|
||||
wolfSprite.setzePosition(wolfPos.getX() - wolfSprite.breite() / 2, wolfPos.getY() - wolfSprite.hoehe() / 1.5);
|
||||
wolfPos.setLocation(meinStift.hPosition(), meinStift.vPosition());
|
||||
meinStift.setzeFarbe(Farbe.rgb(126, 126, 126));
|
||||
meinStift.setzeTransparenzGrad(0.02);
|
||||
meinStift.zeichneKreis(7.5);
|
||||
meinStift.setzeFarbe(Farbe.rgb(126, 126, 126));
|
||||
meinStift.setzeTransparenzGrad(1);
|
||||
meinStift.zeichneKreis(2);
|
||||
Hilfe.warte(10);
|
||||
}
|
||||
else {
|
||||
meinStift.dreheInRichtung(house.getX(), house.getY());
|
||||
meinStift.dreheUm(Hilfe.zufall(-100, 100));
|
||||
Hilfe.kurzePause();
|
||||
meinStift.bewegeUm(px);
|
||||
wolfSprite.setzePosition(wolfPos.getX() - wolfSprite.breite() / 2, wolfPos.getY() - wolfSprite.hoehe() / 1.5);
|
||||
wolfPos.setLocation(meinStift.hPosition(), meinStift.vPosition());
|
||||
meinStift.setzeFarbe(Farbe.rgb(126, 126, 126));
|
||||
meinStift.setzeTransparenzGrad(0.02);
|
||||
meinStift.zeichneKreis(7.5);
|
||||
meinStift.setzeFarbe(Farbe.rgb(126, 126, 126));
|
||||
meinStift.setzeTransparenzGrad(1);
|
||||
meinStift.zeichneKreis(2);
|
||||
Hilfe.warte(10);
|
||||
|
||||
meinStift.dreheInRichtung(house.getX(), house.getY());
|
||||
meinStift.dreheUm(Hilfe.zufall(-100, 100));
|
||||
Hilfe.kurzePause();
|
||||
meinStift.bewegeUm(px);
|
||||
wolfSprite.setzePosition(wolfPos.getX() - wolfSprite.breite() / 2, wolfPos.getY() - wolfSprite.hoehe() / 1.5);
|
||||
wolfPos.setLocation(meinStift.hPosition(), meinStift.vPosition());
|
||||
meinStift.setzeFarbe(Farbe.rgb(126, 126, 126));
|
||||
meinStift.setzeTransparenzGrad(0.02);
|
||||
meinStift.zeichneKreis(7.5);
|
||||
meinStift.setzeFarbe(Farbe.rgb(126, 126, 126));
|
||||
meinStift.setzeTransparenzGrad(1);
|
||||
meinStift.zeichneKreis(2);
|
||||
Hilfe.warte(10);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
BIN
Rotkeappchengame/Rotkeappchengame/res/Background1000.png
Normal file
|
After Width: | Height: | Size: 290 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/Background500.png
Normal file
|
After Width: | Height: | Size: 156 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/Background750.png
Normal file
|
After Width: | Height: | Size: 229 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/Baum.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/DeadRotkeappchenSprite.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/DeadWolf.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/Gunfire.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/Jaeger.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/JaegerGeschossen.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/Koeder.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/RotkaeppchenErreicht.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/RotkeappchenSprite.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/RundeEnde.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/Wolf.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/WolfGefressenSchrift.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/WolfOmaGefressen.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/explosion.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
Rotkeappchengame/Rotkeappchengame/res/house.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
@@ -0,0 +1,8 @@
|
||||
Gesamte Aktionen: 10719293
|
||||
Der Wolf hat das Rotk<74>ppchen 1913319-mal gefressen. (18%)
|
||||
Der Wolf hat die Oma 947675-mal gefressen. (9%)
|
||||
Der J<>ger hat den Wolf 3726615-mal erschossen. (35%)
|
||||
Das Rotk<74>ppchen hat das Haus der Oma 4131684-mal erreicht. (39%)
|
||||
Not matched: 12093006 / Gesamt: 22812299 (53%)
|
||||
Runden: 6046503
|
||||
Male durchgelaufen: 3477.0
|
||||
13128
Rotkeappchengame/Rotkeappchengame/statistics/2019_06_03_Run.txt
Normal file
8
Rotkeappchengame/Rotkeappchengame/statistics/Results.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
Gesamte Aktionen: 2
|
||||
Der Wolf hat das Rotk<74>ppchen 0-mal gefressen. (0%)
|
||||
Der Wolf hat die Oma 0-mal gefressen. (0%)
|
||||
Der J<>ger hat den Wolf 1-mal erschossen. (50%)
|
||||
Das Rotk<74>ppchen hat das Haus der Oma 1-mal erreicht. (50%)
|
||||
Not matched: 2 / Gesamt: 4 (50%)
|
||||
Runden: 1
|
||||
Male durchgelaufen: 1.0
|
||||
3070
Rotkeappchengame/Rotkeappchengame/statistics/Runde890_Runde1698.txt
Normal file
11
SpaceFighter/SpaceFighter.iml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
920
SpaceFighter/src/MAINnormal.java
Normal file
@@ -0,0 +1,920 @@
|
||||
import basis.Bild;
|
||||
import basis.Farbe;
|
||||
import basis.Fenster;
|
||||
import basis.Hilfe;
|
||||
import basis.Maus;
|
||||
import basis.Tastatur;
|
||||
|
||||
public class MAINnormal {
|
||||
private Fenster fenster = new Fenster(1920, 1080);
|
||||
private rocket Rocket;
|
||||
private Bild star;
|
||||
private Bild ScoreStar1;
|
||||
private Bild ScoreStar2;
|
||||
private Bild ScoreStar3;
|
||||
private Bild ScoreStar4;
|
||||
private Bild ScoreStar5;
|
||||
private Bild ScoreStar6;
|
||||
private Bild ScoreStar7;
|
||||
private Bild ScoreStar8;
|
||||
private Bild ScoreStar9;
|
||||
private Bild ScoreStar10;
|
||||
private Bild Deathstar;
|
||||
private Bild BadStar3;
|
||||
private Bild BadStar6;
|
||||
private Bild BadStar9;
|
||||
private Bild PreStar1;
|
||||
private Bild PreStar2;
|
||||
private Bild PreStar3;
|
||||
private Bild PreStar4;
|
||||
private Bild PreStar5;
|
||||
private Bild PreStar6;
|
||||
private Bild PreStar7;
|
||||
private Bild PreStar8;
|
||||
private Bild PreStar9;
|
||||
private Bild PreStar10;
|
||||
private Bild rocket;
|
||||
private Bild rocketLinks;
|
||||
private Bild rocketRunter;
|
||||
private Bild rocketHoch;
|
||||
private Bild laserbeam;
|
||||
private Bild laserbeamup;
|
||||
private Bild Meteorite;
|
||||
private Stern stern;
|
||||
private stift stift;
|
||||
private Tastatur keyboard;
|
||||
private Maus maus;
|
||||
private Meteorite stein;
|
||||
boolean exit;
|
||||
boolean RESTART;
|
||||
boolean hit;
|
||||
boolean SchussRechts;
|
||||
boolean SchussLinks;
|
||||
boolean SchussOben;
|
||||
boolean SchussUnten;
|
||||
double speed;
|
||||
double firespeedRechts;
|
||||
double firespeedLinks;
|
||||
double firespeedOben;
|
||||
double firespeedUnten;
|
||||
int pause;
|
||||
int x;
|
||||
int y;
|
||||
int g;
|
||||
int l;
|
||||
int k;
|
||||
int p;
|
||||
int m;
|
||||
double i;
|
||||
double d;
|
||||
double e;
|
||||
double f;
|
||||
double h;
|
||||
String LocationRakete1 = "res/rocket1.png";
|
||||
String LocationRakete2 = "res/rocket2.png";
|
||||
String LocationRakete3 = "res/rocket3.png";
|
||||
String LocationStern = "res/stern.png";
|
||||
String LocationDeathStar = "res/stern.png";
|
||||
String LocationPreStar = "res/sternvorlage.png";
|
||||
String BadStar = "res/Badstern.png";
|
||||
String LocationBackground = "res/galaxy.jpg";
|
||||
String wasted = "res/Red-Rope-You-Died.jpg";
|
||||
String laser = "res/LASERBEAM.png";
|
||||
String meteorite = "res/meteorite-cartoon-icon-white-background-79741243.png";
|
||||
|
||||
public MAINnormal() {
|
||||
this.fenster.setzeTitel("Rocket");
|
||||
this.keyboard = new Tastatur();
|
||||
this.maus = new Maus();
|
||||
}
|
||||
|
||||
private void ScoreStar() {
|
||||
int i = (int)this.stift.getScore();
|
||||
this.PreStar1.setzePosition((double)this.x, (double)this.y);
|
||||
this.PreStar2.setzePosition((double)(this.x + 50), (double)this.y);
|
||||
this.PreStar3.setzePosition((double)(this.x + 100), (double)this.y);
|
||||
this.PreStar4.setzePosition((double)(this.x + 150), (double)this.y);
|
||||
this.PreStar5.setzePosition((double)(this.x + 200), (double)this.y);
|
||||
this.PreStar6.setzePosition((double)(this.x + 250), (double)this.y);
|
||||
this.PreStar7.setzePosition((double)(this.x + 300), (double)this.y);
|
||||
this.PreStar8.setzePosition((double)(this.x + 350), (double)this.y);
|
||||
this.PreStar9.setzePosition((double)(this.x + 400), (double)this.y);
|
||||
this.PreStar10.setzePosition((double)(this.x + 450), (double)this.y);
|
||||
this.x = this.fenster.breite() / 2 - 300;
|
||||
this.y = this.fenster.hoehe() - 60;
|
||||
switch(i) {
|
||||
case 1:
|
||||
this.PreStar1.setzeSichtbar(false);
|
||||
this.ScoreStar1.setzeSichtbar(true);
|
||||
this.ScoreStar1.setzeGroesse(40.0D, 40.0D);
|
||||
this.ScoreStar1.setzePosition((double)this.x, (double)this.y);
|
||||
break;
|
||||
case 2:
|
||||
this.PreStar2.setzeSichtbar(false);
|
||||
this.ScoreStar2.setzeSichtbar(true);
|
||||
this.ScoreStar2.setzeGroesse(40.0D, 40.0D);
|
||||
this.ScoreStar2.setzePosition((double)(this.x + 50), (double)this.y);
|
||||
break;
|
||||
case 3:
|
||||
this.PreStar3.setzeSichtbar(false);
|
||||
this.ScoreStar3.setzeSichtbar(true);
|
||||
this.ScoreStar3.setzeGroesse(40.0D, 40.0D);
|
||||
this.ScoreStar3.setzePosition((double)(this.x + 100), (double)this.y);
|
||||
break;
|
||||
case 4:
|
||||
this.PreStar4.setzeSichtbar(false);
|
||||
this.ScoreStar4.setzeSichtbar(true);
|
||||
this.ScoreStar4.setzeGroesse(40.0D, 40.0D);
|
||||
this.ScoreStar4.setzePosition((double)(this.x + 150), (double)this.y);
|
||||
break;
|
||||
case 5:
|
||||
this.PreStar5.setzeSichtbar(false);
|
||||
this.ScoreStar5.setzeSichtbar(true);
|
||||
this.ScoreStar5.setzeGroesse(40.0D, 40.0D);
|
||||
this.ScoreStar5.setzePosition((double)(this.x + 200), (double)this.y);
|
||||
break;
|
||||
case 6:
|
||||
this.PreStar6.setzeSichtbar(false);
|
||||
this.ScoreStar6.setzeSichtbar(true);
|
||||
this.ScoreStar6.setzeGroesse(40.0D, 40.0D);
|
||||
this.ScoreStar6.setzePosition((double)(this.x + 250), (double)this.y);
|
||||
break;
|
||||
case 7:
|
||||
this.PreStar7.setzeSichtbar(false);
|
||||
this.ScoreStar7.setzeSichtbar(true);
|
||||
this.ScoreStar7.setzeGroesse(40.0D, 40.0D);
|
||||
this.ScoreStar7.setzePosition((double)(this.x + 300), (double)this.y);
|
||||
break;
|
||||
case 8:
|
||||
this.PreStar8.setzeSichtbar(false);
|
||||
this.ScoreStar8.setzeSichtbar(true);
|
||||
this.ScoreStar8.setzeGroesse(40.0D, 40.0D);
|
||||
this.ScoreStar8.setzePosition((double)(this.x + 350), (double)this.y);
|
||||
break;
|
||||
case 9:
|
||||
this.PreStar9.setzeSichtbar(false);
|
||||
this.ScoreStar9.setzeSichtbar(true);
|
||||
this.ScoreStar9.setzeGroesse(40.0D, 40.0D);
|
||||
this.ScoreStar9.setzePosition((double)(this.x + 400), (double)this.y);
|
||||
break;
|
||||
case 10:
|
||||
this.PreStar10.setzeSichtbar(false);
|
||||
this.ScoreStar10.setzeSichtbar(true);
|
||||
this.ScoreStar10.setzeGroesse(40.0D, 40.0D);
|
||||
this.ScoreStar10.setzePosition((double)(this.x + 450), (double)this.y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void RocketChange() {
|
||||
if (this.stift.getScore() == 5.0D && this.g == 0) {
|
||||
Hilfe.warte(500L);
|
||||
this.rocket.setzeSichtbar(false);
|
||||
this.rocketLinks.setzeSichtbar(false);
|
||||
this.rocketHoch.setzeSichtbar(false);
|
||||
this.rocketRunter.setzeSichtbar(false);
|
||||
this.rocket = new Bild(this.LocationRakete2);
|
||||
this.rocket.setzeGroesse(200.0D, 100.0D);
|
||||
this.rocketLinks = new Bild(this.LocationRakete2);
|
||||
this.rocket.dreheUmOhneGroessenAnpassung(180.0D);
|
||||
this.rocketLinks.setzeGroesse(200.0D, 100.0D);
|
||||
this.rocketHoch = new Bild(this.LocationRakete3);
|
||||
this.rocketHoch.setzeGroesse(100.0D, 200.0D);
|
||||
this.rocketRunter = new Bild(this.LocationRakete3);
|
||||
this.rocketRunter.dreheUmMitGroessenAnpassung(180.0D);
|
||||
this.rocketRunter.setzeGroesse(100.0D, 200.0D);
|
||||
this.rocketLinks.setzeSichtbar(false);
|
||||
this.rocketRunter.setzeSichtbar(false);
|
||||
this.rocketHoch.setzeSichtbar(false);
|
||||
++this.g;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void DeathStar3() {
|
||||
if (this.stift.getScore() == 3.0D && this.l == 0 && !this.Meteorite.istSichtbar()) {
|
||||
this.Deathstar.setzeSichtbar(true);
|
||||
this.Deathstar.setzeGroesse(this.stern.getSize(), this.stern.getSize());
|
||||
this.Deathstar.setzePosition((double)Hilfe.zufall(100, Hilfe.zufall(1920 - 100, this.stern.getY() - 5)), (double)Hilfe.zufall(100, Hilfe.monitorHoehe() - 100));
|
||||
++this.l;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void DeathStar6() {
|
||||
if (this.stift.getScore() == 6.0D && this.k == 0 && !this.Meteorite.istSichtbar()) {
|
||||
this.Deathstar.setzeSichtbar(true);
|
||||
this.Deathstar.setzeGroesse(this.stern.getSize(), this.stern.getSize());
|
||||
this.Deathstar.setzePosition((double)Hilfe.zufall(100, Hilfe.zufall(1920 - 100, this.stern.getY() - 5)), (double)Hilfe.zufall(100, Hilfe.monitorHoehe() - 100));
|
||||
++this.k;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void DeathStar9() {
|
||||
if (this.stift.getScore() == 9.0D && this.p == 0 && !this.Meteorite.istSichtbar()) {
|
||||
this.Deathstar.setzeSichtbar(true);
|
||||
this.Deathstar.setzeGroesse(this.stern.getSize(), this.stern.getSize());
|
||||
this.Deathstar.setzePosition((double)Hilfe.zufall(100, Hilfe.zufall(1920 - 100, this.stern.getY() - 5)), (double)Hilfe.zufall(100, Hilfe.monitorHoehe() - 100));
|
||||
++this.p;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OldRocketDimensions() {
|
||||
if (this.stift.getScore() < 5.0D) {
|
||||
this.rocket.setzeGroesse(200.0D * this.Rocket.getStreckung(), 200.0D * this.Rocket.getStreckung());
|
||||
this.rocketLinks.setzeGroesse(200.0D * this.Rocket.getStreckung(), 200.0D * this.Rocket.getStreckung());
|
||||
this.rocketRunter.setzeGroesse(200.0D * this.Rocket.getStreckung(), 200.0D * this.Rocket.getStreckung());
|
||||
this.rocketHoch.setzeGroesse(200.0D * this.Rocket.getStreckung(), 200.0D * this.Rocket.getStreckung());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void PositionRocket() {
|
||||
this.rocket.setzePosition(this.Rocket.getxPos() - 129.0D * this.Rocket.getStreckung(), this.Rocket.getyPos() - 98.0D * this.Rocket.getStreckung());
|
||||
this.rocketLinks.setzePosition(this.Rocket.getxPos() - 129.0D * this.Rocket.getStreckung(), this.Rocket.getyPos() - 98.0D * this.Rocket.getStreckung());
|
||||
this.rocketRunter.setzePosition(this.Rocket.getxPos() - 129.0D * this.Rocket.getStreckung(), this.Rocket.getyPos() - 98.0D * this.Rocket.getStreckung());
|
||||
this.rocketHoch.setzePosition(this.Rocket.getxPos() - 129.0D * this.Rocket.getStreckung(), this.Rocket.getyPos() - 98.0D * this.Rocket.getStreckung());
|
||||
}
|
||||
|
||||
private void KollisionGut() {
|
||||
if ((this.laserbeam.kollisionErkanntMit(this.Meteorite) || this.laserbeamup.kollisionErkanntMit(this.Meteorite)) && (this.laserbeam.istSichtbar() || this.laserbeamup.istSichtbar())) {
|
||||
this.laserbeam.setzeSichtbar(false);
|
||||
this.laserbeamup.setzeSichtbar(false);
|
||||
this.hit = true;
|
||||
this.Meteorite.setzeSichtbar(false);
|
||||
this.star.setzeSichtbar(true);
|
||||
}
|
||||
|
||||
if (this.hit) {
|
||||
if (this.stift.getScore() == 3.0D) {
|
||||
this.DeathStar3();
|
||||
}
|
||||
|
||||
if (this.stift.getScore() == 6.0D) {
|
||||
this.DeathStar6();
|
||||
}
|
||||
|
||||
if (this.stift.getScore() == 9.0D) {
|
||||
this.DeathStar9();
|
||||
}
|
||||
|
||||
if ((this.rocket.kollisionErkanntMit(this.star) || this.laserbeam.kollisionErkanntMit(this.star) || this.laserbeamup.kollisionErkanntMit(this.star)) && !this.Meteorite.istSichtbar()) {
|
||||
this.stein.pickLocation();
|
||||
this.stern.pickLocation();
|
||||
this.stern.size();
|
||||
this.stift.setScore(this.stift.getScore() + 1.0D);
|
||||
this.hit = false;
|
||||
this.Meteorite.setzeSichtbar(true);
|
||||
this.star.setzeSichtbar(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void KollisionSchlecht() {
|
||||
if ((this.hit = true) && (this.stift.getScore() == 3.0D || this.stift.getScore() == 6.0D || this.stift.getScore() == 9.0D) && !this.Meteorite.istSichtbar() && (this.rocket.kollisionErkanntMit(this.Deathstar) || this.laserbeam.kollisionErkanntMit(this.Deathstar) || this.laserbeamup.kollisionErkanntMit(this.Deathstar))) {
|
||||
this.Erase();
|
||||
this.ScoreStar10.setzeSichtbar(false);
|
||||
switch((int)this.stift.getScore()) {
|
||||
case 3:
|
||||
this.PreStar4.setzeSichtbar(false);
|
||||
this.BadStar3.setzeSichtbar(true);
|
||||
this.BadStar3.setzeGroesse(40.0D, 40.0D);
|
||||
this.BadStar3.setzePosition((double)(this.x + 150), (double)this.y);
|
||||
break;
|
||||
case 6:
|
||||
this.PreStar7.setzeSichtbar(false);
|
||||
this.BadStar6.setzeSichtbar(true);
|
||||
this.BadStar6.setzeGroesse(40.0D, 40.0D);
|
||||
this.BadStar6.setzePosition((double)(this.x + 300), (double)this.y);
|
||||
break;
|
||||
case 9:
|
||||
this.PreStar10.setzeSichtbar(false);
|
||||
this.BadStar9.setzeSichtbar(true);
|
||||
this.BadStar9.setzeGroesse(40.0D, 40.0D);
|
||||
this.BadStar9.setzePosition((double)(this.x + 450), (double)this.y);
|
||||
}
|
||||
|
||||
while(!this.keyboard.istGedrueckt('\n')) {
|
||||
if (this.m == 0) {
|
||||
this.fenster.ladeBildInZeichenflaeche(this.wasted);
|
||||
++this.m;
|
||||
}
|
||||
|
||||
this.stift.lose();
|
||||
if (this.keyboard.istGedrueckt('\u001b')) {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
this.fenster.setzeSichtbar(false);
|
||||
MAINnormal Rocket = new MAINnormal();
|
||||
Rocket.fuehreAus();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Movement() {
|
||||
if (this.keyboard.istGedrueckt('w')) {
|
||||
this.Rocket.setyPos(this.Rocket.getyPos() - this.speed);
|
||||
this.rocketRunter.setzeSichtbar(false);
|
||||
this.rocket.setzeSichtbar(false);
|
||||
this.rocketLinks.setzeSichtbar(false);
|
||||
this.rocketHoch.setzeSichtbar(true);
|
||||
} else if (this.keyboard.istGedrueckt('s')) {
|
||||
this.Rocket.setyPos(this.Rocket.getyPos() + this.speed);
|
||||
this.rocketRunter.setzeSichtbar(true);
|
||||
this.rocketLinks.setzeSichtbar(false);
|
||||
this.rocket.setzeSichtbar(false);
|
||||
this.rocketHoch.setzeSichtbar(false);
|
||||
} else if (this.keyboard.istGedrueckt('a')) {
|
||||
this.rocket.setzeSichtbar(false);
|
||||
this.rocketRunter.setzeSichtbar(false);
|
||||
this.rocketLinks.setzeSichtbar(true);
|
||||
this.rocketHoch.setzeSichtbar(false);
|
||||
this.Rocket.setxPos(this.Rocket.getxPos() - this.speed);
|
||||
} else if (this.keyboard.istGedrueckt('d')) {
|
||||
this.rocket.setzeSichtbar(true);
|
||||
this.rocketLinks.setzeSichtbar(false);
|
||||
this.rocketRunter.setzeSichtbar(false);
|
||||
this.rocketHoch.setzeSichtbar(false);
|
||||
this.Rocket.setxPos(this.Rocket.getxPos() + this.speed);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Fenstersmoothness() {
|
||||
if (this.Rocket.getyPos() < 0.0D) {
|
||||
this.Rocket.setyPos((double)Hilfe.monitorHoehe());
|
||||
}
|
||||
|
||||
if (this.Rocket.getyPos() > (double)Hilfe.monitorHoehe()) {
|
||||
this.Rocket.setyPos(0.0D);
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() > (double)1920) {
|
||||
this.Rocket.setxPos(0.0D);
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 0.0D) {
|
||||
this.Rocket.setxPos((double)1920);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Erase() {
|
||||
this.rocket.setzeSichtbar(false);
|
||||
this.rocketLinks.setzeSichtbar(false);
|
||||
this.rocketRunter.setzeSichtbar(false);
|
||||
this.star.setzeSichtbar(false);
|
||||
this.Deathstar.setzeSichtbar(false);
|
||||
this.rocketHoch.setzeSichtbar(false);
|
||||
this.fenster.setzeHintergrundFarbe(Farbe.SCHWARZ);
|
||||
this.PreStar10.setzeSichtbar(false);
|
||||
this.ScoreStar10.setzeSichtbar(true);
|
||||
this.ScoreStar10.setzeGroesse(40.0D, 40.0D);
|
||||
this.ScoreStar10.setzePosition((double)(this.x + 450), (double)this.y);
|
||||
this.laserbeam.setzeSichtbar(false);
|
||||
this.laserbeamup.setzeSichtbar(false);
|
||||
this.Meteorite.setzeSichtbar(false);
|
||||
}
|
||||
|
||||
private void setFireSpeed() {
|
||||
if (this.stift.getScore() < 5.0D) {
|
||||
if (this.rocket.istSichtbar()) {
|
||||
if (this.Rocket.getxPos() < 1920.0D && this.Rocket.getxPos() > 1680.0D) {
|
||||
this.firespeedRechts = 1.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 1680.0D && this.Rocket.getxPos() > 1440.0D) {
|
||||
this.firespeedRechts = 2.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 1440.0D && this.Rocket.getxPos() > 1200.0D) {
|
||||
this.firespeedRechts = 3.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 1200.0D && this.Rocket.getxPos() > 960.0D) {
|
||||
this.firespeedRechts = 4.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 960.0D && this.Rocket.getxPos() > 720.0D) {
|
||||
this.firespeedRechts = 5.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 720.0D && this.Rocket.getxPos() > 480.0D) {
|
||||
this.firespeedRechts = 6.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 480.0D && this.Rocket.getxPos() > 240.0D) {
|
||||
this.firespeedRechts = 7.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 240.0D && this.Rocket.getxPos() > 0.0D) {
|
||||
this.firespeedRechts = 8.0D;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.rocketLinks.istSichtbar()) {
|
||||
if (this.Rocket.getxPos() < 1920.0D && this.Rocket.getxPos() > 1680.0D) {
|
||||
this.firespeedLinks = 8.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 1680.0D && this.Rocket.getxPos() > 1440.0D) {
|
||||
this.firespeedLinks = 7.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 1440.0D && this.Rocket.getxPos() > 1200.0D) {
|
||||
this.firespeedLinks = 6.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 1200.0D && this.Rocket.getxPos() > 960.0D) {
|
||||
this.firespeedLinks = 5.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 960.0D && this.Rocket.getxPos() > 720.0D) {
|
||||
this.firespeedLinks = 4.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 720.0D && this.Rocket.getxPos() > 480.0D) {
|
||||
this.firespeedLinks = 3.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 480.0D && this.Rocket.getxPos() > 240.0D) {
|
||||
this.firespeedLinks = 2.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 240.0D && this.Rocket.getxPos() > 0.0D) {
|
||||
this.firespeedLinks = 1.0D;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.rocketHoch.istSichtbar()) {
|
||||
if (this.Rocket.getyPos() < 1080.0D && this.Rocket.getyPos() > 810.0D) {
|
||||
this.firespeedOben = 4.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getyPos() < 810.0D && this.Rocket.getyPos() > 540.0D) {
|
||||
this.firespeedOben = 3.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getyPos() < 540.0D && this.Rocket.getyPos() > 270.0D) {
|
||||
this.firespeedOben = 2.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getyPos() < 270.0D && this.Rocket.getyPos() > 0.0D) {
|
||||
this.firespeedOben = 1.0D;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.rocketRunter.istSichtbar()) {
|
||||
if (this.Rocket.getyPos() < 1080.0D && this.Rocket.getyPos() > 810.0D) {
|
||||
this.firespeedUnten = 1.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getyPos() < 810.0D && this.Rocket.getyPos() > 540.0D) {
|
||||
this.firespeedUnten = 2.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getyPos() < 540.0D && this.Rocket.getyPos() > 270.0D) {
|
||||
this.firespeedUnten = 3.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getyPos() < 270.0D && this.Rocket.getyPos() > 0.0D) {
|
||||
this.firespeedUnten = 4.0D;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.rocket.istSichtbar()) {
|
||||
if (this.Rocket.getxPos() < 1920.0D && this.Rocket.getxPos() > 1680.0D) {
|
||||
this.firespeedRechts = 1.5D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 1680.0D && this.Rocket.getxPos() > 1440.0D) {
|
||||
this.firespeedRechts = 3.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 1440.0D && this.Rocket.getxPos() > 1200.0D) {
|
||||
this.firespeedRechts = 4.5D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 1200.0D && this.Rocket.getxPos() > 960.0D) {
|
||||
this.firespeedRechts = 6.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 960.0D && this.Rocket.getxPos() > 720.0D) {
|
||||
this.firespeedRechts = 7.5D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 720.0D && this.Rocket.getxPos() > 480.0D) {
|
||||
this.firespeedRechts = 9.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 480.0D && this.Rocket.getxPos() > 240.0D) {
|
||||
this.firespeedRechts = 10.5D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 240.0D && this.Rocket.getxPos() > 0.0D) {
|
||||
this.firespeedRechts = 12.0D;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.rocketLinks.istSichtbar()) {
|
||||
if (this.Rocket.getxPos() < 1920.0D && this.Rocket.getxPos() > 1680.0D) {
|
||||
this.firespeedLinks = 12.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 1680.0D && this.Rocket.getxPos() > 1440.0D) {
|
||||
this.firespeedLinks = 10.5D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 1440.0D && this.Rocket.getxPos() > 1200.0D) {
|
||||
this.firespeedLinks = 9.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 1200.0D && this.Rocket.getxPos() > 960.0D) {
|
||||
this.firespeedLinks = 7.5D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 960.0D && this.Rocket.getxPos() > 720.0D) {
|
||||
this.firespeedLinks = 6.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 720.0D && this.Rocket.getxPos() > 480.0D) {
|
||||
this.firespeedLinks = 4.5D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 480.0D && this.Rocket.getxPos() > 240.0D) {
|
||||
this.firespeedLinks = 3.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getxPos() < 240.0D && this.Rocket.getxPos() > 0.0D) {
|
||||
this.firespeedLinks = 1.5D;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.rocketHoch.istSichtbar()) {
|
||||
if (this.Rocket.getyPos() < 1080.0D && this.Rocket.getyPos() > 810.0D) {
|
||||
this.firespeedOben = 6.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getyPos() < 810.0D && this.Rocket.getyPos() > 540.0D) {
|
||||
this.firespeedOben = 4.5D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getyPos() < 540.0D && this.Rocket.getyPos() > 270.0D) {
|
||||
this.firespeedOben = 3.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getyPos() < 270.0D && this.Rocket.getyPos() > 0.0D) {
|
||||
this.firespeedOben = 1.5D;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.rocketRunter.istSichtbar()) {
|
||||
if (this.Rocket.getyPos() < 1080.0D && this.Rocket.getyPos() > 810.0D) {
|
||||
this.firespeedUnten = 1.5D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getyPos() < 810.0D && this.Rocket.getyPos() > 540.0D) {
|
||||
this.firespeedUnten = 3.0D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getyPos() < 540.0D && this.Rocket.getyPos() > 270.0D) {
|
||||
this.firespeedUnten = 4.5D;
|
||||
}
|
||||
|
||||
if (this.Rocket.getyPos() < 270.0D && this.Rocket.getyPos() > 0.0D) {
|
||||
this.firespeedUnten = 6.0D;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void SchussRichtung() {
|
||||
if (this.rocket.istSichtbar() && !this.laserbeam.istSichtbar()) {
|
||||
if (this.stift.getScore() < 5.0D) {
|
||||
this.laserbeam.setzePosition(this.Rocket.getxPos() + 20.0D, this.Rocket.getyPos() - 38.0D);
|
||||
} else {
|
||||
this.laserbeam.setzePosition(this.Rocket.getxPos() + 120.0D, this.Rocket.getyPos() - 37.0D);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.rocketLinks.istSichtbar() && !this.laserbeam.istSichtbar()) {
|
||||
this.laserbeam.setzePosition(this.Rocket.getxPos() - 124.0D, this.Rocket.getyPos() - 36.0D);
|
||||
}
|
||||
|
||||
if (this.rocketHoch.istSichtbar() && !this.laserbeamup.istSichtbar()) {
|
||||
this.laserbeamup.setzePosition(this.Rocket.getxPos() - 38.0D, this.Rocket.getyPos() - 115.0D);
|
||||
}
|
||||
|
||||
if (this.rocketRunter.istSichtbar() && !this.laserbeamup.istSichtbar()) {
|
||||
if (this.stift.getScore() < 5.0D) {
|
||||
this.laserbeamup.setzePosition(this.Rocket.getxPos() - 35.0D, this.Rocket.getyPos() + 38.0D);
|
||||
} else {
|
||||
this.laserbeamup.setzePosition(this.Rocket.getxPos() - 38.0D, this.Rocket.getyPos() + 120.0D);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Schuss() {
|
||||
if (this.keyboard.istGedrueckt(' ') && this.rocket.istSichtbar() && !this.laserbeam.istSichtbar() && !this.laserbeamup.istSichtbar()) {
|
||||
this.SchussRechts = true;
|
||||
}
|
||||
|
||||
if (this.keyboard.istGedrueckt(' ') && this.rocketLinks.istSichtbar() && !this.laserbeam.istSichtbar() && !this.laserbeamup.istSichtbar()) {
|
||||
this.SchussLinks = true;
|
||||
}
|
||||
|
||||
if (this.keyboard.istGedrueckt(' ') && this.rocketHoch.istSichtbar() && !this.laserbeam.istSichtbar() && !this.laserbeamup.istSichtbar()) {
|
||||
this.SchussOben = true;
|
||||
} else if (this.keyboard.istGedrueckt(' ') && this.rocketRunter.istSichtbar() && !this.laserbeam.istSichtbar() && !this.laserbeamup.istSichtbar()) {
|
||||
this.SchussUnten = true;
|
||||
}
|
||||
|
||||
if (this.SchussRechts) {
|
||||
this.laserbeam.setzeSichtbar(true);
|
||||
this.laserbeam.setzePosition(this.laserbeam.hPosition() + this.firespeedRechts, this.laserbeam.vPosition());
|
||||
if (this.laserbeam.hPosition() > (double)1920) {
|
||||
this.SchussRechts = false;
|
||||
this.laserbeam.setzeSichtbar(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.SchussLinks) {
|
||||
this.laserbeam.setzeSichtbar(true);
|
||||
this.laserbeam.setzePosition(this.laserbeam.hPosition() - this.firespeedLinks, this.laserbeam.vPosition());
|
||||
if (this.laserbeam.hPosition() < 0.0D) {
|
||||
this.SchussLinks = false;
|
||||
this.laserbeam.setzeSichtbar(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.SchussOben) {
|
||||
this.laserbeamup.setzeSichtbar(true);
|
||||
this.laserbeamup.setzePosition(this.laserbeamup.hPosition(), this.laserbeamup.vPosition() - this.firespeedOben);
|
||||
if (this.laserbeamup.vPosition() < 0.0D) {
|
||||
this.SchussOben = false;
|
||||
this.laserbeamup.setzeSichtbar(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.SchussUnten) {
|
||||
this.laserbeamup.setzeSichtbar(true);
|
||||
this.laserbeamup.setzePosition(this.laserbeamup.hPosition(), this.laserbeamup.vPosition() + this.firespeedUnten);
|
||||
if (this.laserbeamup.vPosition() > (double)Hilfe.monitorHoehe()) {
|
||||
this.SchussUnten = false;
|
||||
this.laserbeamup.setzeSichtbar(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void fuehreAus() {
|
||||
this.rocket = new Bild(this.LocationRakete1);
|
||||
this.rocketLinks = new Bild(this.LocationRakete1);
|
||||
this.rocketRunter = new Bild(this.LocationRakete1);
|
||||
this.rocketHoch = new Bild(this.LocationRakete1);
|
||||
this.star = new Bild(this.LocationStern);
|
||||
this.Deathstar = new Bild(this.LocationDeathStar);
|
||||
this.Meteorite = new Bild(this.meteorite);
|
||||
this.laserbeamup = new Bild(this.laser);
|
||||
this.laserbeam = new Bild(this.laser);
|
||||
this.stein = new Meteorite();
|
||||
this.PreStar1 = new Bild(this.LocationPreStar);
|
||||
this.PreStar2 = new Bild(this.LocationPreStar);
|
||||
this.PreStar3 = new Bild(this.LocationPreStar);
|
||||
this.PreStar4 = new Bild(this.LocationPreStar);
|
||||
this.PreStar5 = new Bild(this.LocationPreStar);
|
||||
this.PreStar6 = new Bild(this.LocationPreStar);
|
||||
this.PreStar7 = new Bild(this.LocationPreStar);
|
||||
this.PreStar8 = new Bild(this.LocationPreStar);
|
||||
this.PreStar9 = new Bild(this.LocationPreStar);
|
||||
this.PreStar10 = new Bild(this.LocationPreStar);
|
||||
this.ScoreStar1 = new Bild(this.LocationStern);
|
||||
this.ScoreStar2 = new Bild(this.LocationStern);
|
||||
this.ScoreStar3 = new Bild(this.LocationStern);
|
||||
this.ScoreStar4 = new Bild(this.LocationStern);
|
||||
this.ScoreStar5 = new Bild(this.LocationStern);
|
||||
this.ScoreStar6 = new Bild(this.LocationStern);
|
||||
this.ScoreStar7 = new Bild(this.LocationStern);
|
||||
this.ScoreStar8 = new Bild(this.LocationStern);
|
||||
this.ScoreStar9 = new Bild(this.LocationStern);
|
||||
this.ScoreStar10 = new Bild(this.LocationStern);
|
||||
this.BadStar3 = new Bild(this.BadStar);
|
||||
this.BadStar6 = new Bild(this.BadStar);
|
||||
this.BadStar9 = new Bild(this.BadStar);
|
||||
this.BadStar3.setzeSichtbar(false);
|
||||
this.BadStar6.setzeSichtbar(false);
|
||||
this.BadStar9.setzeSichtbar(false);
|
||||
this.ScoreStar1.setzeSichtbar(false);
|
||||
this.ScoreStar2.setzeSichtbar(false);
|
||||
this.ScoreStar3.setzeSichtbar(false);
|
||||
this.ScoreStar4.setzeSichtbar(false);
|
||||
this.ScoreStar5.setzeSichtbar(false);
|
||||
this.ScoreStar6.setzeSichtbar(false);
|
||||
this.ScoreStar7.setzeSichtbar(false);
|
||||
this.ScoreStar8.setzeSichtbar(false);
|
||||
this.ScoreStar9.setzeSichtbar(false);
|
||||
this.ScoreStar10.setzeSichtbar(false);
|
||||
this.PreStar1.setzeGroesse(40.0D, 40.0D);
|
||||
this.PreStar2.setzeGroesse(40.0D, 40.0D);
|
||||
this.PreStar3.setzeGroesse(40.0D, 40.0D);
|
||||
this.PreStar4.setzeGroesse(40.0D, 40.0D);
|
||||
this.PreStar5.setzeGroesse(40.0D, 40.0D);
|
||||
this.PreStar6.setzeGroesse(40.0D, 40.0D);
|
||||
this.PreStar7.setzeGroesse(40.0D, 40.0D);
|
||||
this.PreStar8.setzeGroesse(40.0D, 40.0D);
|
||||
this.PreStar9.setzeGroesse(40.0D, 40.0D);
|
||||
this.PreStar10.setzeGroesse(40.0D, 40.0D);
|
||||
this.speed = 4.0D;
|
||||
this.firespeedOben = 4.0D;
|
||||
this.Meteorite.setzeGroesse(100.0D, 100.0D);
|
||||
this.laserbeam.setzeGroesse(40.0D, 80.0D);
|
||||
this.laserbeam.dreheUmMitGroessenAnpassung(90.0D);
|
||||
this.laserbeam.setzeSichtbar(false);
|
||||
this.laserbeamup.setzeGroesse(40.0D, 80.0D);
|
||||
this.laserbeamup.setzeSichtbar(false);
|
||||
this.Rocket = new rocket(540.0D, 540.0D, 0.5D);
|
||||
this.stern = new Stern();
|
||||
this.stift = new stift();
|
||||
this.fenster.setzeTitel("ROCKET");
|
||||
this.fenster.ladeBildInZeichenflaeche(this.LocationBackground);
|
||||
this.stein.pickLocation();
|
||||
this.stein.size();
|
||||
this.Meteorite.setzeGroesse(this.stein.getSize(), this.stein.getSize());
|
||||
this.stern.pickLocation();
|
||||
this.stern.setSize(100.0D * this.Rocket.getStreckung());
|
||||
this.Deathstar.setzeSichtbar(false);
|
||||
this.rocketLinks.dreheUmMitGroessenAnpassung(180.0D);
|
||||
this.rocketLinks.setzeSichtbar(false);
|
||||
this.rocketRunter.setzeSichtbar(false);
|
||||
this.rocketHoch.setzeSichtbar(false);
|
||||
this.rocketRunter.dreheUmMitGroessenAnpassung(270.0D);
|
||||
this.rocketHoch.dreheUmMitGroessenAnpassung(90.0D);
|
||||
this.star.setzeSichtbar(false);
|
||||
|
||||
while(this.stift.getScore() < 10.0D) {
|
||||
if (this.stift.getScore() != 3.0D && this.stift.getScore() != 6.0D && this.stift.getScore() != 9.0D) {
|
||||
this.Deathstar.setzeSichtbar(false);
|
||||
}
|
||||
|
||||
this.setFireSpeed();
|
||||
this.ScoreStar();
|
||||
this.RocketChange();
|
||||
this.star.setzeGroesse(this.stern.getSize(), this.stern.getSize());
|
||||
this.Meteorite.setzeGroesse(this.stein.getSize(), this.stein.getSize());
|
||||
this.OldRocketDimensions();
|
||||
this.PositionRocket();
|
||||
this.Meteorite.setzePosition((double)this.stein.getX(), (double)this.stein.getY());
|
||||
this.star.setzePosition((double)(this.stern.getX() - 4), (double)(this.stern.getY() - 5));
|
||||
this.KollisionGut();
|
||||
this.KollisionSchlecht();
|
||||
if (this.keyboard.istGedrueckt('\u001b')) {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
this.Movement();
|
||||
this.Fenstersmoothness();
|
||||
this.Schuss();
|
||||
this.SchussRichtung();
|
||||
}
|
||||
|
||||
this.Erase();
|
||||
|
||||
while(!this.keyboard.istGedrueckt('\u001b')) {
|
||||
this.stift.end();
|
||||
}
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public void game() {
|
||||
Bild Bewegung = new Bild("res/Bewegen.png");
|
||||
Bild Space = new Bild("res/Space.png");
|
||||
Bild Steuerung = new Bild("res/Steuerung.png");
|
||||
Bild Rechteck = new Bild("res/Rechteck 1.png");
|
||||
Bild HelpMeteorit = new Bild("res/Anleitung_Meteorit.png");
|
||||
Bild HelpStern = new Bild("res/Anleitung_Stern.png");
|
||||
Bild startscreen = new Bild("res/startscreen.png");
|
||||
Rechteck.setzeGroesse(30.0D, 30.0D);
|
||||
HelpStern.setzeGroesse(254.0D, 151.0D);
|
||||
HelpMeteorit.setzeGroesse(254.0D, 151.0D);
|
||||
Rechteck.setzeSichtbar(false);
|
||||
HelpStern.setzeSichtbar(false);
|
||||
HelpMeteorit.setzeSichtbar(false);
|
||||
Space.setzeSichtbar(false);
|
||||
Bewegung.setzeSichtbar(false);
|
||||
|
||||
while(true) {
|
||||
while(!this.keyboard.istGedrueckt(' ')) {
|
||||
HelpStern.setzePosition((double)(this.fenster.breite() + 170 - this.fenster.breite()), (double)(this.fenster.hoehe() - (this.fenster.hoehe() - 100)));
|
||||
HelpMeteorit.setzePosition((double)(this.fenster.breite() + 170 - this.fenster.breite()), (double)(this.fenster.hoehe() - (this.fenster.hoehe() - 280)));
|
||||
Bewegung.setzePosition((double)(this.fenster.breite() + 180 - this.fenster.breite()), (double)(this.fenster.hoehe() - (this.fenster.hoehe() - 470)));
|
||||
Space.setzePosition((double)(this.fenster.breite() + 40 - this.fenster.breite()), (double)(this.fenster.hoehe() - (this.fenster.hoehe() - 720)));
|
||||
Steuerung.setzePosition((double)(this.fenster.breite() + 170 - this.fenster.breite()), (double)(this.fenster.hoehe() - (this.fenster.hoehe() - 900)));
|
||||
Rechteck.setzePosition((double)this.maus.hPosition(), (double)this.maus.vPosition());
|
||||
if (Steuerung.kollisionErkanntMit(Rechteck)) {
|
||||
Space.setzeSichtbar(true);
|
||||
Space.setzeTransparenz(true);
|
||||
|
||||
while(this.d <= 1.0D) {
|
||||
Space.setzeTransparenzGrad(this.d);
|
||||
this.d += 0.025D;
|
||||
Hilfe.warte(5L);
|
||||
}
|
||||
|
||||
Bewegung.setzeSichtbar(true);
|
||||
Bewegung.setzeTransparenz(true);
|
||||
|
||||
while(this.e <= 1.0D) {
|
||||
Bewegung.setzeTransparenzGrad(this.e);
|
||||
this.e += 0.025D;
|
||||
Hilfe.warte(5L);
|
||||
}
|
||||
|
||||
HelpMeteorit.setzeSichtbar(true);
|
||||
HelpMeteorit.setzeTransparenz(true);
|
||||
|
||||
while(this.f <= 1.0D) {
|
||||
HelpMeteorit.setzeTransparenzGrad(this.f);
|
||||
this.f += 0.025D;
|
||||
Hilfe.warte(5L);
|
||||
}
|
||||
|
||||
HelpStern.setzeSichtbar(true);
|
||||
HelpStern.setzeTransparenz(true);
|
||||
|
||||
while(this.h <= 1.0D) {
|
||||
HelpStern.setzeTransparenzGrad(this.h);
|
||||
this.h += 0.025D;
|
||||
Hilfe.warte(5L);
|
||||
}
|
||||
} else {
|
||||
if (Space.istSichtbar() && Bewegung.istSichtbar() && HelpMeteorit.istSichtbar() && HelpStern.istSichtbar()) {
|
||||
while(this.d > 0.0D) {
|
||||
Space.setzeTransparenzGrad(this.d);
|
||||
this.d -= 0.025D;
|
||||
Hilfe.warte(5L);
|
||||
}
|
||||
|
||||
this.d = 0.0D;
|
||||
Space.setzeSichtbar(false);
|
||||
|
||||
while(this.e > 0.0D) {
|
||||
Bewegung.setzeTransparenzGrad(this.e);
|
||||
this.e -= 0.025D;
|
||||
Hilfe.warte(5L);
|
||||
}
|
||||
|
||||
this.e = 0.0D;
|
||||
Bewegung.setzeSichtbar(false);
|
||||
|
||||
while(this.f > 0.0D) {
|
||||
HelpMeteorit.setzeTransparenzGrad(this.f);
|
||||
this.f -= 0.025D;
|
||||
Hilfe.warte(5L);
|
||||
}
|
||||
|
||||
this.f = 0.0D;
|
||||
HelpMeteorit.setzeSichtbar(false);
|
||||
}
|
||||
|
||||
while(this.h > 0.0D) {
|
||||
HelpStern.setzeTransparenzGrad(this.h);
|
||||
this.h -= 0.025D;
|
||||
Hilfe.warte(5L);
|
||||
}
|
||||
|
||||
this.h = 0.0D;
|
||||
HelpMeteorit.setzeSichtbar(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.keyboard.istGedrueckt('\u001b')) {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
Hilfe.kurzePause();
|
||||
startscreen.setzeGroesse((double)this.fenster.breite(), (double)this.fenster.hoehe());
|
||||
startscreen.setzeSichtbar(false);
|
||||
Steuerung.setzeSichtbar(false);
|
||||
Rechteck.setzeSichtbar(false);
|
||||
Bewegung.setzeSichtbar(false);
|
||||
Space.setzeSichtbar(false);
|
||||
HelpMeteorit.setzeSichtbar(false);
|
||||
HelpStern.setzeSichtbar(false);
|
||||
this.fuehreAus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
MAINnormal Rocket = new MAINnormal();
|
||||
Rocket.game();
|
||||
}
|
||||
}
|
||||
43
SpaceFighter/src/Meteorite.java
Normal file
@@ -0,0 +1,43 @@
|
||||
import basis.Hilfe;
|
||||
|
||||
public class Meteorite {
|
||||
int x;
|
||||
int y;
|
||||
double size;
|
||||
|
||||
public Meteorite() {
|
||||
}
|
||||
|
||||
public void pickLocation() {
|
||||
this.x = Hilfe.zufall(100, Hilfe.monitorBreite() - 100);
|
||||
this.y = Hilfe.zufall(100, Hilfe.monitorHoehe() - 100);
|
||||
}
|
||||
|
||||
public void size() {
|
||||
this.size = (double)Hilfe.zufall(50, 120);
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public void setX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public void setY(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void setSizee(double size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public double getSize() {
|
||||
return this.size;
|
||||
}
|
||||
}
|
||||
43
SpaceFighter/src/Stern.java
Normal file
@@ -0,0 +1,43 @@
|
||||
import basis.Hilfe;
|
||||
|
||||
public class Stern {
|
||||
int x;
|
||||
int y;
|
||||
double size;
|
||||
|
||||
public Stern() {
|
||||
}
|
||||
|
||||
public void pickLocation() {
|
||||
this.x = Hilfe.zufall(100, Hilfe.monitorBreite() - 100);
|
||||
this.y = Hilfe.zufall(100, Hilfe.monitorHoehe() - 100);
|
||||
}
|
||||
|
||||
public void size() {
|
||||
this.size = (double)Hilfe.zufall(30, 120);
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public void setX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public void setY(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void setSize(double size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public double getSize() {
|
||||
return this.size;
|
||||
}
|
||||
}
|
||||
BIN
SpaceFighter/src/res/Anleitung_Meteorit.png
Normal file
|
After Width: | Height: | Size: 99 KiB |
BIN
SpaceFighter/src/res/Anleitung_Stern.png
Normal file
|
After Width: | Height: | Size: 88 KiB |