How to Make a Side Scrolling Game in Java

Written by michael dominick
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Make a Side Scrolling Game in Java
Java can be used to make two-dimensional side scrolling games. (Java hot and black image by Pix by Marti from Fotolia.com)

Generally, when people talk about Java development, they tend to focus on enterprise development. Java, however, can be used for a number of applications. One of these applications is game development. If you are interested in programming a retro style two-dimensional side scrolling game that can run on Linux, Mac OS X or Windows, Java is a great tool.

Skill level:
Easy

Other People Are Reading

Things you need

  • JDK
  • IDE
  • Image editing program

Show MoreHide

Instructions

  1. 1

    Download and install the Java SDK. You cannot do Java development without having the SDK on your computer. Versions of the SDK are available for Linux, Mac OS X and Windows, all of which can be freely downloaded from the Java developer site. Mac OS X users should already have JDK installed on their systems, but they can download a different version of it if they so chose.

  2. 2

    Download and install an integrated development environment; IDEs are tools that allow you to edit code and provide useful project organisation, debugging and code completion features. You can legally download and use a number of free IDEs; common choices for Java development include NetBeans, Eclipse and IntelliJ Idea 9 Community Edition.

  3. 3

    Open your IDE of choice and select "New Project" from the "File" menu. Then click on "New Java Desktop Application." The IDE asks you where you want to save your project and what you want to call it. It then generates some code for you, including the main class for your application, which has the same name as the application itself and cannot be renamed.

  4. 4

    Write the class for your player character, then instantiate an instance of that class. This is a basic example of a player class: Class Player { String name; int health; }. In the example, all instances of the Player class will have a string value for their name and an integer value for their health, but you can and should customise that code for your specific game. Classes similar to the example Player class can be written for enemy characters and any other nonplayer character you plan to include in your game.

  5. 5

    Create the images for your game; in game development, it is usually best to use PNGs for player and enemy character images because of that format's inherent transparency. You can use any tool, such as the free and open-source Inkscape, the commercial Adobe Illustrator and even MS Paint. Since everything is a class in Java, the art assets for your game will be linked to the class programmatically, meaning that there is no drag-and-drop way to get images on the screen.

  6. 6

    Program the functions of your classes. Examples of functions might be what your player character does when you press a certain key or what happens to an enemy character when struck by the player; like everything else, functions are part of the class.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.