Skip to content

Commit

Permalink
make IScreen a class rather than interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
asalga committed Dec 3, 2013
1 parent d27aa44 commit 737dd03
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 71 deletions.
10 changes: 9 additions & 1 deletion Horadrix.pde
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ final int START_Y = (int)(CANVAS_HEIGHT/2.0f - BOARD_H_IN_PX/2.0f) + debugPosOff
// Used by the AssetStore
PApplet globalApplet;

// For Pjs, if the user has WebGL enabled, we will use it.
boolean using3DMode = true;

// In the perfect world, this would not be necessary, but unfortunately both
// Processing and Pjs have bugs that force us to sometimes have to distinguish
// which version we are using.
boolean usingPjs = false;

// As the levels increase, more and more token types are added
// This makes it a slightly harder to match tokens.
int numTokenTypesOnBoard = 3;
Expand All @@ -63,7 +71,7 @@ final float[] timePermitted = new float[]{4, 8, 12, 18};
Journey starts here
*/
void setup(){
size(CANVAS_WIDTH, CANVAS_HEIGHT);
size(CANVAS_WIDTH, CANVAS_HEIGHT, P2D);

// The style of the game is pixel art, so we don't want anti-aliasing
noSmooth();
Expand Down
25 changes: 13 additions & 12 deletions IScreen.pde
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/*
*/
public interface IScreen{
public class IScreen{

public void draw();
public void update();
public void draw(){}
public void update(){}

// Mouse methods
public void mousePressed();
public void mouseReleased();
public void mouseDragged();
public void mouseMoved();
public void mousePressed(){}
public void mouseReleased(){}
public void mouseDragged(){}
public void mouseMoved(){}

public void keyPressed();
public void keyReleased();
public void OnTransitionTo();
public void keyPressed(){}
public void keyReleased(){}
public void OnTransitionTo(){}

public String getName();
public String getName(){
return "none";
}
}
11 changes: 2 additions & 9 deletions ScreenGameOver.pde
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Displays game name and credits
*/
public class ScreenGameOver implements IScreen{
public class ScreenGameOver extends IScreen{

RetroFont solarWindsFont;

Expand Down Expand Up @@ -39,15 +39,8 @@ public class ScreenGameOver implements IScreen{
public String getName(){
return "gameover";
}

public void keyReleased(){}
public void keyPressed(){}

public void mousePressed(){
screens.setCurr(new ScreenGameplay());
}

public void mouseReleased(){}
public void mouseDragged(){}
public void mouseMoved(){}
}
}
20 changes: 11 additions & 9 deletions ScreenGameplay.pde
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This screen is the main gameplay screen.
*/
public class ScreenGameplay implements IScreen, Subject{
public class ScreenGameplay extends IScreen implements Subject{

ArrayList<LayerObserver> layerObserver;

Expand Down Expand Up @@ -188,23 +188,26 @@ public class ScreenGameplay implements IScreen, Subject{
// HACK: This line is here as a workaround a bug in Processing.js
// If removed, the board would translate diagonally on the canvas.
// when tokens are removed.
resetMatrix();


if(usingPjs){
resetMatrix();
}

if(layerObserver != null){
for(int i = 0; i < layerObserver.size(); i++){
layerObserver.get(i).draw();
}
}

//debug.addString("FPS: " + frameRate);

debug.draw();
}

/**
*/
public void update(){

//}
//public void fuckyou(){
// TODO: fix
// Need to notify that we are paused so the HUD can draw an overlay
if(isPaused){
Expand Down Expand Up @@ -344,7 +347,9 @@ public class ScreenGameplay implements IScreen, Subject{
boardModel.ensureGemCount();
}

resetMatrix();
if(usingPjs){
resetMatrix();
}

// Add a leading zero if seconds is a single digit
String secStr = "";
Expand Down Expand Up @@ -378,9 +383,6 @@ public class ScreenGameplay implements IScreen, Subject{
return (int)map(mouseX, START_X, START_X + BOARD_W_IN_PX, 0, BOARD_COLS);
}

public void mouseMoved(){}
public void mouseReleased(){}

/*
*
*/
Expand Down
17 changes: 3 additions & 14 deletions ScreenSplash.pde
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Displays game name and credits
*/
public class ScreenSplash implements IScreen{
public class ScreenSplash extends IScreen{

Ticker ticker;

Expand All @@ -11,9 +11,7 @@ public class ScreenSplash implements IScreen{
RetroLabel loadingLabel;
RetroLabel mainTitleLabel;

public void OnTransitionTo(){
}

public void OnTransitionTo(){}

public ScreenSplash(){
ticker = new Ticker();
Expand Down Expand Up @@ -49,21 +47,12 @@ public class ScreenSplash implements IScreen{

public void update(){
ticker.tick();
if(ticker.getTotalTime() > 0.01f){
//screens.transitionTo("gameplay");
if(ticker.getTotalTime() > 1.01f){
screens.transitionTo("story");
}
}

public String getName(){
return "splash";
}

public void keyReleased(){}
public void keyPressed(){}

public void mousePressed(){}
public void mouseReleased(){}
public void mouseDragged(){}
public void mouseMoved(){}
}
12 changes: 4 additions & 8 deletions ScreenStory.pde
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*/
public class ScreenStory implements IScreen{
public class ScreenStory extends IScreen{

private int storyPointer = 0;

Expand All @@ -16,6 +16,8 @@ public class ScreenStory implements IScreen{

private float target;

//private Background background;

public ScreenStory(){
solarWindsFont = new RetroFont("data/fonts/solarwinds.png", 14, 16, 2);

Expand All @@ -35,7 +37,7 @@ public class ScreenStory implements IScreen{

public void update(){

screens.transitionTo("gameplay");
//screens.transitionTo("gameplay");

if(extro == false){
textPos += (target - textPos) * easing;
Expand Down Expand Up @@ -66,15 +68,9 @@ public class ScreenStory implements IScreen{
}

// Mouse methods
public void mousePressed(){}
public void mouseReleased(){
clicked = true;
}
public void mouseDragged(){}
public void mouseMoved(){}

public void keyPressed(){}
public void keyReleased(){}

public String getName(){
return "story";
Expand Down
13 changes: 2 additions & 11 deletions ScreenWin.pde
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
*
*/
public class ScreenWin implements IScreen{
public class ScreenWin extends IScreen{

Ticker ticker;

Expand Down Expand Up @@ -33,7 +33,6 @@ public class ScreenWin implements IScreen{
*/
public void draw(){
background(0);

title.draw();
win.draw();
}
Expand All @@ -45,12 +44,4 @@ public class ScreenWin implements IScreen{
public String getName(){
return "win";
}

public void keyReleased(){}
public void keyPressed(){}

public void mousePressed(){}
public void mouseReleased(){}
public void mouseDragged(){}
public void mouseMoved(){}
}
}
9 changes: 6 additions & 3 deletions Token.pde
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,18 @@ public class Token{

// pjs giving issues here
pushMatrix();
resetMatrix();

if(usingPjs){
resetMatrix();
}

translate(START_X, START_Y);
//translate(START_X, START_Y);
translate(x, y);

rectMode(CENTER);

// draw a grey box to easily identify dead or null tokens
if(DEBUG_ON && (state == DEAD || state == DYING || type == TYPE_NULL)){
if(DEBUG_ON){//} && (state == DEAD || state == DYING || type == TYPE_NULL)){
pushStyle();
fill(128,128);
rect(0, 0, TOKEN_SIZE, TOKEN_SIZE);
Expand Down
5 changes: 1 addition & 4 deletions data/shaders/plane_deformation.frag
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@ uniform sampler2D iChannel0;
void main(){
// p will range from -1 to 1
vec2 p = 1.0 - 2.0 * gl_FragCoord.xy / vec2(400.0,400.0);

p.x *= 1.0;//iResolution.x / iResolution.y;

//vec2 cursor = 1.0 - 2.0 * iMouse.xy/iResolution.xy;
//p += cursor;


float pLength = length(p);

// Use polar coordinate to sample the texture
vec2 texel = vec2( 1.0/pLength + time * 0.3,
atan(p.y/p.x)/TAU);
vec2 texel = vec2( 1.0/pLength + time * 0.3, atan(p.y/p.x)/TAU);

vec4 fogCol = vec4(vec3(0.75) * pLength/2.0, 1.0);

Expand Down

0 comments on commit 737dd03

Please sign in to comment.