mirror of
https://inf.pirckheimer-gymnasium.de/kebab/kebab
synced 2026-08-26 16:31:23 +00:00
Some final improvements
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package project;
|
||||
|
||||
import project.scenes.GameScene;
|
||||
import project.scenes.LoadingScene;
|
||||
import project.scenes.VictoryScene;
|
||||
import project.utils.Statistics;
|
||||
@@ -13,19 +12,19 @@ import java.awt.Toolkit;
|
||||
|
||||
public class Main
|
||||
{
|
||||
public static ConfigLoader config;
|
||||
public static ConfigLoader CONFIG;
|
||||
public static int WINDOW_WIDTH = 1000;
|
||||
public static int WINDOW_HEIGHT = 600;
|
||||
|
||||
static {
|
||||
config = new ConfigLoader("kebab.properties", new Statistics());
|
||||
config.load();
|
||||
CONFIG = new ConfigLoader("kebab.properties", new Statistics());
|
||||
CONFIG.load();
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Controller.instantMode(false);
|
||||
Controller.start(new LoadingScene(), 1000, 600);
|
||||
//Controller.start(new GameScene(), 1000, 600);
|
||||
//Controller.start(new VictoryScene(), 1000, 600);
|
||||
Controller.start(new LoadingScene(), WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||
|
||||
try {
|
||||
Cursor customCursor = Toolkit.getDefaultToolkit().createCustomCursor(
|
||||
|
||||
@@ -25,6 +25,10 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
||||
Image tatli;
|
||||
Text[] texts;
|
||||
Image[] ingredients; // array of all ingredients (including the final kebab lol)
|
||||
static int INGREDIENTS_X = 13;
|
||||
static int INGREDIENTS_X_TRESHOLD = 7;
|
||||
static int INGREDIENTS_Y = -25;
|
||||
|
||||
int[] current_kebab; // used for remembering which ingredients have already been added to the current kebab build
|
||||
Actor[] customers;
|
||||
boolean[] fed_customers;
|
||||
@@ -35,6 +39,8 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
||||
public GameScene() {
|
||||
// the background music, color, stats (some meta information)
|
||||
Controller.jukebox.playSound("sounds/Mozart_Turkish_March_-_Orchestral_Melodic_Techno_-_TVV_music_320k.mp3");
|
||||
|
||||
// background and stuff
|
||||
bg = new Rectangle(2000, 2000);
|
||||
bg.color("#ffffff");
|
||||
bg.center(0, 0);
|
||||
@@ -42,11 +48,11 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
||||
addStatsCollectionOutline(this);
|
||||
texts = createTexts(this);
|
||||
camera().meter(10);
|
||||
s = Main.config.getGroup(Statistics.class);
|
||||
s = Main.CONFIG.getGroup(Statistics.class);
|
||||
|
||||
tatli = new Image("images/kebab-pack/tatli-ekmek-256x256.png");
|
||||
tatli.size(2.56*13, 2.56*13);
|
||||
tatli.center(-33, -23);
|
||||
tatli.center(-33.4, -23);
|
||||
|
||||
// create customers
|
||||
customers = new Actor[2];
|
||||
@@ -86,14 +92,14 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
||||
}
|
||||
|
||||
if(mouse_pressed_on_kebab) {
|
||||
ingredients[4].center(Controller.mousePosition());
|
||||
ingredients[ingredients.length-1].center(Controller.mousePosition());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseDown(Vector position, MouseButton button)
|
||||
{
|
||||
if(ingredients[4].contains(Controller.mousePosition()) && ingredients[4].isVisible()) {
|
||||
if(ingredients[ingredients.length-1].contains(Controller.mousePosition()) && ingredients[ingredients.length-1].isVisible()) {
|
||||
mouse_pressed_on_kebab = true;
|
||||
}
|
||||
|
||||
@@ -113,7 +119,7 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
||||
for(int i=0; i<current_kebab.length; i++) {
|
||||
current_kebab[i] = 0;
|
||||
}
|
||||
ingredients[4].visible(true);
|
||||
ingredients[ingredients.length-1].visible(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,8 +129,8 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
||||
// 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);
|
||||
ingredients[ingredients.length-1].visible(false);
|
||||
ingredients[ingredients.length-1].center(INGREDIENTS_X + INGREDIENTS_X_TRESHOLD*(ingredients.length-1) +2, INGREDIENTS_Y);
|
||||
fed_customers[i] = true;
|
||||
}
|
||||
}
|
||||
@@ -144,11 +150,12 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
||||
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);
|
||||
for (int i=0; i<ingredients.length-1; i++) {
|
||||
ingredients[i].size(5, 5).center(INGREDIENTS_X + INGREDIENTS_X_TRESHOLD*i, INGREDIENTS_Y);
|
||||
}
|
||||
|
||||
ingredients[ingredients.length-1].size(7, 7).center(INGREDIENTS_X + INGREDIENTS_X_TRESHOLD*(ingredients.length-1) +2, INGREDIENTS_Y);
|
||||
|
||||
return ingredients;
|
||||
}
|
||||
|
||||
@@ -179,7 +186,7 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
||||
Text[] texts = new Text[10];
|
||||
Font font = fonts.get("fonts/BitcountGridDouble-Regular.ttf");
|
||||
|
||||
Statistics s = Main.config.getGroup(Statistics.class);
|
||||
Statistics s = Main.CONFIG.getGroup(Statistics.class);
|
||||
|
||||
Text money = new Text(s.money());
|
||||
money.color("#000000");
|
||||
@@ -225,7 +232,7 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
||||
public void sellKebabStatistics(int amount) {
|
||||
s.kebabSold(s.kebabSold()+amount);
|
||||
s.money(s.money() + s.kebabPrice());
|
||||
Main.config.save();
|
||||
Main.CONFIG.save();
|
||||
setKebabSold(texts, s.kebabSold());
|
||||
setMoney(texts, s.money());
|
||||
|
||||
@@ -236,7 +243,7 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
||||
}
|
||||
public void incrementWaitingCustomers(int amount) {
|
||||
s.waitingCustomers(s.waitingCustomers()+amount);
|
||||
Main.config.save();
|
||||
Main.CONFIG.save();
|
||||
setWaitingCustomers(texts, s.waitingCustomers());
|
||||
}
|
||||
|
||||
@@ -254,6 +261,6 @@ public class GameScene extends Scene implements FrameListener, MouseClickListene
|
||||
s.kebabPrice(5);
|
||||
s.kebabSold(0);
|
||||
s.waitingCustomers(0);
|
||||
Main.config.save();
|
||||
Main.CONFIG.save();
|
||||
}
|
||||
}
|
||||
@@ -6,52 +6,66 @@ import pi.actor.Actor;
|
||||
import pi.actor.Animation;
|
||||
import pi.actor.Rectangle;
|
||||
import pi.actor.Text;
|
||||
import pi.event.FrameListener;
|
||||
import pi.graphics.geom.Vector;
|
||||
import project.Main;
|
||||
|
||||
import static pi.Controller.fonts;
|
||||
import java.awt.Font;
|
||||
|
||||
|
||||
public class VictoryScene extends Scene {
|
||||
public class VictoryScene extends Scene implements FrameListener {
|
||||
Font font;
|
||||
boolean faded_out;
|
||||
Text designer;
|
||||
Text pr;
|
||||
Text programmer;
|
||||
Rectangle rect;
|
||||
Actor sixseven;
|
||||
|
||||
public VictoryScene() {
|
||||
Controller.jukebox.playSound("sounds/reward.mp3");
|
||||
|
||||
Font font = fonts.get("fonts/BitcountGridDouble-Regular.ttf");
|
||||
font = fonts.get("fonts/BitcountGridDouble-Regular.ttf");
|
||||
|
||||
Text designer = new Text("Design: Alf");
|
||||
designer = new Text("Design: Alf");
|
||||
designer.color("#ffffff");
|
||||
designer.font(font);
|
||||
designer.height(2.5);
|
||||
Text pr = new Text("PR: Kevon Faison");
|
||||
pr = new Text("PR: Kevon Faison");
|
||||
pr.color("#ffffff");
|
||||
pr.font(font);
|
||||
pr.height(2.5);
|
||||
Text programmer = new Text("Programming: Benjamin Burkhardt");
|
||||
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");
|
||||
rect = new Rectangle(Main.WINDOW_WIDTH/camera().meter(), Main.WINDOW_HEIGHT/camera().meter());
|
||||
rect.color("#4d0000");
|
||||
|
||||
designer.center(0, 4);
|
||||
pr.center(0, 0);
|
||||
programmer.center(0, -4);
|
||||
//rect.center(0,0);
|
||||
rect.center(0,0);
|
||||
|
||||
add(designer);
|
||||
add(pr);
|
||||
add(programmer);
|
||||
//add(rect);
|
||||
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));
|
||||
rect.applyImpulse(new Vector(0, -1).multiply(67000));
|
||||
|
||||
sixseven.angularVelocity(-0.1);
|
||||
|
||||
add(sixseven);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFrame(double pastTime)
|
||||
{
|
||||
sixseven.center(rect.center());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user