Created
June 13, 2016 16:53
-
-
Save anonymous/7569e4cbf462149b82a11dd4904b0f3e to your computer and use it in GitHub Desktop.
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
package dodgit; | |
import dodgit.input.Controller; | |
import dodgit.input.KeyInput; | |
import dodgit.objects.Enemy; | |
import dodgit.objects.Player; | |
import java.awt.Graphics; | |
import java.awt.Graphics2D; | |
import java.awt.Image; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import javax.swing.ImageIcon; | |
import javax.swing.JPanel; | |
import javax.swing.Timer; | |
public class Game extends JPanel implements ActionListener { | |
private static long serialVersionUID = 1L; | |
private String background = "/Images/background.png"; | |
Timer gamelooptimer; | |
Player p; | |
Controller c; | |
public Game() { | |
setFocusable(true); | |
gamelooptimer = new Timer(10, this); | |
gamelooptimer.start(); | |
p = new Player(50, 400); | |
c = new Controller(); | |
addKeyListener(new KeyInput(p)); | |
} | |
public void paint(Graphics g) { | |
super.paint(g); | |
Graphics2D g2d = (Graphics2D) g; | |
g2d.drawImage(getBackgroundImage(), 0, 0, this); | |
p.draw(g2d); | |
c.draw(g2d); | |
} | |
public void actionPerformed(ActionEvent ee) { | |
repaint(); | |
p.update(); | |
c.update(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment