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