Let’s Make a Video Game! Part 1

Now let’s add them to the canvas:



   public void runGame() throws InterruptedException {

       isRunning = true;


       JFrame frame = configureWindow();

       Canvas canvas = configureView(frame);

       List<Entity> entities = createEntities();






       List<EntityView> views = new ArrayList<>(entities.size());


       for (Entity model : entities) {

           views.add(new AlienView(model));



       BufferStrategy strategy = canvas.getBufferStrategy();


       while (isRunning) {

           Graphics2D g = (Graphics2D) strategy.getDrawGraphics();


           g.fillRect(0, 0, 800, 600);


           for (EntityView view : views) {









We create a graphic “view” for each model and then we paint them all to the screen in the loop every 1000 milliseconds.

And there we see our alien place holders all set up.


Next time, we’ll add Timing, Inputs, player action, game logic and animation!


The source for this can be found at:



Author: Bruce Brown

Share This Post On

Submit a Comment

Your email address will not be published. Required fields are marked *