Skip to content

Commit

Permalink
🧹 refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick helm committed Jun 16, 2023
1 parent 4b3ecea commit bd63bed
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Um das Ganze einfacher zu gestalten ist das Build-Kommando in dem Start Script m
```bash
Raspberry Pi 3
TSL2561
ADX345
ADXL345
Pi Breakout Board

Steckbrett
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ These parts were used for our setup:
```bash
Raspberry Pi 3
TSL2561
ADX345
ADXL345
Pi Breakout Board

Breadboard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ public class Launcher {
public static void main(String[] args) {
Main.main(args);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public class Main extends Application {
static final int BOARD_WIDTH = HORIZONTAL_CELLS * CELL_SIZE;
static final int BOARD_HEIGHT = VERTICAL_CELLS * CELL_SIZE;
public static boolean gameover = false;
private static int anInt;
public static List<SpriteView> sprites = new ArrayList<>();
public static PixelatedClock pixelatedClock;
public static Group root;
Expand Down Expand Up @@ -277,47 +276,47 @@ private void populateCells(Group root, final SpriteView mainCharacter) {
}


private void addKeyHandler(Scene scene, SpriteView mary) {
private void addKeyHandler(Scene scene, SpriteView player) {

scene.addEventHandler(KeyEvent.KEY_PRESSED,
ke -> {
KeyCode keyCode = ke.getCode();
key -> {
KeyCode keyCode = key.getCode();

switch (keyCode) {
case W:
case UP:
mary.move(Direction.UP);
player.move(Direction.UP);
break;

case A:
case LEFT:
mary.move(Direction.LEFT);
player.move(Direction.LEFT);
break;

case S:
case DOWN:
mary.move(Direction.DOWN);
player.move(Direction.DOWN);
break;

case D:
case RIGHT:
mary.move(Direction.RIGHT);
player.move(Direction.RIGHT);
break;

case Z:
if (ke.isControlDown() && ke.isShiftDown())
case J:
if (key.isControlDown() && key.isShiftDown())
angreifen(3);

break;

case X:
if (ke.isControlDown() && ke.isShiftDown())
case K:
if (key.isControlDown() && key.isShiftDown())
nacht.setValue(!nacht.getValue());

break;

case C:
if (ke.isControlDown() && ke.isShiftDown())
case L:
if (key.isControlDown() && key.isShiftDown())
erdbeben();

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.pi4j.component.gyroscope.analogdevices.ADXL345;
import com.pi4j.io.gpio.*;
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent;
import com.pi4j.io.gpio.event.GpioPinListenerDigital;
import com.pi4j.io.i2c.I2CBus;
import com.pi4j.io.i2c.I2CDevice;
Expand Down Expand Up @@ -49,17 +48,12 @@ public void createButton(SpriteView.PokeTrainer pokeTrainer) {
if (PiSystem.isPiUnix) {
final GpioPinDigitalInput myButton = gpio.provisionDigitalInputPin(RaspiPin.GPIO_07,
PinPullResistance.PULL_UP);
myButton.addListener(new GpioPinListenerDigital() {

@Override
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {

boolean knopfGedrueckt = event.getState().isLow();

if (knopfGedrueckt)
Main.display("Knopf gedrueckt.");
// Pokemon angreifen!
}
myButton.addListener((GpioPinListenerDigital) event -> {
boolean knopfGedrueckt = event.getState().isLow();
if (knopfGedrueckt)
Main.display("Knopf gedrueckt.");
// ToDo: Pokemon angreifen!
});
}
}
Expand Down Expand Up @@ -126,6 +120,8 @@ public void createAccelerometer() {
}
}
}


// Pokemon angreifen!
// Main.angreifen(3);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public Bidiza(Main.Location loc) {
}
}

public static class Krebscorps extends Pokemon {
static class Krebscorps extends Pokemon {

public Krebscorps(Main.Location loc) {

Expand Down Expand Up @@ -293,13 +293,13 @@ public Mampfaxo(Main.Location loc) {
}
}

public static class Pokemon extends RandomWalker {
static class Pokemon extends RandomWalker {

private String name;
private final Image front;
private final Image back;

public Pokemon(String name, Main.Location loc, double speed) {
private Pokemon(String name, Main.Location loc, double speed) {

super(loadImage("/images/" + name + ".png", 4, 4), loc, 4, 4, speed);
front = new Image(getClass().getResourceAsStream("/images/" + name + "-front.png"));
Expand Down

0 comments on commit bd63bed

Please sign in to comment.