@@ -0,0 +1,2442 @@
+package jelly;%0A%0Aimport java.awt.Graphics;%0Aimport java.awt.Graphics2D;%0Aimport java.awt.image.BufferedImage;%0Aimport java.util.ArrayList;%0Aimport java.util.Observable;%0Aimport java.util.Observer;%0Aimport javax.swing.JFrame;%0A%0Aimport static jelly.Global.*;%0A%0A/**%0A * Displays a graphical view of the game%0A * @author Almas%0A * @version 0.8%0A */%0A@SuppressWarnings(%22serial%22)%0Apublic class GameView extends JFrame implements Observer%0A%7B%0A  private ArrayList%3CRenderable%3E renderedObjects = new ArrayList%3CRenderable%3E();%09//all objects that need to be rendered%0A%09private int xOrigin = 0;%09//origin relative to which objects need to be drawn%0A%09%0A%09public GameView()%0A%09%7B%09%0A%09%09setSize(W, H); // Size of window%0A%09%09setTitle(APP_TITLE);%0A%09%09setLocationRelativeTo(null);%0A%09%09setVisible(true);%0A%09%09setDefaultCloseOperation(EXIT_ON_CLOSE);%0A%09%7D%0A%0A%09/**%0A%09 * Code called to create the current state of the game%0A%09 * @param g - Graphics context to use%0A%09 */%0A%09public void createPicture(Graphics2D g)%0A%09%7B%0A%09%09g.drawImage(GameResources.IMG_BACKGROUND, 0, 0, this);%09//CHANGE TO A GAME OBJECT%0A%09%09%0A%09%09for (Renderable obj : renderedObjects)%0A%09%09%09render(g, obj);%0A%09%7D%0A%09%0A%09/**%0A%09 * Renders (but doesn't show on the screen, just creates)%0A%09 * a renderable object%0A%09 * @param g - graphics context on which to render%0A%09 * @param obj - the object%0A%09 */%0A%09public void render(Graphics2D g, Renderable obj) %7B%0A%09%09g.drawImage(obj.getImage(), obj.getX() - xOrigin, obj.getY(), this);%0A%09%7D%0A%09%0A%09/**%0A%09 * Called from the model when its state has changed%0A%09 */%0A%09@Override%0A%09public void update(Observable aModel, Object arg)%0A%09%7B%0A%09%09GameModel model = (GameModel) aModel;%0A%09%09renderedObjects = model.getRenderedObjects();%0A%09%09xOrigin = renderedObjects.get(0).getX();%09//we always place a dummy game object origin as the 1st element%0A%09%09%0A%09%09repaint();%0A%09%7D%0A%09%0A%09/**%0A%09 * Called by repaint%0A%09 */%0A%09@Override%0A%09public void update(Graphics g) %7B%0A%09%09drawPicture((Graphics2D) g);%0A%09%7D%0A%0A%09/**%0A%09 * When first shown or damaged%0A%09 */%0A%09@Override%0A%09public void paint(Graphics g) %7B%0A%09%09drawPicture((Graphics2D) g);%0A%09%7D%0A%0A%09private BufferedImage theAI; // Alternate Image%0A%09private Graphics2D theAG; %09 // Alternate Graphics%0A%0A%09/**%0A%09 * Double buffer drawing to avoid flicker%0A%09 * @param g - graphics context%0A%09 */%0A%09public void drawPicture(Graphics2D g)%0A%09%7B%09%0A%09%09if (theAG == null)%0A%09%09%7B%0A%09%09%09theAI = (BufferedImage) createImage(W, H);%0A%09%09%09theAG = theAI.createGraphics();%0A%09%09%7D%0A%09%09%0A%09%09createPicture(theAG); %09%09%09// Create new picture%0A%0A%09%09g.drawImage(theAI, 0, 0, this); // Display on screen previous picture%0A%09%7D%0A%7D%0A

Create GameView.java