mirror of
https://inf.pirckheimer-gymnasium.de/kebab/kebab
synced 2026-08-26 16:31:23 +00:00
Final state
This commit is contained in:
@@ -1,7 +0,0 @@
|
|||||||
kebabPrice=5
|
|
||||||
kebabSold=28
|
|
||||||
money=123
|
|
||||||
totalEarned=0
|
|
||||||
upgradeLevel=0
|
|
||||||
waitingCustomers=0
|
|
||||||
workers=0
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package project;
|
package project;
|
||||||
|
|
||||||
import project.scenes.GameScene;
|
import project.scenes.GameScene;
|
||||||
|
import project.scenes.LoadingScene;
|
||||||
|
import project.scenes.VictoryScene;
|
||||||
import project.utils.Statistics;
|
import project.utils.Statistics;
|
||||||
import pi.Controller;
|
import pi.Controller;
|
||||||
import pi.config.ConfigLoader;
|
import pi.config.ConfigLoader;
|
||||||
@@ -21,8 +23,9 @@ public class Main
|
|||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
Controller.instantMode(false);
|
Controller.instantMode(false);
|
||||||
//Controller.start(new LoadingScene(), 1000, 600);
|
Controller.start(new LoadingScene(), 1000, 600);
|
||||||
Controller.start(new GameScene(), 1000, 600);
|
//Controller.start(new GameScene(), 1000, 600);
|
||||||
|
//Controller.start(new VictoryScene(), 1000, 600);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Cursor customCursor = Toolkit.getDefaultToolkit().createCustomCursor(
|
Cursor customCursor = Toolkit.getDefaultToolkit().createCustomCursor(
|
||||||
|
|||||||
@@ -24,9 +24,13 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
|||||||
Rectangle bg;
|
Rectangle bg;
|
||||||
Image tatli;
|
Image tatli;
|
||||||
Text[] texts;
|
Text[] texts;
|
||||||
Image[] ingredients;
|
Image[] ingredients; // array of all ingredients (including the final kebab lol)
|
||||||
|
int[] current_kebab; // used for remembering which ingredients have already been added to the current kebab build
|
||||||
Actor[] customers;
|
Actor[] customers;
|
||||||
|
boolean[] fed_customers;
|
||||||
public static ConfigLoader loader;
|
public static ConfigLoader loader;
|
||||||
|
boolean mouse_pressed_on_kebab;
|
||||||
|
Statistics s;
|
||||||
|
|
||||||
public GameScene() {
|
public GameScene() {
|
||||||
// the background music, color, stats (some meta information)
|
// the background music, color, stats (some meta information)
|
||||||
@@ -38,6 +42,7 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
|||||||
addStatsCollectionOutline(this);
|
addStatsCollectionOutline(this);
|
||||||
texts = createTexts(this);
|
texts = createTexts(this);
|
||||||
camera().meter(10);
|
camera().meter(10);
|
||||||
|
s = Main.config.getGroup(Statistics.class);
|
||||||
|
|
||||||
tatli = new Image("images/kebab-pack/tatli-ekmek-256x256.png");
|
tatli = new Image("images/kebab-pack/tatli-ekmek-256x256.png");
|
||||||
tatli.size(2.56*13, 2.56*13);
|
tatli.size(2.56*13, 2.56*13);
|
||||||
@@ -47,13 +52,18 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
|||||||
customers = new Actor[2];
|
customers = new Actor[2];
|
||||||
customers[0] = Animation.createFromAnimatedGif("images/kebab-pack/customer-sonic-on-white.gif", 1.48*25, 1.25*25);
|
customers[0] = Animation.createFromAnimatedGif("images/kebab-pack/customer-sonic-on-white.gif", 1.48*25, 1.25*25);
|
||||||
customers[0].center(-60,0);
|
customers[0].center(-60,0);
|
||||||
customers[0].applyImpulse(new Vector(1, 0).multiply(100000));
|
customers[0].applyImpulse(new Vector(1, 0).multiply(200000));
|
||||||
customers[1] = Animation.createFromAnimatedGif("images/kebab-pack/customer-mr-eggman.gif", 1.48*20, 1.48*20);
|
customers[1] = Animation.createFromAnimatedGif("images/kebab-pack/customer-mr-eggman.gif", 1.48*20, 1.48*20);
|
||||||
customers[1].center(-180,0);
|
customers[1].center(-180,0);
|
||||||
customers[1].applyImpulse(new Vector(1, 0).multiply(100000));
|
customers[1].applyImpulse(new Vector(1, 0).multiply(100000));
|
||||||
|
fed_customers = new boolean[customers.length];
|
||||||
|
|
||||||
|
// initialize ingredients and current_kebab arrays
|
||||||
ingredients = createIngredients();
|
ingredients = createIngredients();
|
||||||
|
current_kebab = new int[ingredients.length-1];
|
||||||
|
|
||||||
|
mouse_pressed_on_kebab = false;
|
||||||
|
|
||||||
// add all actors
|
// add all actors
|
||||||
add(bg);
|
add(bg);
|
||||||
add(customers);
|
add(customers);
|
||||||
@@ -64,22 +74,63 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
|||||||
@Override
|
@Override
|
||||||
public void onFrame(double pastTime)
|
public void onFrame(double pastTime)
|
||||||
{
|
{
|
||||||
for(Actor c : customers) {
|
for(int i=0; i<customers.length; i++) {
|
||||||
if(visibleArea().xRight() < c.anchor().add(new Vector(-20, 0)).x()) {
|
if(visibleArea().xRight() < customers[i].anchor().add(new Vector(-20, 0)).x()) {
|
||||||
c.center(-60,0);
|
customers[i].center(-60,0);
|
||||||
Statistics s = Main.config.getGroup(Statistics.class);;
|
if(fed_customers[i]) {
|
||||||
s.kebabSold(s.kebabSold()+1);
|
fed_customers[i] = false;
|
||||||
Main.config.save();
|
} else {
|
||||||
|
incrementWaitingCustomers(1);
|
||||||
setKebabSold(texts, s.kebabSold());
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mouse_pressed_on_kebab) {
|
||||||
|
ingredients[4].center(Controller.mousePosition());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMouseDown(Vector position, MouseButton button)
|
public void onMouseDown(Vector position, MouseButton button)
|
||||||
{
|
{
|
||||||
|
if(ingredients[4].contains(Controller.mousePosition()) && ingredients[4].isVisible()) {
|
||||||
|
mouse_pressed_on_kebab = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0; i<4; i++) {
|
||||||
|
if (ingredients[i].contains(position)) {
|
||||||
|
current_kebab[i] += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean everything_added = true;
|
||||||
|
for(int i : current_kebab){
|
||||||
|
if(i == 0) {
|
||||||
|
everything_added = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(everything_added) {
|
||||||
|
for(int i=0; i<current_kebab.length; i++) {
|
||||||
|
current_kebab[i] = 0;
|
||||||
|
}
|
||||||
|
ingredients[4].visible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMouseUp(Vector position, MouseButton button) {
|
||||||
|
for (int i=0; i<customers.length; i++) {
|
||||||
|
// only sell kebab when (1) a kebab is (2) dragged on a customer that has (3) not already been fed
|
||||||
|
if(mouse_pressed_on_kebab && customers[i].contains(position) && !fed_customers[i]) {
|
||||||
|
sellKebabStatistics(1);
|
||||||
|
ingredients[4].visible(false);
|
||||||
|
ingredients[4].center(10+7*4, -20);
|
||||||
|
fed_customers[i] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// must be at bottom for previous checks to work
|
||||||
|
mouse_pressed_on_kebab = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static helper methods
|
// Static helper methods
|
||||||
@@ -91,6 +142,12 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
|||||||
ingredients[2] = new Image("images/kebab-pack/bread-256x256.png");
|
ingredients[2] = new Image("images/kebab-pack/bread-256x256.png");
|
||||||
ingredients[3] = new Image("images/kebab-pack/lettuce-96x96.png");
|
ingredients[3] = new Image("images/kebab-pack/lettuce-96x96.png");
|
||||||
ingredients[4] = new Image("images/kebab-pack/kebab-128x128.png");
|
ingredients[4] = new Image("images/kebab-pack/kebab-128x128.png");
|
||||||
|
ingredients[4].visible(false);
|
||||||
|
|
||||||
|
for (int i=0; i<5; i++) {
|
||||||
|
ingredients[i].size(5, 5);
|
||||||
|
ingredients[i].center(10+ 7*i, -20);
|
||||||
|
}
|
||||||
|
|
||||||
return ingredients;
|
return ingredients;
|
||||||
}
|
}
|
||||||
@@ -107,7 +164,7 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
|||||||
moneyIcon.center(-12, 25);
|
moneyIcon.center(-12, 25);
|
||||||
Image kebabSoldIcon = new Image("images/kebab-pack/kebab-128x128.png").size(2, 2);
|
Image kebabSoldIcon = new Image("images/kebab-pack/kebab-128x128.png").size(2, 2);
|
||||||
kebabSoldIcon.center(-2, 25);
|
kebabSoldIcon.center(-2, 25);
|
||||||
Image waitingCustomersIcon = new Image("images/kebab-pack/aladin-256x256.png").size(2, 2);
|
Image waitingCustomersIcon = new Image("images/kebab-pack/customer.png").size(2, 2);
|
||||||
waitingCustomersIcon.center(8, 25);
|
waitingCustomersIcon.center(8, 25);
|
||||||
|
|
||||||
scene.add(moneyButton);
|
scene.add(moneyButton);
|
||||||
@@ -165,6 +222,23 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
|||||||
public static void setWaitingCustomers(Text[] texts, int waitingCustomers) {
|
public static void setWaitingCustomers(Text[] texts, int waitingCustomers) {
|
||||||
texts[2].content(String.valueOf(waitingCustomers));
|
texts[2].content(String.valueOf(waitingCustomers));
|
||||||
}
|
}
|
||||||
|
public void sellKebabStatistics(int amount) {
|
||||||
|
s.kebabSold(s.kebabSold()+amount);
|
||||||
|
s.money(s.money() + s.kebabPrice());
|
||||||
|
Main.config.save();
|
||||||
|
setKebabSold(texts, s.kebabSold());
|
||||||
|
setMoney(texts, s.money());
|
||||||
|
|
||||||
|
if(s.money() >= 67) {
|
||||||
|
resetStats();
|
||||||
|
Controller.transitionToScene(new VictoryScene());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void incrementWaitingCustomers(int amount) {
|
||||||
|
s.waitingCustomers(s.waitingCustomers()+amount);
|
||||||
|
Main.config.save();
|
||||||
|
setWaitingCustomers(texts, s.waitingCustomers());
|
||||||
|
}
|
||||||
|
|
||||||
public static void saveStats(Text[] texts) {
|
public static void saveStats(Text[] texts) {
|
||||||
int money = Integer.parseInt(texts[0].content());
|
int money = Integer.parseInt(texts[0].content());
|
||||||
@@ -175,4 +249,11 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
|||||||
System.out.println(kebabSold);
|
System.out.println(kebabSold);
|
||||||
System.out.println(waitingCustomers);
|
System.out.println(waitingCustomers);
|
||||||
}
|
}
|
||||||
}
|
public void resetStats() {
|
||||||
|
s.money(2);
|
||||||
|
s.kebabPrice(5);
|
||||||
|
s.kebabSold(0);
|
||||||
|
s.waitingCustomers(0);
|
||||||
|
Main.config.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package project.scenes;
|
||||||
|
|
||||||
|
import pi.Controller;
|
||||||
|
import pi.Scene;
|
||||||
|
import pi.actor.Actor;
|
||||||
|
import pi.actor.Animation;
|
||||||
|
import pi.actor.Rectangle;
|
||||||
|
import pi.actor.Text;
|
||||||
|
import pi.graphics.geom.Vector;
|
||||||
|
|
||||||
|
import static pi.Controller.fonts;
|
||||||
|
import java.awt.Font;
|
||||||
|
|
||||||
|
|
||||||
|
public class VictoryScene extends Scene {
|
||||||
|
boolean faded_out;
|
||||||
|
Actor sixseven;
|
||||||
|
|
||||||
|
public VictoryScene() {
|
||||||
|
Controller.jukebox.playSound("sounds/reward.mp3");
|
||||||
|
|
||||||
|
Font font = fonts.get("fonts/BitcountGridDouble-Regular.ttf");
|
||||||
|
|
||||||
|
Text designer = new Text("Design: Alf");
|
||||||
|
designer.color("#ffffff");
|
||||||
|
designer.font(font);
|
||||||
|
designer.height(2.5);
|
||||||
|
Text pr = new Text("PR: Kevon Faison");
|
||||||
|
pr.color("#ffffff");
|
||||||
|
pr.font(font);
|
||||||
|
pr.height(2.5);
|
||||||
|
Text programmer = new Text("Programming: Benjamin Burkhardt");
|
||||||
|
programmer.color("#ffffff");
|
||||||
|
programmer.font(font);
|
||||||
|
programmer.height(1.5);
|
||||||
|
//Rectangle rect = new Rectangle(1000, 600);
|
||||||
|
//rect.color("#000000");
|
||||||
|
|
||||||
|
designer.center(0, 4);
|
||||||
|
pr.center(0, 0);
|
||||||
|
programmer.center(0, -4);
|
||||||
|
//rect.center(0,0);
|
||||||
|
|
||||||
|
add(designer);
|
||||||
|
add(pr);
|
||||||
|
add(programmer);
|
||||||
|
//add(rect);
|
||||||
|
|
||||||
|
sixseven = Animation.createFromAnimatedGif("images/kebab-pack/reward.gif", 1.48*15, 1.25*15);
|
||||||
|
sixseven.center(0, 0);
|
||||||
|
|
||||||
|
//rect.applyImpulse(new Vector(0, -1).multiply(50000));
|
||||||
|
sixseven.applyImpulse(new Vector(0, -1).multiply(50000));
|
||||||
|
|
||||||
|
add(sixseven);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ public class Statistics extends ConfigGroup {
|
|||||||
private int totalEarned = 0;
|
private int totalEarned = 0;
|
||||||
|
|
||||||
public Statistics() {
|
public Statistics() {
|
||||||
money(0);
|
money(2);
|
||||||
kebabPrice(5);
|
kebabPrice(5);
|
||||||
upgradeLevel(0);
|
upgradeLevel(0);
|
||||||
kebabSold(0);
|
kebabSold(0);
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
Binary file not shown.
Reference in New Issue
Block a user