-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added the puase menu (mouse events has some problems
)
- Loading branch information
1 parent
c3dc771
commit 8b2ee74
Showing
6 changed files
with
198 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package UI; | ||
|
||
import java.awt.Rectangle; | ||
|
||
public class PauseButton { | ||
protected int x; | ||
protected int y; | ||
protected int width; | ||
protected int height; | ||
|
||
public int getX() { | ||
return x; | ||
} | ||
|
||
public void setX(int x) { | ||
this.x = x; | ||
} | ||
|
||
public int getY() { | ||
return y; | ||
} | ||
|
||
public void setY(int y) { | ||
this.y = y; | ||
} | ||
|
||
public int getWidth() { | ||
return width; | ||
} | ||
|
||
public void setWidth(int width) { | ||
this.width = width; | ||
} | ||
|
||
public int getHeight() { | ||
return height; | ||
} | ||
|
||
public void setHeight(int height) { | ||
this.height = height; | ||
} | ||
|
||
public Rectangle getBounds() { | ||
return bounds; | ||
} | ||
|
||
public void setBounds(Rectangle bounds) { | ||
this.bounds = bounds; | ||
} | ||
|
||
protected Rectangle bounds; | ||
|
||
public PauseButton(int x, int y, int width, int height){ | ||
this.x = x; | ||
this.y = y; | ||
this.width = width; | ||
this.height = height; | ||
createBounds(); | ||
} | ||
|
||
private void createBounds() { | ||
bounds = new Rectangle(x, y, width, height); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package UI; | ||
|
||
import java.awt.Graphics; | ||
import java.awt.image.BufferedImage; | ||
|
||
import Utils.Constants; | ||
import Utils.LoadSave; | ||
|
||
public class SoundButton extends PauseButton{ | ||
|
||
private BufferedImage[][] soundImages; | ||
private int rowIndex, colIndex; | ||
private boolean mouseOver; | ||
private boolean mousePressed; | ||
private boolean muted; | ||
|
||
public SoundButton(int x, int y, int width, int height) { | ||
super(x, y, width, height); | ||
loadSoundImages(); | ||
} | ||
|
||
private void loadSoundImages() { | ||
BufferedImage temp = LoadSave.getImage(LoadSave.SOUND_BUTTONS); | ||
soundImages = new BufferedImage[2][3]; | ||
|
||
for(int i=0; i<soundImages.length; i++){ | ||
for(int j=0; j<soundImages[i].length; j++){ | ||
soundImages[i][j] = temp.getSubimage(j * Constants.Ui.PauseButtons.SOUND_SIZE_DEFAULT, i * Constants.Ui.PauseButtons.SOUND_SIZE_DEFAULT, Constants.Ui.PauseButtons.SOUND_SIZE_DEFAULT, Constants.Ui.PauseButtons.SOUND_SIZE_DEFAULT); | ||
} | ||
} | ||
} | ||
|
||
public boolean isMouseOver() { | ||
return mouseOver; | ||
} | ||
|
||
public void setMouseOver(boolean mouseOver) { | ||
this.mouseOver = mouseOver; | ||
} | ||
|
||
public boolean isMousePressed() { | ||
return mousePressed; | ||
} | ||
|
||
public void setMousePressed(boolean mousePressed) { | ||
this.mousePressed = mousePressed; | ||
} | ||
|
||
public boolean isMuted() { | ||
return muted; | ||
} | ||
|
||
public void setMuted(boolean muted) { | ||
this.muted = muted; | ||
} | ||
|
||
public void update(){ | ||
if(muted) rowIndex = 1; | ||
else rowIndex = 0; | ||
|
||
colIndex = 0; | ||
if(mouseOver) colIndex = 1; | ||
if(mousePressed) colIndex = 2; | ||
} | ||
|
||
public void resetBools(){ | ||
mouseOver = false; | ||
mousePressed = false; | ||
} | ||
|
||
public void render(Graphics g){ | ||
g.drawImage(soundImages[rowIndex][colIndex], x, y, width, height, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters