Java

Java 2D Game Programming Platformer Tutorial – Part 1 – The Game State Manager



IMPORTANT INFO:
This is an extremely old tutorial, back when I was a noob at game programming. One of the most destructive parts of this crap code is the multi-threaded key input. Swing puts all KeyEvent firings in a separate thread, so I implore everyone to look at video 9 (final – Artifact game) of this tutorial to check out the Keys class in the source code so as to put all game logic on a single thread.

This is a new tutorial series.
The game is a tile based, side-scrolling…

Similar Posts

30 thoughts on “Java 2D Game Programming Platformer Tutorial – Part 1 – The Game State Manager
  1. I Really need help u probally really busy but I keep getting these errors
    java.lang.IllegalArgumentException: input == null!

    at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1356)

    at TileMap.Backround.<init>(Backround.java:24)

    at GameState.MenuState.<init>(MenuState.java:28)

    at GameState.GameStateManager.<init>(GameStateManager.java:18)

    at Main.GamePanel.init(GamePanel.java:62)

    at Main.GamePanel.run(GamePanel.java:70)

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

    Exception in thread "Thread-0" java.lang.Error: Unresolved compilation problems:

    length cannot be resolved or is not a field

    The type of the expression must be an array type but it resolved to Object

    at GameState.MenuState.draw(MenuState.java:65)

    at GameState.GameStateManager.draw(GameStateManager.java:33)

    at Main.GamePanel.draw(GamePanel.java:108)

    at Main.GamePanel.run(GamePanel.java:82)

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

  2. java.lang.IllegalArgumentException: input == null!

    at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1356)

    at TitleMap.Background.<init>(Background.java:38)

    at GameState.MenuState.<init>(MenuState.java:35)

    at GameState.GameStateManager.<init>(GameStateManager.java:21)

    at Main.GamePanel.init(GamePanel.java:61)

    at Main.GamePanel.run(GamePanel.java:67)

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

    I am getting this error

  3. Very cool, and at the time you typed g = (Graphics2D) g, I just thought, what the fuck… but kept coding along and at the end laughed very much hahaha.
    Just forty minutes and we got a cool menu working. Nice!

Leave a Reply

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