Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bin/Game/GUI/GameMenu.class
Binary file not shown.
Binary file modified bin/Game/GUI/GamePlaying.class
Binary file not shown.
Binary file modified bin/Game/GUI/ui/GamePauseDisplayLayer.class
Binary file not shown.
Binary file modified bin/Game/GUI/ui/buttons/GameMenuButton.class
Binary file not shown.
Binary file modified bin/Game/GUI/ui/buttons/GameSoundButton.class
Binary file not shown.
Binary file modified bin/Game/GUI/ui/buttons/GameURMButton.class
Binary file not shown.
Binary file modified bin/Game/GUI/ui/buttons/GameVolumeButton.class
Binary file not shown.
Binary file modified bin/Game/gameBase/GameUnitPair.class
Binary file not shown.
22 changes: 9 additions & 13 deletions src/Game/GUI/GameMenu.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package Game.GUI;

import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
Expand All @@ -15,6 +14,7 @@
import Game.Loader.ImageLoader;
import Game.PLUG.GameStateMethod;
import Game.gameBase.GameCalculator;
import Game.gameBase.GamePoint;
import Game.gameBase.GameUnitPair;
import Game.state.GameState;
import Game.state.MouseState;
Expand All @@ -30,8 +30,8 @@ public class GameMenu extends GameStateBase implements GameStateMethod {
private GameMenuButton[] buttons = new GameMenuButton[MENU_BUTTON_NUMBER];
private BufferedImage backgroundImage, backgroundMenuImage;

private Point menuWH;
private Point menuBgPoint;
private GameUnitPair menuWH;
private GamePoint menuBgPoint;

private static final float[] xMenuArray = { GAME_WIDTH / 2.0F, GAME_WIDTH / 2.0F, GAME_WIDTH / 2.0F };
private static final float[] yMenuArray = { 150 * SCALE, 220 * SCALE, 290 * SCALE };
Expand All @@ -54,15 +54,11 @@ private void loadGameMenuSelectBackgroundImage() throws IOException {
private void loadGameMenuBackgroundImage() throws IOException {
this.backgroundImage = ImageLoader.loadImage(GameSourceFilePath.MENU_BACKGROUND_IMAGE);

this.menuWH = GameCalculator
.calculate(
this.backgroundImage.getWidth(), this.backgroundImage.getHeight(),
x -> (int) (x * SCALE))
.toIntPoint();
this.menuWH = GameCalculator.calculate(
this.backgroundImage.getWidth(), this.backgroundImage.getHeight(),
x -> (int) (x * SCALE));

this.menuBgPoint = GameUnitPair
.buildGameUnitPair(GAME_WIDTH / 2.0F - menuWH.x / 2.0F, 45 * SCALE)
.toIntPoint();
this.menuBgPoint = GamePoint.buildGamePoint(GAME_WIDTH / 2.0F - menuWH.x / 2.0F, 45 * SCALE);
}

private void loadGameMenuButton() throws IOException {
Expand All @@ -74,8 +70,8 @@ public void render(Graphics g) {
g.drawImage(this.backgroundMenuImage, 0, 0, GAME_WIDTH, GAME_HEIGHT, null);

g.drawImage(backgroundImage,
this.menuBgPoint.x, this.menuBgPoint.y,
this.menuWH.x, this.menuWH.y,
this.menuBgPoint.getIntX(), this.menuBgPoint.getIntY(),
this.menuWH.getIntW(), this.menuWH.getIntH(),
null);

Arrays.stream(this.buttons).forEach(item -> item.render(g));
Expand Down
6 changes: 3 additions & 3 deletions src/Game/GUI/GamePlaying.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public GamePlaying(Game game) {
e.printStackTrace();
}


Random random = new Random();

smallCloudPosArrayY = IntStream
Expand Down Expand Up @@ -84,7 +83,8 @@ public void initClass() throws IOException {
this.maxTileOffset = levelTileWide - TILES_IN_WIDTH;
this.maxLevelOffset = this.maxTileOffset * TILES_SIZE;

this.bigCloudNumber = (int) Math.round((double) GameEnvironment.BIG_CLOUD_WIDTH.value / (double) this.gameLevelManager.getGameLevel().getMaxWidth());
this.bigCloudNumber = (int) Math.round((double) GameEnvironment.BIG_CLOUD_WIDTH.value
/ (double) this.gameLevelManager.getGameLevel().getMaxWidth());
}

public GameCharacter getPlayer() {
Expand Down Expand Up @@ -146,7 +146,7 @@ public void render(Graphics g) {
private void drawCloud(Graphics g) {
for (int i = 0; i < this.bigCloudNumber; i++) {
g.drawImage(this.bigCloudImage,
i * GameEnvironment.BIG_CLOUD_WIDTH.value - (int) (xLevelOffset - 0.3), // slower
i * GameEnvironment.BIG_CLOUD_WIDTH.value - (int) (xLevelOffset - 0.1), // slower
(int) (204 * SCALE),
GameEnvironment.BIG_CLOUD_WIDTH.value,
GameEnvironment.BIG_CLOUD_HEIGHT.value,
Expand Down
4 changes: 2 additions & 2 deletions src/Game/GUI/ui/GamePauseDisplayLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public void render(Graphics g) {

// background
g.drawImage(this.backgroundImage,
(int) this.bgPoint.x, (int) this.bgPoint.y,
(int) this.bgWH.x, (int) this.bgWH.y,
this.bgPoint.getIntX(), this.bgPoint.getIntY(),
this.bgWH.getIntW(), this.bgWH.getIntH(),
null);

this.allButtons.forEach(btn -> btn.render(g));
Expand Down
4 changes: 2 additions & 2 deletions src/Game/GUI/ui/buttons/GameMenuButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public GameMenuButton(GamePoint point, BufferedImage[] images, GameState state)
@Override
protected void initBounds() {
this.bounds = new Rectangle(
(int) this.point.x - xOffsetCenter, (int) this.point.y,
(int) this.point.getX() - xOffsetCenter, this.point.getIntY(),
MenuButtons.B_WIDTH.value,
MenuButtons.B_HEIGHT.value);
}
Expand All @@ -46,7 +46,7 @@ public void update() {
@Override
public void render(Graphics g) {
g.drawImage(this.images[this.mouseState.toDisplayIndex],
(int) this.point.x - xOffsetCenter, (int) this.point.y,
(int) this.point.getX() - xOffsetCenter, this.point.getIntY(),
MenuButtons.B_WIDTH.value, MenuButtons.B_HEIGHT.value, null);
}

Expand Down
7 changes: 3 additions & 4 deletions src/Game/GUI/ui/buttons/GameSoundButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public void setSoundImages(BufferedImage[][] soundImages) {

@Override
protected void initBounds() {
this.bounds = new Rectangle((int) this.point.x,
(int) this.point.y, PauseLayerButtons.SOUND_SIZE.value,
this.bounds = new Rectangle(this.point.getIntX(), this.point.getIntY(),
PauseLayerButtons.SOUND_SIZE.value,
PauseLayerButtons.SOUND_SIZE.value);
}

Expand All @@ -53,10 +53,9 @@ public void update() {
@Override
public void render(Graphics g) {
g.drawImage(this.soundImages[!isMul ? 0 : 1][this.mouseState.toDisplayIndex],
(int) this.point.x, (int) this.point.y,
this.point.getIntX(), this.point.getIntY(),
PauseLayerButtons.SOUND_SIZE.value,
PauseLayerButtons.SOUND_SIZE.value,
null);

}
}
4 changes: 2 additions & 2 deletions src/Game/GUI/ui/buttons/GameURMButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void update() {
@Override
public void render(Graphics g) {
g.drawImage(this.image[this.mouseState.toDisplayIndex],
(int) this.point.x, (int) this.point.y,
this.point.getIntX(), this.point.getIntY(),
URMButtons.URM_SIZE.value, URMButtons.URM_SIZE.value,
null);

Expand All @@ -40,7 +40,7 @@ public void render(Graphics g) {
@Override
protected void initBounds() {
this.bounds = new Rectangle(
(int) this.point.x, (int) this.point.y,
this.point.getIntX(), this.point.getIntY(),
URMButtons.URM_SIZE.value, URMButtons.URM_SIZE.value);
}

Expand Down
13 changes: 8 additions & 5 deletions src/Game/GUI/ui/buttons/GameVolumeButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ protected void initBounds() {
// this.point.addToX(this.point.x + VolumeButtons.SLIDER_WIDTH.value / 2.0F);
this.buttonX = (int) (this.point.x + VolumeButtons.SLIDER_WIDTH.value / 2.0F);

this.bounds = new Rectangle(this.buttonX, (int) this.point.y,
this.bounds = new Rectangle(
this.buttonX, this.point.getIntY(),
VolumeButtons.VOLUME_WIDTH.value,
VolumeButtons.VOLUME_HEIGHT.value);

Expand Down Expand Up @@ -75,14 +76,16 @@ public void update() {
@Override
public void render(Graphics g) {
g.drawImage(slider,
(int) this.point.x, (int) this.point.y,
this.point.getIntX(), this.point.getIntY(),
VolumeButtons.SLIDER_WIDTH.value,
VolumeButtons.VOLUME_HEIGHT.value, null);
VolumeButtons.VOLUME_HEIGHT.value,
null);

g.drawImage(this.image[this.mouseState.toDisplayIndex],
(int) (buttonX - sliderXOffset), (int) this.point.y,
(int) (buttonX - sliderXOffset), this.point.getIntY(),
VolumeButtons.VOLUME_WIDTH.value,
VolumeButtons.VOLUME_HEIGHT.value, null);
VolumeButtons.VOLUME_HEIGHT.value,
null);
}

}
47 changes: 47 additions & 0 deletions src/Game/gameBase/GameUnitPair.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,51 @@ public GameUnitPair div(float scale) {
return new GameUnitPair(this.x / scale, this.y / scale);
}

public void setX(float x) {
this.x = x;
}

public void setY(float y) {
this.y = y;
}

public float getX() {
return this.x;
}

public float getY() {
return this.y;
}

public int getIntX() {
return (int) this.x;
}

public int getIntY() {
return (int) this.y;
}

public void setW(float w) {
this.x = w;
}

public void setH(float h) {
this.y = h;
}

public float getW() {
return this.x;
}

public float getH() {
return this.y;
}

public int getIntW() {
return (int) this.x;
}

public int getIntH() {
return (int) this.y;
}
}