mirror of
https://inf.pirckheimer-gymnasium.de/kebab/kebab
synced 2026-08-26 16:31:23 +00:00
133 lines
4.4 KiB
Java
133 lines
4.4 KiB
Java
package project.scenes;
|
|
|
|
import pi.Controller;
|
|
import pi.Rectangle;
|
|
import pi.Scene;
|
|
import pi.Text;
|
|
import pi.actor.Actor;
|
|
import pi.actor.Animation;
|
|
import pi.actor.Image;
|
|
import pi.event.FrameListener;
|
|
import pi.graphics.geom.Vector;
|
|
|
|
import static pi.Controller.fonts;
|
|
import java.awt.Font;
|
|
|
|
|
|
public class GameScene extends Scene implements FrameListener
|
|
{
|
|
Rectangle bg;
|
|
Text[] texts;
|
|
Actor[] customers;
|
|
|
|
public GameScene() {
|
|
// the background music, color, stats (some meta information)
|
|
Controller.jukebox.playSound("sounds/Mozart_Turkish_March_-_Orchestral_Melodic_Techno_-_TVV_music_320k.mp3");
|
|
bg = new Rectangle(2000, 2000);
|
|
bg.color("#ffffff");
|
|
bg.center(0, 0);
|
|
bg.layerPosition(-100);
|
|
addStatsCollectionOutline(this);
|
|
texts = createTexts(this);
|
|
camera().meter(10);
|
|
|
|
// create customers
|
|
customers = new Actor[1];
|
|
customers[0] = Animation.createFromAnimatedGif("images/kebab-pack/customer-mr-eggman.gif", 1.48*25, 1.25*25);
|
|
customers[0].center(-60,0);
|
|
customers[0].applyImpulse(new Vector(1, 0).multiply(100000));
|
|
|
|
// add all actors
|
|
add(bg);
|
|
add(customers);
|
|
}
|
|
|
|
@Override
|
|
public void onFrame(double pastTime)
|
|
{
|
|
if(visibleArea().xRight() < customers[0].anchor().add(new Vector(-20, 0)).x()) {
|
|
customers[0].center(-60,0);
|
|
}
|
|
}
|
|
|
|
// Static helper methods
|
|
public static void addStatsCollectionOutline(Scene scene) {
|
|
Image moneyButton = new Image("images/pixui-pack/Buttons/Button_White_Outline (9).png");
|
|
moneyButton.center(-10, 25);
|
|
Image kebabSoldButton = new Image("images/pixui-pack/Buttons/Button_White_Outline (9).png");
|
|
kebabSoldButton.center(0, 25);
|
|
Image waitingCustomersButton = new Image("images/pixui-pack/Buttons/Button_White_Outline (9).png");
|
|
waitingCustomersButton.center(10, 25);
|
|
|
|
Image moneyIcon = new Image("images/kebab-pack/money-128x128.png").size(2, 2);
|
|
moneyIcon.center(-12, 25);
|
|
Image kebabSoldIcon = new Image("images/kebab-pack/kebab-128x128.png").size(2, 2);
|
|
kebabSoldIcon.center(-2, 25);
|
|
Image waitingCustomersIcon = new Image("images/kebab-pack/aladin-256x256.png").size(2, 2);
|
|
waitingCustomersIcon.center(8, 25);
|
|
|
|
scene.add(moneyButton);
|
|
scene.add(moneyIcon);
|
|
scene.add(kebabSoldButton);
|
|
scene.add(kebabSoldIcon);
|
|
scene.add(waitingCustomersButton);
|
|
scene.add(waitingCustomersIcon);
|
|
}
|
|
|
|
public static Text[] createTexts(Scene scene) {
|
|
Text[] texts = new Text[10];
|
|
Font font = fonts.get("fonts/BitcountGridDouble-Regular.ttf");
|
|
|
|
Text money = new Text("0");
|
|
money.color("#000000");
|
|
money.font(font);
|
|
money.height(2.5);
|
|
money.center(-9, 25);
|
|
texts[0] = money;
|
|
Text kebabSold = new Text("0");
|
|
kebabSold.color("#000000");
|
|
kebabSold.font(font);
|
|
kebabSold.height(2.5);
|
|
kebabSold.center(1, 25);
|
|
texts[1] = kebabSold;
|
|
Text waitingCustomers = new Text("0");
|
|
waitingCustomers.color("#000000");
|
|
waitingCustomers.font(font);
|
|
waitingCustomers.height(2.5);
|
|
waitingCustomers.center(11, 25);
|
|
texts[2] = waitingCustomers;
|
|
|
|
scene.add(money);
|
|
scene.add(kebabSold);
|
|
scene.add(waitingCustomers);
|
|
|
|
return texts;
|
|
}
|
|
|
|
public static void setTexts(Text[] texts, int money, int kebabSold, int waitingCustomers) {
|
|
texts[0].content(String.valueOf(money));
|
|
texts[1].content(String.valueOf(kebabSold));
|
|
texts[2].content(String.valueOf(waitingCustomers));
|
|
}
|
|
|
|
public static void setMoney(Text[] texts, int money) {
|
|
texts[0].content(String.valueOf(money));
|
|
}
|
|
public static void setKebabSold(Text[] texts, int kebabSold) {
|
|
texts[1].content(String.valueOf(kebabSold));
|
|
}
|
|
public static void setWaitingCustomers(Text[] texts, int waitingCustomers) {
|
|
texts[2].content(String.valueOf(waitingCustomers));
|
|
}
|
|
|
|
public static void saveStats(Text[] texts) {
|
|
int money = Integer.parseInt(texts[0].content());
|
|
int kebabSold = Integer.parseInt(texts[1].content());
|
|
int waitingCustomers = Integer.parseInt(texts[2].content());
|
|
|
|
System.out.println(money);
|
|
System.out.println(kebabSold);
|
|
System.out.println(waitingCustomers);
|
|
}
|
|
}
|