changeset 4:e0e8fd08331e

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 28 Jan 2011 17:37:01 +0200
parents b8fd19e2d879
children 4890020bf856
files Ristipolku.java
diffstat 1 files changed, 24 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Ristipolku.java	Fri Jan 28 16:59:36 2011 +0200
+++ b/Ristipolku.java	Fri Jan 28 17:37:01 2011 +0200
@@ -2,7 +2,7 @@
  * Ristipolku
  * (C) Copyright 2011 Matti 'ccr' Hämäläinen <ccr@tnsp.org>
  *
- * Ohjelmointiprojekti Java-kurssille .
+ * Ohjelmointiprojekti 2010-2011 Java-kurssille T740306.
  */
 import java.awt.*;
 import java.awt.geom.*;
@@ -52,7 +52,10 @@
         for (int x = 0; x < boardSize; x++)
         if (board[x][y] != null)
         {
-            board[x][y].paint(g, sx + (x * scale), sy + (y * scale), scale - scale/10);
+            board[x][y].paint(g,
+                sx + (x * scale),
+                sy + (y * scale),
+                scale - scale / 10);
         }
     }
    
@@ -92,14 +95,28 @@
 }
 
 
-public class gfxtest extends JApplet
-                     implements KeyListener
+public class Ristipolku extends JApplet
+                        implements KeyListener
 {
-    GameBoard lauta;
+    GameBoard lauta = null;
+    BufferedImage lautaBG = null;
 
     public void init()
     {
         getContentPane().setBackground(Color.white);
+
+        try
+        {
+            lautaBG = ImageIO.read(new File("tausta.png"));
+        }
+        catch (IOException e)
+        {
+            JOptionPane.showMessageDialog(null,
+                "Could not load background image.",
+                "Initialization error",
+                JOptionPane.ERROR_MESSAGE);
+        }
+        
         lauta = new GameBoard();
         addKeyListener(this);
     }
@@ -107,12 +124,13 @@
     public void paint(Graphics g)
     {
         Graphics2D g2 = (Graphics2D) g;
+
         g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                             RenderingHints.VALUE_ANTIALIAS_ON);
+
         lauta.paint(g2, 15, 15, 60);
     }
 
-
     public void keyPressed(KeyEvent e)
     {
     }