Skip to content

Commit

Permalink
Another blob commit. This one is just about alpha.
Browse files Browse the repository at this point in the history
Signed-off-by: Ken Hoover <[email protected]>
  • Loading branch information
Ken Hoover committed Jun 19, 2013
1 parent 62941a1 commit 7e65188
Show file tree
Hide file tree
Showing 28 changed files with 1,251 additions and 102 deletions.
12 changes: 6 additions & 6 deletions rop-game-android/assets/img/food/food.atlas
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@

food.png
format: RGBA8888
filter: Linear,Linear
filter: Nearest,Nearest
repeat: none
bigger food/sideview_bread_top
rotate: false
xy: 1, 1
size: 674, 180
orig: 674, 180
size: 600, 87
orig: 600, 87
offset: 0, 0
index: -1

food2.png
format: RGBA8888
filter: Linear,Linear
filter: Nearest,Nearest
repeat: none
bread/bread_brown
rotate: false
Expand Down Expand Up @@ -46,7 +46,7 @@ bread/bread_normal

food3.png
format: RGBA8888
filter: Linear,Linear
filter: Nearest,Nearest
repeat: none
icons/bread
rotate: false
Expand All @@ -69,7 +69,7 @@ icons/lettuce
orig: 130, 50
offset: 0, 0
index: -1
icons/Onion
icons/onion
rotate: false
xy: 397, 1
size: 130, 50
Expand Down
Binary file modified rop-game-android/assets/img/food/food.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion rop-game-android/gen/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/com
/com
/.gitignore
116 changes: 108 additions & 8 deletions rop-game/src/com/kandl/ropgame/GameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,78 @@
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.*;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.scenes.scene2d.utils.*;
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Payload;
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Source;
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Target;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Scaling;
import com.kandl.ropgame.ingredients.Chicken;
import com.kandl.ropgame.ingredients.Ingredient;
import com.kandl.ropgame.ingredients.Lettuce;
import com.kandl.ropgame.ingredients.Onion;
import com.kandl.ropgame.ingredients.Tomato;
import com.kandl.ropgame.ingredients.WhiteBread;
import com.kandl.ropgame.managers.GroupManager;
import com.kandl.ropgame.managers.TableManager;
import com.kandl.ropgame.managers.SheetManager;
import com.kandl.ropgame.model.Sandwich;
import com.kandl.ropgame.ui.UILayer;
import com.kandl.ropgame.view.Person;
import com.kandl.ropgame.view.ProgressBar;
import com.kandl.ropgame.view.sandwichView.CutView;
import com.kandl.ropgame.view.sandwichView.MakeView;

