Skip to content

Commit

Permalink
Moved out files from Horadrix to top level directory so index file ca…
Browse files Browse the repository at this point in the history
…n access data/
  • Loading branch information
asalga committed Jul 7, 2013
1 parent f49957b commit c311db4
Show file tree
Hide file tree
Showing 29 changed files with 135 additions and 179 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
149 changes: 55 additions & 94 deletions Horadrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,45 +56,9 @@ public class GemToken extends Token{

}
/**
- refactor Token
- allow doing match after row falls after failure or
success to swap.
- Create loading screen
- Add statistics screen (score, leveltime, tokens destroyed, etc)
- Measure and make efficient the making of a random board
- Comment matchesLeft, right, up, down
- Display Floating score
- Add mechanism to match tokens with unlike tokens.
- Prevent swapping a token that has been marked for removal
- Add easing to falling tokens
Req:
- users should be able to add their own gems with their own behaviours
- Special gems need to match with regular gems
- prevent popping gems on invisible part of board
Bugs:
- Fix redundant row/col values in board and tokens.
- Prevent two layered tokens
*/


/**
- on click, get row and column
- on mouve, see if the cursor is now in a row above, below or to left or to right of token
- if yes,
swap(a,b);
keep track of a
once a no longer is moving,
check if swap was valid,
if no, swap back
Horadrix
Andor Salga
June 2013
*/

PApplet globalApplet;
Expand Down Expand Up @@ -215,7 +179,7 @@ void resetBoard(){
*/

if(false == validSwapExists()){
println("**** no moves remaining ****");
//println("**** no moves remaining ****");
}
}

