Limit holder's cell size to match board's size (closes #2)
This commit is contained in:
parent
07fed37697
commit
c302a4b5b4
2 changed files with 53 additions and 2 deletions
51
core/src/io/github/lonamiwebs/klooni/GameSerializer.java
Normal file
51
core/src/io/github/lonamiwebs/klooni/GameSerializer.java
Normal file
|
@ -0,0 +1,51 @@
|
|||
package io.github.lonamiwebs.klooni;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class GameSerializer {
|
||||
// integer version
|
||||
// integer game mode:
|
||||
// integer current/high score
|
||||
//
|
||||
// TODO: Scorer specific
|
||||
// Board on row major order:
|
||||
// true color if cell is filled
|
||||
// false if cell is empty
|
||||
// 3 held pieces IDs (-1 if null)
|
||||
|
||||
// Modify this if the saving scheme changes
|
||||
private static final int VERSION = 1;
|
||||
|
||||
public static void serialize(final int /*GameScreen*/ game, final OutputStream output)
|
||||
throws IOException {
|
||||
DataOutputStream out = new DataOutputStream(output);
|
||||
try {
|
||||
out.writeInt(VERSION);
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
|
||||
// todo uhm maybe make the classes serializable? like telethon, kinda, idk, bye.
|
||||
|
||||
|
||||
/*
|
||||
DataInputStream d = new DataInputStream(new FileInputStream("test.txt"));
|
||||
|
||||
DataOutputStream out = new DataOutputStream(new FileOutputStream("test1.txt"));
|
||||
|
||||
String count;
|
||||
d.readFully();
|
||||
while((count = d.readLine()) != null){
|
||||
String u = count.toUpperCase();
|
||||
System.out.println(u);
|
||||
out.writeBytes(u + " ,");
|
||||
}
|
||||
d.close();
|
||||
out.close();
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -90,12 +90,12 @@ public class PieceHolder {
|
|||
pieces[i] = Piece.random();
|
||||
|
||||
// Set the absolute position on screen and the cells' cellSize
|
||||
// Also clamp the cell size to be the picked * 2 as maximum, or
|
||||
// Also clamp the cell size to be the picked size as maximum, or
|
||||
// it would be too big in some cases.
|
||||
pieces[i].pos.set(area.x + i * perPieceWidth, area.y);
|
||||
pieces[i].cellSize = Math.min(Math.min(
|
||||
perPieceWidth / pieces[i].cellCols,
|
||||
area.height / pieces[i].cellRows), pickedCellSize * 2f);
|
||||
area.height / pieces[i].cellRows), pickedCellSize);
|
||||
|
||||
// Center the piece on the X and Y axes. For this we see how
|
||||
// much up we can go, this is, (area.height - piece.height) / 2
|
||||
|
|
Loading…
Reference in a new issue