Skip to content

Commit c0fa25e

Browse files
committed
Adding moving cursor on options menu
1 parent a2d1c5b commit c0fa25e

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

bin/main/KeyHandler.class

250 Bytes
Binary file not shown.

bin/main/UI.class

212 Bytes
Binary file not shown.

src/main/KeyHandler.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,32 @@ public void optionState(int code) {
224224
if (code == KeyEvent.VK_ENTER) {
225225
enterPressed = true;
226226
}
227+
228+
int maxCommandNum = 0;
229+
230+
switch (gp.ui.subState) {
231+
case 0:
232+
maxCommandNum = 5;
233+
break;
234+
}
235+
236+
if (code == KeyEvent.VK_W) {
237+
gp.ui.commandNum--;
238+
gp.playSE(9);
239+
240+
if (gp.ui.commandNum < 0) {
241+
gp.ui.commandNum = maxCommandNum;
242+
}
243+
}
244+
245+
if (code == KeyEvent.VK_S) {
246+
gp.ui.commandNum++;
247+
gp.playSE(9);
248+
249+
if (gp.ui.commandNum > maxCommandNum) {
250+
gp.ui.commandNum = 0;
251+
}
252+
}
227253
}
228254

229255
@Override

src/main/UI.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,26 +513,44 @@ public void options_top(int frameX, int frameY) {
513513
textX = frameX + gp.tileSize;
514514
textY += gp.tileSize * 2;
515515
g2.drawString("Full Screen", textX, textY);
516+
if (commandNum == 0) {
517+
g2.drawString(">", textX - 25, textY);
518+
}
516519

517520
// MUSIC
518521
textY += gp.tileSize;
519522
g2.drawString("Music", textX, textY);
523+
if (commandNum == 1) {
524+
g2.drawString(">", textX - 25, textY);
525+
}
520526

521527
// SOUND EFFECT
522528
textY += gp.tileSize;
523529
g2.drawString("SE", textX, textY);
530+
if (commandNum == 2) {
531+
g2.drawString(">", textX - 25, textY);
532+
}
524533

525534
// CONTROL
526535
textY += gp.tileSize;
527536
g2.drawString("Control", textX, textY);
537+
if (commandNum == 3) {
538+
g2.drawString(">", textX - 25, textY);
539+
}
528540

529541
// END GAME
530542
textY += gp.tileSize;
531543
g2.drawString("End Game", textX, textY);
544+
if (commandNum == 4) {
545+
g2.drawString(">", textX - 25, textY);
546+
}
532547

533548
// BACK
534549
textY += gp.tileSize * 2;
535550
g2.drawString("Back", textX, textY);
551+
if (commandNum == 5) {
552+
g2.drawString(">", textX - 25, textY);
553+
}
536554
}
537555

538556
public int getItemIndexOnSlot() {

0 commit comments

Comments
 (0)