Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Where to start to make a 2d game?

  1. #1
    Member DusteroftheCentury's Avatar
    Join Date
    Jan 2012
    Location
    Northern California
    Posts
    42
    My Mood
    Fine
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Where to start to make a 2d game?

    Hello Guys,

    I want to develop a simple 2d action/exploration game in Java. I am thinking the theme will be mining. Where to start? What API should I learn? How much much work must really go into this, is it something that can I can do being a beginner/intermediate"ish" programmer? Please help, It will be much appreciated.
    Win is: That epic moment when you make a reference to coding in Class, and everyone stares at you like you are crazy.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Where to start to make a 2d game?

    How familiar with Java are you already? Your first step is to familiarize yourself with the basics- program flow, methods, Objects, classes, instantiation, etc. Work through the basic tutorials, carefully, until you can write a game played on the command line.

    From there, learn about Swing and painting in Java2D. Draw a simple scene on a JFrame- some rectangles and some circles.

    Then worry about animation- make the rectangles and circles move around. Start working on things like collision detection and basic physics.

    Then figure out user input, through the mouse or keyboard.

    If you get stuck on any of these steps, create an SSCCE that demonstrates exactly what's going on, and we'll go from there. Much luck.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Member
    Join Date
    Aug 2009
    Posts
    53
    Thanks
    2
    Thanked 3 Times in 2 Posts

    Default Re: Where to start to make a 2d game?

    There is this little framework that can be used to play around and have fun. The overhead is some the simplest in any game framework I have seen.

    JGame: a Java/Flash game engine for 2D games

    This is a shortcut, and will as such not be nearly as educational as above mentioned, but will make you put stuff together fast. Coding should also be fun, even while we are beginners

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Where to start to make a 2d game?

    I can agree that coding should be fun, but you should know the basics of what's going on before you devote yourself to any one framework. There are tons of different frameworks out there, and you have to know the basics before you can really choose between them. It's like learning how to drive before picking out a sports car.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Member DusteroftheCentury's Avatar
    Join Date
    Jan 2012
    Location
    Northern California
    Posts
    42
    My Mood
    Fine
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: Where to start to make a 2d game?

    Thanks so much! That is SO helpful. Especially the checklist. I know most of the basics, I will learn the things you mentioned I am not familiar with. As for Swing, I am already pretty sufficient in it, being able to make Frames, Panels, Buttons, Labels, TextBoxes etc. Ill also try to learn Java 2d, It looks pretty simple. Ill look into sprites, and collision detection/physics etc. I already understand some basic mouse Listeners, but my game will probably be mostly keyboard controlled, so I definitely will learn Keyboard input. And if I cant get these things to work together, l'll create an SSCCE.

    Thanks you SOOOO much, a checklist like what you provided was exactly what I needed.

    -Duster
    Win is: That epic moment when you make a reference to coding in Class, and everyone stares at you like you are crazy.

  6. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Where to start to make a 2d game?

    No problem. And for what it's worth, I pretty much follow that guideline every time I create a new game from scratch. My workflow goes something like this:

    1- Get a JFrame / JApplet running (I actually use a JPanel and put it in both).
    2- Use Java2D to paint a single circle in the middle of that JPanel. How do I want to display things? Using a grid? By set coordinates?
    3- Add a KeyListener and logic to get the circle moving based on input.
    4- Add collision detection- what happens when the circle hits the edge of a screen? What happens when I add a square to it?
    5- Add a Timer to handle the game loop. For more advanced stuff, some threading might be required, but a Timer should work for most simple games.

    Once you have those things implemented, it's a pretty natural progression to add things to your game. I wouldn't worry too much about art until you have a functional game that contains dummy art.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    Member DusteroftheCentury's Avatar
    Join Date
    Jan 2012
    Location
    Northern California
    Posts
    42
    My Mood
    Fine
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: Where to start to make a 2d game?

    Thanks for all the help

    I am working on a text based game like you said.

    I have a few questions though:

    How do I set a boolean to true if something happens but have the default be false?

    How Do I add 1 to an int everytime an if statement is activated? (ie. If it occurs set it to 1, if twice set it to 2 etc)

    Thanks for all your help,

    -Duster


    Edit: Figured out both questions by myself.
    Last edited by DusteroftheCentury; February 12th, 2012 at 01:47 PM.
    Win is: That epic moment when you make a reference to coding in Class, and everyone stares at you like you are crazy.

Similar Threads

  1. How to make a start/menu screen?
    By skerridge in forum AWT / Java Swing
    Replies: 1
    Last Post: December 21st, 2011, 12:38 AM
  2. Trying to start a game when 'Enter' is pressed.
    By Shaybay92 in forum AWT / Java Swing
    Replies: 6
    Last Post: September 27th, 2011, 07:48 AM
  3. trying to make game
    By knoxy5467 in forum Java Theory & Questions
    Replies: 3
    Last Post: June 20th, 2011, 09:26 AM
  4. Read in file and store in 2D array start of The Game of Life
    By shipwills in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 2nd, 2011, 09:52 AM
  5. Trying to make Jeopardy Game
    By wbroman in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 8th, 2010, 06:40 AM