Skip to content

Commit

Permalink
Fix screen ratio. Init accelerometer sensors.
Browse files Browse the repository at this point in the history
  • Loading branch information
hubbu committed Mar 30, 2012
1 parent ac6b04a commit 3a03161
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 18 deletions.
Binary file added pm-android/assets/data/assets1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pm-android/assets/data/assets2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
122 changes: 122 additions & 0 deletions pm-android/assets/data/pack
@@ -0,0 +1,122 @@

assets1.png
format: RGBA8888
filter: Nearest,Nearest
repeat: none
grassboard
rotate: false
xy: 0, 0
size: 720, 708
orig: 720, 708
offset: 0, 0
index: -1
smallgrass
rotate: false
xy: 726, 0
size: 91, 62
orig: 91, 62
offset: 0, 0
index: -1
smalldeadgrass
rotate: false
xy: 823, 0
size: 91, 62
orig: 91, 62
offset: 0, 0
index: -1

assets2.png
format: RGBA8888
filter: Nearest,Nearest
repeat: none
logointro
rotate: false
xy: 0, 0
size: 950, 59
orig: 950, 59
offset: 0, 0
index: -1
logogameover
rotate: false
xy: 0, 65
size: 259, 73
orig: 259, 73
offset: 0, 0
index: -1
newlandgameover
rotate: false
xy: 0, 144
size: 211, 27
orig: 211, 27
offset: 0, 0
index: -1
tile
rotate: false
xy: 0, 177
size: 202, 202
orig: 202, 202
offset: 0, 0
index: -1
moves
rotate: false
xy: 0, 385
size: 71, 14
orig: 71, 14
offset: 0, 0
index: -1
quitgameover
rotate: false
xy: 956, 0
size: 67, 39
orig: 67, 39
offset: 0, 0
index: -1
scoregameover
rotate: false
xy: 956, 45
size: 64, 14
orig: 64, 14
offset: 0, 0
index: -1
fungitop
rotate: false
xy: 0, 405
size: 53, 44
orig: 53, 44
offset: 0, 0
index: -1
fungibtm
rotate: false
xy: 0, 455
size: 53, 44
orig: 53, 44
offset: 0, 0
index: -1
fungiright
rotate: false
xy: 208, 177
size: 44, 53
orig: 44, 53
offset: 0, 0
index: -1
fungileft
rotate: false
xy: 208, 236
size: 44, 53
orig: 44, 53
offset: 0, 0
index: -1
milkjug
rotate: false
xy: 208, 295
size: 38, 53
orig: 38, 53
offset: 0, 0
index: -1
mushroom
rotate: false
xy: 77, 385
size: 35, 55
orig: 35, 55
offset: 0, 0
index: -1
2 changes: 1 addition & 1 deletion pm-desktop/src/com/ivanarellano/game/pm/pmGame.java
Expand Up @@ -8,7 +8,7 @@
import com.ivanarellano.game.pm.screen.GameScreen;

public class PmGame extends Game implements ApplicationListener {
public static final int SCREEN_WIDTH = 1280;
public static final int SCREEN_WIDTH = 1196; //1280
public static final int SCREEN_HEIGHT = 720;

public Stage stage;
Expand Down
51 changes: 34 additions & 17 deletions pm-desktop/src/com/ivanarellano/game/pm/screen/GameScreen.java
Expand Up @@ -22,70 +22,87 @@ public GameScreen(PmGame game) {
initStage();
}

public void update(float delta) {
game.stage.act(delta);

if (Gdx.input.getAccelerometerY() <= -7.0f) {
Gdx.app.log("accelY", "going left");
} else if (Gdx.input.getAccelerometerY() >= 7.0f) {
Gdx.app.log("accelY", "going right");
} else if (Gdx.input.getAccelerometerX() >= 9.5f) {
Gdx.app.log("accelX", "going down");
} else if (Gdx.input.getAccelerometerX() <= -7.5f) {
Gdx.app.log("accelX", "going up");
}
}

@Override
public void render(float delta) {
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
game.stage.act(delta);
game.stage.draw();

update(delta);

game.stage.draw();
}

@Override
public void resize(int width, int height) {
public void resize(int width, int height) {
}

@Override
public void show() {
public void show() {
}

@Override
public void hide() {
public void hide() {
}

@Override
public void pause() {
public void pause() {
}

@Override
public void resume() {
public void resume() {
}

@Override
public void dispose() {
game.stage.dispose();
}

void initStage() {
// add some grass
groupBoard.addActor(grassBoard);

// place board in the middle
groupBoard.x = PmGame.SCREEN_WIDTH/2 - grassBoard.width/2;

groupBoard.x = PmGame.SCREEN_WIDTH / 2 - grassBoard.width / 2;
groupBoard.y = PmGame.SCREEN_HEIGHT / 2 - grassBoard.height / 2;

// add and arrange tiles
int XOffset = 45;
int YOffset = 465;
for (int row = 0; row < Board.ROWS; row++) {
for (int col = 0; col < Board.COLS; col++) {
board.tiles[row][col].x = XOffset;
board.tiles[row][col].y = YOffset;

groupTiles.addActor(board.tiles[row][col]);

if (col >= 2)
XOffset = 45;
else
XOffset += 215;

if (board.tiles[row][col].number.contentEquals("0"))
board.tiles[row][col].visible = false;
}

YOffset -= 215;
}

// layer tiles on top of grass
groupBoard.addActor(groupTiles);

// place it all on the stage
game.stage.addActor(groupBoard);
}
Expand Down

0 comments on commit 3a03161

Please sign in to comment.