Rev 583 |
Rev 590 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
package com.gebauz.PonPonChun.game;
import com.badlogic.gdx.Gdx;
import com.gebauz.Bauzoid.parser.ScanException;
import com.gebauz.Bauzoid.parser.Tokenizer;
import com.gebauz.PonPonChun.game.entities.Block;
import com.gebauz.PonPonChun.game.entities.PlayField;
public class GameModeLogicEndless
extends GameModeLogic
{
// Constants========================================================================================
public static final int MAX_SPEED =
10;
public static final int MAX_ROWS =
10;
public static final int MIN_SPEED =
1;
public static final int MIN_ROWS =
0;
public static final int DEFAULT_SPEED =
1;
public static final int DEFAULT_ROWS =
3;
// Embedded Types===================================================================================
// Members==========================================================================================
// Methods==========================================================================================
public GameModeLogicEndless
(GameLogic gameLogic
)
{
super(gameLogic, GameLogic.
GameMode.
ENDLESS);
}
@
Override
public void init
(String param
)
{
mBlockRandomizer.
addEntry(Block.
TYPE_BLACK,
20);
mBlockRandomizer.
addEntry(Block.
TYPE_WHITE,
20);
mBlockRandomizer.
addEntry(Block.
TYPE_RED,
20);
mBlockRandomizer.
addEntry(Block.
TYPE_GREEN,
20);
mBlockRandomizer.
addEntry(Block.
TYPE_BLUE,
20);
mBlockRandomizer.
addEntry(Block.
TYPE_YELLOW,
20);
mBlockRandomizer.
addEntry(Block.
TYPE_BOMB,
10);
mBlockRandomizer.
addEntry(Block.
TYPE_CRYSTAL,
1);
// interpret param for level/stage/speed
int speed =
3;
int rows =
3;
try
{
Tokenizer t =
new Tokenizer
(param
);
speed =
(int)t.
readNumber();
t.
readToken(":");
rows =
(int)t.
readNumber();
}
catch (ScanException ex
)
{
ex.
log(GameConsts.
LOG_TAG);
}
randomizeInitialLevel
(rows
);
getGameLogic
().
getPlayField().
loadPlayField(Gdx.
files.
internal("data/levels/level02.txt"));
//getGameLogic().getPlayField().setAdvanceSpeed(0.1f * speed);
}
public void randomizeInitialLevel
(int startRow
)
{
PlayField pf = getGameLogic
().
getPlayField();
pf.
clearAllBlocks();
// row by row randomization that prevents triplets
int[] lastRow =
null;
int[] prevLastRow =
null;
boolean firstRow =
true;
for (int dy =
(PlayField.
NUM_CELLS_Y-startRow
); dy
< (PlayField.
NUM_CELLS_Y); dy++
)
{
int[] row = generateRow
(lastRow, prevLastRow
);
if (firstRow
)
{
row
[2] =
6;
firstRow =
false;
}
for (int dx =
0; dx
< row.
length; dx++
)
{
pf.
spawnBlock(row
[dx
], dx, dy
);
}
if (lastRow
!=
null)
prevLastRow = lastRow.
clone();
lastRow = row.
clone();
}
pf.
setNextRow(generateRow
(lastRow, prevLastRow
));
}
@
Override
public void exit
()
{
}
@
Override
public void update
(float deltaTime
)
{
}
@
Override
public void render
()
{
//if (getGameLogic().getPlayField().isGameOver())
//PonPonChunCustomServices.getInstance().getScoringFont().drawText("GAME OVER", 100, 300, GameConsts.WHITE_COLOR, 4);
}
// Getters/Setters==================================================================================
}