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

Thread: How do I create a level using different colours in a picture?

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    10
    My Mood
    Aggressive
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question How do I create a level using different colours in a picture?

    I recently watched someone make a game, and they made a system to make a certain level on a plat-former by using a picture.
    Basically, I have 6 pictures, and I want to draw them on the screen to make a level, by using the info from an image. How can I do this?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: How do I create a level using different colours in a picture?

    What do you mean by a "level"?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    10
    My Mood
    Aggressive
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: How do I create a level using different colours in a picture?

    Quote Originally Posted by Norm View Post
    What do you mean by a "level"?
    Well, what I mean is that in Mario, there is a set level with all the enemies and platforms and what-not, and I just want to make a system to create one level for my game by just making a photo, unless there is a way that is just as easy once it is set up.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: How do I create a level using different colours in a picture?

    Can you explain what you mean by a level? Is it a number, like floors in a building? Level 1 is the first floor, level 2 is the second, etc

    What would "creating a level" mean? Would that be generating a random number say from 1 to 10?

    Or would it be level of difficulty: level 1 is easy, level 10 is very hard.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Dec 2013
    Posts
    10
    My Mood
    Aggressive
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: How do I create a level using different colours in a picture?

    Quote Originally Posted by Norm View Post
    Quote Originally Posted by LukeR View Post
    Well, what I mean is that in Mario, there is a set level with all the enemies and platforms and what-not, and I just want to make a system to create one level for my game by just making a photo, unless there is a way that is just as easy once it is set up.
    Can you explain what you mean by a level? Is it a number, like floors in a building? Level 1 is the first floor, level 2 is the second, etcetera.

    What would "creating a level" mean? Would that be generating a random number say from 1 to 10?

    Or would it be level of difficulty: level 1 is easy, level 10 is very hard.
    Well, look at a platform game. There are platforms, spikes, enemies etc. And I want to make each level by creating a picture with different colours for each pixel, and the RGB value the pixel represents will make a certain thing in the game (For Example, in the image for the first map/level, I put a red pixel in the top corner. In the game, it reads the file, and puts a spike on the screen relative to the position in the picture.

    Summary of my question: I want to be able to simply draw a new level, add a few lines of code and voila, I can enter that room or 'level'

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: How do I create a level using different colours in a picture?

    I want to be able to simply draw a new ...
    Are you talking about custom drawings?
    See the tutorial about how to do custom paintings: Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Dec 2013
    Posts
    10
    My Mood
    Aggressive
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: How do I create a level using different colours in a picture?

    Are you even *** listening to me? I want to create a drawing like this: (I made the image 10x bigger for you to see it)
    level_example.jpg
    And it looks at the file, for every red pixel (the RGB value for red, (255,0,0)) it prints a certain picture to the screen in the same place relative to the picture, and for every orange pixel it does the same with some death-inflicting spikes
    Attached Images Attached Images
    Last edited by Norm; December 27th, 2013 at 07:05 AM. Reason: Removed language

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: How do I create a level using different colours in a picture?

    Did you look at the link for custom painting?
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Dec 2013
    Posts
    10
    My Mood
    Aggressive
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: How do I create a level using different colours in a picture?

    Quote Originally Posted by Norm View Post
    Did you look at the link for custom painting?
    Yes I *** did, but that has nothing to *** do with what I am asking.

    I want to read every pixel, from left to right, through the entire image, and put a number in an array depending on the RGB value of the pixel.
    Last edited by copeg; December 27th, 2013 at 10:28 AM. Reason: Removed profanity

  10. #10
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: How do I create a level using different colours in a picture?

    @LukeR, getting answers has as much to do with how a question is asked, and using profanity is not doing you any favors. Your posts have been edited. I suggest reading Lesson: Working with Images (The Java™ Tutorials > 2D Graphics)

  11. #11
    Junior Member
    Join Date
    Dec 2013
    Posts
    10
    My Mood
    Aggressive
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: How do I create a level using different colours in a picture?

    Sorry, but atleast now I have an answer related to what I want.
    But, for more explanation, watch the last five 2-3 minutes of this video
    3D Game Programming - Episode 34 - Entities - YouTube

Similar Threads

  1. Setting a transparency level of a picture issue
    By Asido in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 18th, 2012, 05:42 AM
  2. HELP - placing picture on top of another picture in Java - JLayerPane
    By smasm in forum What's Wrong With My Code?
    Replies: 39
    Last Post: April 27th, 2012, 07:16 PM
  3. Changing colours of objects
    By tommyf in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 22nd, 2012, 04:25 PM
  4. Replies: 1
    Last Post: January 3rd, 2012, 06:28 PM
  5. Converting a picture made up of 0s and 1s into a colored picture??
    By Kranti1992 in forum Java Theory & Questions
    Replies: 10
    Last Post: November 21st, 2011, 06:25 PM