Expand Down Expand Up @@ -262,7 +226,7 @@ void removeMarkedTokens(){
Token tokenToDestroy = board[r][c];

if(tokenToDestroy.isDying()){//.isMarkedForDeletion()){
println("marked for delection...");
//println("marked for delection...");
//
tokenToDestroy.destroy();
dyingTokens.add(tokenToDestroy);
Expand Down Expand Up @@ -335,7 +299,7 @@ void update(){

// If it was not a valid swap, animate it back from where it came.
if(isValidSwap(swapToken1, swapToken2) == false){
println("not a valid swap");
//println("not a valid swap");

int r1 = swapToken1.getRow();
int c1 = swapToken1.getColumn();
Expand Down Expand Up @@ -371,7 +335,7 @@ void update(){

}
else if(swapToken1.arrivedAtDest() && swapToken1.isReturning()){
println("returned");
//println("returned");
swapToken1.dropIntoCell();
swapToken2.dropIntoCell();
swapToken1.setReturning(false);
Expand Down Expand Up @@ -414,7 +378,7 @@ void update(){
dropTokens();

if(validSwapExists() == false){
println("no more moves available!");
//println("no more moves available!");
}

//if(markTokensForRemoval()){
Expand All @@ -438,64 +402,61 @@ void update(){
* they want to swap with.
*/
public void mouseDragged(){
//println("moved: " + mouseX);

// convert the mouse coords to grid coordinates
int r = (int)map(mouseY, START_Y, START_Y + BOARD_ROWS * TOKEN_SIZE, 0, BOARD_ROWS);
int c = (int)map(mouseX, START_X, START_X + BOARD_COLS * TOKEN_SIZE, 0, BOARD_COLS);

println("r: " + r + ", " + "c: " + c);

if(currToken1 != null){
if(c != currToken1.getColumn() || r != currToken1.getRow() && currToken2 == null){

if(currToken2 == null){
currToken2 = board[r][c];

// We swap and unswap just to make the code easier to write and read.
// swapTokens(currToken1, currToken2);

// User clicked on a token that's too far to swap with the one already selected
// In that case, what they are probably doing is starting the 'swap process' over.

int token1Row = currToken1.getRow();
int token1Column = currToken1.getColumn();

int token2Row = currToken2.getRow();
int token2Column = currToken2.getColumn();

//
//if( Math.abs(currToken1.getRow() - currToken2.getRow()) > 1 || Math.abs(currToken1.getColumn() - currToken2.getColumn()) > 1 ||
if( abs(token1Row - token2Row) + abs(token1Column - token2Column) != 1){
//swapTokens(currToken1, currToken2);
currToken1.setSelect(false);
currToken1 = currToken2;
currToken1.setSelect(true);
currToken2 = null;
}
else{
swapToken1 = currToken1;
swapToken2 = currToken2;
if(currToken1 != null && currToken2 == null){
if(c != currToken1.getColumn() || r != currToken1.getRow()){

if(currToken2 == null){
currToken2 = board[r][c];

// We swap and unswap just to make the code easier to write and read.
// swapTokens(currToken1, currToken2);

// Animate will detach the tokens from the board
swapToken1.animateTo(token2Row, token2Column);
swapToken2.animateTo(token1Row, token1Column);
// User clicked on a token that's too far to swap with the one already selected
// In that case, what they are probably doing is starting the 'swap process' over.

int token1Row = currToken1.getRow();
int token1Column = currToken1.getColumn();

int token2Row = currToken2.getRow();
int token2Column = currToken2.getColumn();

//
//if( Math.abs(currToken1.getRow() - currToken2.getRow()) > 1 || Math.abs(currToken1.getColumn() - currToken2.getColumn()) > 1 ||
if( abs(token1Row - token2Row) + abs(token1Column - token2Column) != 1){
//swapTokens(currToken1, currToken2);
currToken1.setSelect(false);
currToken1 = currToken2;
currToken1.setSelect(true);
currToken2 = null;
}
else{
swapToken1 = currToken1;
swapToken2 = currToken2;

// Animate will detach the tokens from the board
swapToken1.animateTo(token2Row, token2Column);
swapToken2.animateTo(token1Row, token1Column);

deselectTokens();
}

deselectTokens();
//deselectTokens();
/*else if(!isValidSwap(currToken1, currToken2)){
swapTokens(currToken1, currToken2);
deselectTokens();
}else{
markTokensForRemoval();
gemRemovalTicker = new Ticker();
deselectTokens();
}*/
}

//deselectTokens();
/*else if(!isValidSwap(currToken1, currToken2)){
swapTokens(currToken1, currToken2);
deselectTokens();
}else{
markTokensForRemoval();
gemRemovalTicker = new Ticker();
deselectTokens();
}*/
}
}
}
}

/*
Expand Down Expand Up @@ -1440,7 +1401,7 @@ public class Token{
deathTicker.tick();
if(deathTicker.getTotalTime() >= 1.0f){
isLiving = false;
println("dead");
//println("dead");
}
}
}
Expand All @@ -1453,7 +1414,7 @@ public class Token{
}

public void destroy(){
println("destroyed");
//println("destroyed");
deathTicker = new Ticker();
//animTicker = new Ticker();
}
Expand Down
10 changes: 5 additions & 5 deletions Horadrix/Horadrix.pde → Horadrix.pde
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void resetBoard(){
*/

if(false == validSwapExists()){
println("**** no moves remaining ****");
//println("**** no moves remaining ****");
}
}

Expand Down Expand Up @@ -169,7 +169,7 @@ void removeMarkedTokens(){
Token tokenToDestroy = board[r][c];

if(tokenToDestroy.isDying()){//.isMarkedForDeletion()){
println("marked for delection...");
//println("marked for delection...");
//
tokenToDestroy.destroy();
dyingTokens.add(tokenToDestroy);
Expand Down Expand Up @@ -242,7 +242,7 @@ void update(){

// If it was not a valid swap, animate it back from where it came.
if(isValidSwap(swapToken1, swapToken2) == false){
println("not a valid swap");
//println("not a valid swap");

int r1 = swapToken1.getRow();
int c1 = swapToken1.getColumn();
Expand Down Expand Up @@ -278,7 +278,7 @@ void update(){

}
else if(swapToken1.arrivedAtDest() && swapToken1.isReturning()){
println("returned");
//println("returned");
swapToken1.dropIntoCell();
swapToken2.dropIntoCell();
swapToken1.setReturning(false);
Expand Down Expand Up @@ -321,7 +321,7 @@ void update(){
dropTokens();

if(validSwapExists() == false){
println("no more moves available!");
//println("no more moves available!");
}

//if(markTokensForRemoval()){
Expand Down
77 changes: 0 additions & 77 deletions Horadrix/index.html

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
build: minify

minify:
cat Horadrix/*.pde Horadrix/*.java > Horadrix.js
cat *.pde *.java > Horadrix.js

publish: minify
git add Horadrix-min.js
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions Horadrix/Token.pde → Token.pde
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public class Token{
deathTicker.tick();
if(deathTicker.getTotalTime() >= 1.0f){
isLiving = false;
println("dead");
//println("dead");
}
}
}
Expand All @@ -218,7 +218,7 @@ public class Token{
}

public void destroy(){
println("destroyed");
//println("destroyed");
deathTicker = new Ticker();
//animTicker = new Ticker();
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading

0 comments on commit c311db4

Please sign in to comment.