Java Programming: Let's Build a Game #1



Source Code and Courses ► https://www.codingmadesimple.com/courses/

Part 1 of a series on the very basic fundamentals of Java game design. If you have any questions then be sure to leave a comment or contact me on twitter; realtutsgml. If you learned something then be sure to leave a like, comment, and favorite.

Have you ever wanted to create games? Have you ever gotten fed up with it being to difficult? Well now is the time to thank me and possibly subscribe because you have just found the channel for you! Game Maker Tutorials, Java Game Programming, Unity3D Tutorials, Batch, C++ and much much more! This is the channel for you, the one stop shop for an exploration of your hidden talent as a game developer. Unleash your potential and go wild with imagination when you finally figure out how to make any game you want!

Wave Playlist- https://www.youtube.com/playlist?list=PLWms45O3n–7TtyMACZqmEgT0nfkOrfLd

Visit CodingMadeSimple for more exclusive tutorials and get the help you need to succeed as your very own indie game developer!

Home

Follow me on twitter for exclusive content and interaction with me!

Follow me on Google+ to keep updated with all of my tutorials
http://www.google.com/+RealTutsGML

Game Maker Studio: Programming
Game Maker Studio: Tutorial
Java Programming
Game Programming
Game Tutorial
Programming Tutorial

25 thoughts on “Java Programming: Let's Build a Game #1

  1. uncle zack error in render method when i use bufferStrategy. Plz slove it uncle

    Exception in thread "Thread-0" java.lang.IllegalStateException: Component must have a valid peer

    at java.desktop/java.awt.Component$FlipBufferStrategy.createBuffers(Component.java:4087)

    at java.desktop/java.awt.Component$FlipBufferStrategy.<init>(Component.java:4061)

    at java.desktop/java.awt.Component$FlipSubRegionBufferStrategy.<init>(Component.java:4593)

    at java.desktop/java.awt.Component.createBufferStrategy(Component.java:3924)

    at java.desktop/java.awt.Canvas.createBufferStrategy(Canvas.java:195)

    at java.desktop/java.awt.Component.createBufferStrategy(Component.java:3848)

    at java.desktop/java.awt.Canvas.createBufferStrategy(Canvas.java:170)

    at hide.Game.render(Game.java:97)

    at hide.Game.run(Game.java:80)

    at java.base/java.lang.Thread.run(Thread.java:831)

  2. run method code:

    public void run() {

    long lastTime = System.nanoTime();

    double amountOfTicks = 60.0;

    double ns = 1000000000 / amountOfTicks;

    double delta = 0;

    long timer = System.currentTimeMillis();

    int frames = 0;

    while(running) {

    long now = System.nanoTime();

    delta += (now – lastTime) / ns;

    lastTime = now;

    while(delta >= 1) {

    tick();

    delta–;

    }

    if(running)

    render();

    frames++;

    if(System.currentTimeMillis() – timer > 1000) {

    timer += 1000;

    System.out.println("FPS: " + frames);

    frames = 0;

    }

    }

    stop();

    }

  3. 14:45
    For everyone who don't really want to lose their mind while typing this, here it is, ready to copy paste:

    public void run() {

    long lastTime = System.nanoTime();

    double amountOfTicks = 60.0;

    double ns = 1000000000 / amountOfTicks;

    double delta = 0;

    long timer = System.currentTimeMillis();

    int frames = 0;

    while (running) {

    long now = System.nanoTime();

    delta += (now – lastTime) / ns;

    lastTime = now;

    while (delta >= 1) {

    tick();

    delta–;

    }

    if (running) {

    render();

    }

    frames++;

    if (System.currentTimeMillis() – timer > 1000) {

    timer += 1000;

    System.out.println("FPS: " + frames);

    frames = 0;

    }

    }

    stop();

    }

  4. This is killing me – what actually calls the Game.run() method? By doing a stack trace I can tell that it's being called by Thread.run() so I suppose some inheritance stuff is going on there, but that's where the trail runs cold for me.

    Is it something like Game.start() calls Thread.start() which somehow calls Thread.run() which is inherited into Game.run()?

Leave a Reply

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