public class GameScreen implements Screen{
public static final int FRONT = 0;
public static final int INGREDIENTS = 1;
public static final int GRILL = 2;
public static final int ASSEMBLY = 3;

private MakeView currentMaking;
private CutView currentCutting = null;
private DragAndDrop makeDrag;
private final UILayer UILayer;
private final Stage[] Scene = new Stage[4];
private Stage ActiveScene;
private Image frontBackground;
private float offsetX;
private Array<Ingredient> ingredients = new Array<Ingredient>(5);
private Music frontMusic = Gdx.audio.newMusic(Gdx.files.internal("sound/front_music.ogg"));
private Music grillMusic = Gdx.audio.newMusic(Gdx.files.internal("sound/grill_music.ogg"));

public float getOffsetX() {
return offsetX;
}

public GameScreen() {
//Create UI, input processors
UILayer = new UILayer(1280, 800, true);
SheetManager.initialize(UILayer);
frontMusic.setLooping(true);
frontMusic.setVolume(0.5f);
frontMusic.play();
grillMusic.setLooping(true);
grillMusic.setVolume(0.75f);

Chicken.initialize(ingredients);
Lettuce.initialize(ingredients);
Onion.initialize(ingredients);
Tomato.initialize(ingredients);
WhiteBread.initialize();
Ingredient.loadAll();

//Create scenes
Scene[0] = createFrontScreen();
Scene[1] = createMakeScreen();
Scene[2] = createGrillScreen();
Scene[3] = createCutScreen();
Person.initialize();
ActiveScene = Scene[0];

InputMultiplexer input = new InputMultiplexer();
Expand All @@ -85,13 +124,56 @@ private Stage createGrillScreen() {
Texture background = RopGame.assets.get("img/backgrounds/Grills.png", Texture.class);
scene.addActor(new Image(new TextureRegionDrawable(new TextureRegion(background, 0, 224, 1280, 800))));
for (Actor a: scene.getActors()) {
a.setPosition(-50, 0);
a.setPosition(0, 0);
}
return scene;
}

private Stage createMakeScreen() {
makeDrag = new DragAndDrop();
makeDrag.setDragActorPosition(-300, 100);
Stage scene = new Stage(1280, 800, true, UILayer.getSpriteBatch());
Texture background = RopGame.assets.get("img/backgrounds/Making.png", Texture.class);
scene.addActor(new Image(new TextureRegionDrawable(new TextureRegion(background, 0, 224, 1280, 800))));
for (Actor a: scene.getActors()) {
a.setPosition(-60, 0);
}
int n = 0;
for (final Ingredient i: ingredients) {
Image current = new Image(new SpriteDrawable(i.getIcon()));
scene.addActor(current);
current.setPosition(10 + 170 * n++, 550);
makeDrag.addSource(new Source(current) {

@Override
public Payload dragStart(InputEvent event, float x, float y,
int pointer) {
Payload p = new Payload();
p.setDragActor(i.getSideView());
p.setObject(i);
return p;
}

});
}
currentMaking = new MakeView(new Sandwich(new WhiteBread()));
scene.addActor(currentMaking);
currentMaking.setPosition(100, 146);
makeDrag.addTarget(new Target(currentMaking) {

@Override
public boolean drag(Source source, Payload payload, float x,
float y, int pointer) {
return !((MakeView) getActor()).isFull();
}

@Override
public void drop(Source source, Payload payload, float x, float y,
int pointer) {
((MakeView) getActor()).addIngredient((Ingredient) payload.getObject());
}

});
return scene;
}

Expand All @@ -103,23 +185,28 @@ private Stage createFrontScreen() {
@Override
public void drag (InputEvent event, float x, float y, int pointer) {
float dx = -getDeltaX();
if (Scene[0].getRoot().getX() + dx >= 0) Scene[0].addAction(Actions.moveTo(0, 0)); // if root left edge enters stage
if (Scene[0].getRoot().getX() + dx >= 0) { Scene[0].addAction(Actions.moveTo(0, 0)); offsetX = 0;}// if root left edge enters stage
else if (Scene[0].getRoot().getX() + dx <= Scene[0].getWidth() - 445 - frontBackground.getWidth()) { // if root right edge is left of background + UI coverage
Scene[0].addAction(Actions.moveTo(Scene[0].getWidth()- 445 - frontBackground.getWidth(), 0));
offsetX = Scene[0].getWidth() - 445 - frontBackground.getWidth();
}
else Scene[0].addAction(Actions.moveBy(dx, 0, 0));
else { Scene[0].addAction(Actions.moveBy(dx, 0, 0)); offsetX += dx; }
}
});
frontBackground = new Image(new TiledDrawable(new TextureRegion(RopGame.assets.get("img/backgrounds/new front.png", Texture.class), 0, 224, 1280, 800)), Scaling.stretch);
scene.addActor(frontBackground);
frontBackground.setSize(1280 * 5, 800);
//scene.addActor(new GroupManager());
scene.addActor(new GroupManager());
return scene;
}

public void switchScreen(final int screen) {
if (RopGame.DEBUG) assert(screen >= 0 && screen <= 3);
frontMusic.stop();
grillMusic.stop();
((InputMultiplexer) Gdx.input.getInputProcessor()).removeProcessor(ActiveScene);
if (screen == 0) frontMusic.play();
else if (screen == 2) grillMusic.play();
ActiveScene = Scene[screen];
((InputMultiplexer) Gdx.input.getInputProcessor()).addProcessor(ActiveScene);
}
Expand Down Expand Up @@ -168,14 +255,19 @@ public void resume() {
// TODO add call to showPauseOverlay

}

