# HG changeset patch # User Matti Hamalainen # Date 1296229021 -7200 # Node ID e0e8fd08331e44c773c0202f439c8f1b8453f339 # Parent b8fd19e2d87989308e7cc1e2653b54dd1e21dbae Cleanups. diff -r b8fd19e2d879 -r e0e8fd08331e Ristipolku.java --- 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 * - * 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) { }