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 4 of 4

Thread: how to set up level class in 2d java game

  1. #1
    Member
    Join Date
    Oct 2012
    Posts
    133
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default how to set up level class in 2d java game

    my end goal is to make 4 different level's. kind of like 2d mario game. I read some where that there are two ways to make a level.

    1st is to use a background image. and when user hit right key, than you should move the background to left. that way it will look like player is moving right.

    2nd way is to make a 2d string array. and in that array there will be alot of g, s, p,e. so where u put g, put load a image of ground. where u put s, upload a sky image, and so on...

    try to expain which way is better. for ex i would think 2nd way would take alot longer. where 1st way gound be easier to set up. but with 2nd way u can do alot more stuff...
    --------------------------------------------------------------------------------------------------------------------------------------------


    also how would i set up the class for 4 different level's..

    so i would have
    Main.java
    Player.java
    Level1.java
    Level2.java
    Level3.java
    Level4.java


  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: how to set up level class in 2d java game

    There are a ton of ways to make a game level, not just those two methods. What method you choose really depends on you, your game, your preferences, and your context. So it's really up to you how to proceed.
    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
    Oct 2012
    Posts
    133
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: how to set up level class in 2d java game

    ...and do u mind let me in on those methods?

  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: how to set up level class in 2d java game

    This topic is much too involved to really cover in a single forum post; there are entire books devoted to this subject.

    You could do it either of the ways you propose. Or you could use polygons. Or a quad tree. Or a combination of several techniques. Which method you choose is really up to you.
    Last edited by KevinWorkman; October 25th, 2012 at 06:19 PM.
    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. The Following User Says Thank You to KevinWorkman For This Useful Post:

    hwoarang69 (October 25th, 2012)

Similar Threads

  1. Java Class : How do I set up a toString method for arrays?
    By red7 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: May 11th, 2012, 05:47 PM
  2. Set Class
    By jerryg in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 18th, 2012, 06:27 AM
  3. Hangman game for JAVA Beginning class
    By shahravi88 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 12th, 2011, 03:15 PM
  4. [SOLVED] Using values set in one class in another
    By sp11k3t3ht3rd in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 23rd, 2011, 10:34 PM
  5. Cannot set class fields using textInput
    By javascrub in forum What's Wrong With My Code?
    Replies: 0
    Last Post: August 26th, 2010, 04:04 AM