diff options
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/fourisland/frigidearth/Main.java | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/com/fourisland/frigidearth/Main.java b/src/com/fourisland/frigidearth/Main.java index 40a10f7..2b3f5ee 100644 --- a/src/com/fourisland/frigidearth/Main.java +++ b/src/com/fourisland/frigidearth/Main.java | |||
@@ -26,7 +26,7 @@ import javax.swing.JFrame; | |||
26 | * | 26 | * |
27 | * @author hatkirby | 27 | * @author hatkirby |
28 | */ | 28 | */ |
29 | public class Main | 29 | public class Main extends Canvas |
30 | { | 30 | { |
31 | public static final int GAME_WIDTH = 640; | 31 | public static final int GAME_WIDTH = 640; |
32 | public static final int GAME_HEIGHT = 480; | 32 | public static final int GAME_HEIGHT = 480; |
@@ -43,7 +43,7 @@ public class Main | |||
43 | 43 | ||
44 | public static void main(String[] args) | 44 | public static void main(String[] args) |
45 | { | 45 | { |
46 | gameCanvas = new Canvas(); | 46 | gameCanvas = new Main(); |
47 | 47 | ||
48 | mainWindow = new JFrame(); | 48 | mainWindow = new JFrame(); |
49 | mainWindow.setTitle("Frigid Earth"); | 49 | mainWindow.setTitle("Frigid Earth"); |
@@ -61,6 +61,7 @@ public class Main | |||
61 | public void keyPressed(KeyEvent ke) | 61 | public void keyPressed(KeyEvent ke) |
62 | { | 62 | { |
63 | inputables.peek().processInput(ke); | 63 | inputables.peek().processInput(ke); |
64 | render(gameCanvas); | ||
64 | } | 65 | } |
65 | 66 | ||
66 | @Override | 67 | @Override |
@@ -75,16 +76,6 @@ public class Main | |||
75 | gameCanvas.createBufferStrategy(2); | 76 | gameCanvas.createBufferStrategy(2); |
76 | 77 | ||
77 | setGameState(new MapViewGameState()); | 78 | setGameState(new MapViewGameState()); |
78 | |||
79 | long waitTime = System.nanoTime() + (1000000*FPS); | ||
80 | for (;;) | ||
81 | { | ||
82 | if (System.nanoTime() > waitTime) | ||
83 | { | ||
84 | render(gameCanvas); | ||
85 | waitTime = System.nanoTime() + (1000000*FPS); | ||
86 | } | ||
87 | } | ||
88 | } | 79 | } |
89 | 80 | ||
90 | public static void setGameState(GameState m_gameState) | 81 | public static void setGameState(GameState m_gameState) |
@@ -95,6 +86,8 @@ public class Main | |||
95 | gameState = m_gameState; | 86 | gameState = m_gameState; |
96 | renderables.add(gameState); | 87 | renderables.add(gameState); |
97 | inputables.push(gameState); | 88 | inputables.push(gameState); |
89 | |||
90 | render(gameCanvas); | ||
98 | } | 91 | } |
99 | 92 | ||
100 | public static void addRenderable(Renderable renderable) | 93 | public static void addRenderable(Renderable renderable) |
@@ -158,4 +151,11 @@ public class Main | |||
158 | 151 | ||
159 | Toolkit.getDefaultToolkit().sync(); | 152 | Toolkit.getDefaultToolkit().sync(); |
160 | } | 153 | } |
154 | |||
155 | @Override | ||
156 | public void paint(Graphics grphcs) | ||
157 | { | ||
158 | render(this); | ||
159 | } | ||
160 | |||
161 | } | 161 | } |