@Override
public void dispose() {
for (Stage s: Scene) {
s.dispose();
}
ActiveScene = null;
UILayer.dispose();
frontMusic.dispose();
grillMusic.dispose();
Ingredient.dispose();
Person.dispose();
ProgressBar.staticDispose();
}

public Stage getScreen(int stage) {
Expand All @@ -185,4 +277,12 @@ public Stage getScreen(int stage) {
public Stage getUI() {
return UILayer;
}

public MakeView getCurrentMaking() {
return currentMaking;
}

public CutView getCurrentCutting() {
return currentCutting;
}
}
7 changes: 4 additions & 3 deletions rop-game/src/com/kandl/ropgame/RopGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@
import com.badlogic.gdx.Game;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.kandl.ropgame.ingredients.Ingredient;
import com.kandl.ropgame.view.Person;

public class RopGame extends Game {
public static GameScreen gameScreen;
public static double score;
public static final int WIDTH = 1024;
public static final int HEIGHT = 600;
public static final boolean DEBUG = true;
public static final AssetManager assets = new AssetManager();

@Override
public void create() {
score = 0;
loadAll();
Person.initialize();
gameScreen = new GameScreen();
setScreen(gameScreen);
}
Expand All @@ -26,6 +25,8 @@ private void loadAll() {
assets.load("img/backgrounds/new front.png", Texture.class);
assets.load("img/backgrounds/cuttingBoard.png", Texture.class);
assets.load("img/backgrounds/Grills.png", Texture.class);
assets.load("img/backgrounds/Making.png", Texture.class);
assets.load("img/icons/buttons.atlas", TextureAtlas.class);
assets.finishLoading();
}

Expand Down
22 changes: 22 additions & 0 deletions rop-game/src/com/kandl/ropgame/ingredients/Bread.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.kandl.ropgame.ingredients;

import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.utils.Array;
import com.kandl.ropgame.model.Recipe.CookState;

public abstract class Bread extends Ingredient {

private static Array<Class<? extends Bread>> subclasses = new Array<Class<? extends Bread>>(false, 6);

public static void addSubclass (Class<? extends Bread> clazz) {
subclasses.add(clazz);
}

public static Class<? extends Bread> getRandomIngredient() {
return subclasses.random();
}

public abstract Image getTopView(CookState state);
}
25 changes: 25 additions & 0 deletions rop-game/src/com/kandl/ropgame/ingredients/Chicken.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.kandl.ropgame.ingredients;

import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable;
import com.badlogic.gdx.utils.Array;

public class Chicken extends Ingredient {
public static void initialize(Array<Ingredient> ingredients) {
Ingredient.addSubclass(Chicken.class);
ingredients.add(new Chicken());
}

@Override
public Image getSideView() {
// TODO Auto-generated method stub
return new Image(new SpriteDrawable(assets.get("img/food/food.atlas", TextureAtlas.class).createSprite("icons/chicken")));
}

@Override
public Sprite getIcon() {
return assets.get("img/food/food.atlas", TextureAtlas.class).createSprite("icons/chicken");
}
}
35 changes: 34 additions & 1 deletion rop-game/src/com/kandl/ropgame/ingredients/Ingredient.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
package com.kandl.ropgame.ingredients;

public abstract class Ingredient {
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.utils.Array;

// Every subclass must have a section where it declares itself to ingredient.
public abstract class Ingredient{

// Subclasses should load PIXMAP assets through here. Textures will be created in the Atlas.
protected static AssetManager assets = new AssetManager();
static {
assets.load("img/food/food.atlas", TextureAtlas.class);
}

public static void loadAll() {
assets.finishLoading();
}

public static void dispose() {
assets.dispose();
}

private static Array<Class<? extends Ingredient>> subclasses = new Array<Class<? extends Ingredient>>(false, 6);

public static void addSubclass (Class<? extends Ingredient> clazz) {
subclasses.add(clazz);
}

public static Class<? extends Ingredient> getRandomIngredient() {
return subclasses.random();
}

public abstract Image getSideView();
public abstract Sprite getIcon();
}
Loading

0 comments on commit 7e65188

Please sign in to comment.