-
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.
feat(AddCapture): AddScreenshot function
- update Game to be a KeyListener - add Render save buffer function - update InputHandler fix #10
- Loading branch information
Showing
5 changed files
with
77 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import java.awt.Color; | ||
import java.awt.Font; | ||
import java.awt.event.KeyEvent; | ||
import java.awt.event.KeyListener; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
|
@@ -23,7 +24,7 @@ | |
* @author Frédéric Delorme<[email protected]> | ||
* @since 0.0.1 | ||
*/ | ||
public class Game { | ||
public class Game implements KeyListener { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(Game.class); | ||
|
||
|
@@ -53,8 +54,6 @@ public class Game { | |
* the mandatory default constructor | ||
*/ | ||
public Game() { | ||
renderer = new Render(320, 200); | ||
window = new Window("", 320, 200); | ||
} | ||
|
||
/** | ||
|
@@ -81,6 +80,7 @@ public void initialize(String[] argv) throws UnknownArgumentException { | |
renderer = new Render(this.width, this.height); | ||
window = new Window(this.title, (int) (this.width * this.scale), (int) (this.height * this.scale)); | ||
inputHandler = new InputHandler(window); | ||
inputHandler.addKeyListener(this); | ||
} | ||
|
||
public void loadDefaultValues() { | ||
|
@@ -204,7 +204,7 @@ private void loop() { | |
*/ | ||
private void input() { | ||
if (inputHandler.getKey(KeyEvent.VK_ESCAPE)) { | ||
this.exit = true; | ||
|
||
} | ||
} | ||
|
||
|
@@ -280,4 +280,30 @@ public static void main(String[] argc) { | |
logger.error("Unable to run the game", e); | ||
} | ||
} | ||
|
||
@Override | ||
public void keyTyped(KeyEvent e) { | ||
// nothing to do now | ||
} | ||
|
||
@Override | ||
public void keyPressed(KeyEvent e) { | ||
// nothing to do now | ||
|
||
} | ||
|
||
@Override | ||
public void keyReleased(KeyEvent e) { | ||
switch (e.getKeyCode()) { | ||
case KeyEvent.VK_F11: | ||
renderer.saveScreenshot(); | ||
break; | ||
case KeyEvent.VK_ESCAPE: | ||
this.exit = true; | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
} | ||
} |
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
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