title: tick and render aren't working for other class's what do I do
body: <p>When I try to <code>tick()</code> and <code>render()</code> my other class's in my game class doesn't work. </p>
  
  <pre class="lang-none prettyprint-override"><code>Exception in thread "Thread-2" java.lang.NullPointerException 
      at ca.patrick.main.window.Game.render(Game.java:87) 
      at ca.patrick.main.window.Game.run(Game.java:52) 
      at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>and sometimes:</p>
  
  <pre class="lang-none prettyprint-override"><code>Exception in thread "Thread-2" java.lang.NullPointerException 
      at ca.patrick.main.window.Game.tick(Game.java:71) 
      at ca.patrick.main.window.Game.run(Game.java:54) 
      at java.lang.Thread.run(Unknown Source) 
  </code></pre>
  
  <p>So here's the code for my game (I replaced my name with "name") and 
  as you can see I'm a beginner at Java so my code is probably sub-standard, but here is my code: </p>
  
  <pre><code>package ca.name.main.window;
  
  import java.awt.Canvas;
  import java.awt.Color;
  import java.awt.Graphics;
  import java.awt.image.BufferStrategy;
  import java.util.LinkedList;
  
  import ca.name.main.framework.GameObject;
  import ca.name.main.framework.Id;
  import ca.name.main.objects.Enemy1;
  
  public class Game extends Canvas implements Runnable{
  
      private static final long serialVersionUID = -4319386659730073928L;
  
      public int WIDTH, HEIGHT;
      public boolean running = false;
      private Thread thread;
  
      private LinkedList&lt;GameObject&gt; object;
      private Enemy1 enemy1;
  
      public synchronized void start(){
          if(running)
              return;
  
          running = true;
          thread = new Thread(this);
          thread.start();
      }
  </code></pre>
  
  <p>Game loop:</p>
  
  <pre><code>    public void run() {
          init();
          this.requestFocus();
          long lastTime = System.nanoTime();
          double amountOfTicks = 60.0;
          double ns = 1000000000 / amountOfTicks;
          double delta = 0;
          long timer = System.currentTimeMillis();
          int updates = 0;
          int frames = 0;
          while (running) {
              long now = System.nanoTime();
              delta += (now - lastTime) / ns;
              lastTime = now;
              while (delta &gt;= 1) {
                  tick();
                  updates++;
                  delta--;
              }
              render();
              frames++;
  
              if (System.currentTimeMillis() - timer &gt; 1000) {
                  timer += 1000;
                  System.out.println("FPS: " + frames + " TICKS: " + updates);
                  frames = 0;
                  updates = 0;
              }
          }
      }
  
      private void init() {
          HEIGHT = getHeight();
          WIDTH = getWidth();
  
          Enemy1 enemy1 = new Enemy1(0, 0, Id.Enemy);
      }
  </code></pre>
  
  <p>tick:</p>
  
  <pre><code>    private void tick() {
          enemy1.tick(object);
      }
  </code></pre>
  
  <p>render:</p>
  
  <pre><code>    private void render() {
          BufferStrategy bs = this.getBufferStrategy();
          if(bs == null){
              this.createBufferStrategy(3);
              return;
          }
  
          Graphics g = bs.getDrawGraphics();
  
          g.setColor(Color.cyan);
          g.fillRect(0, 0, getHeight() * 2, getWidth() * 2);
  
          enemy1.render(g);
  
          bs.show();
          g.dispose();
      }
  
      public Game(){
  
      }
  
      public static void main(String args[]){
          new Window(600, 800, "Log Platformer prototype", new Game());
      }
  }
  </code></pre>