Page 1 of 5 123 ... LastLast
Results 1 to 20 of 83
Like Tree1Likes

Thread: Images and stuff

  1. #1
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default Images and stuff

    hey guys (norm) it's me again :D
    i have some questions about Images. Im nearly at the end of my JumpNRun Editor, but some Stuff is still missing: the Ares to paint them.

    herefor i have some layers, which are a 2D Array of BufferedImages.
    these layers show these images on top of each other.
    so i have a ArrayList with layers, who contain a 2D array of BufferedImages.
    now my questions:
    1) how can i make the layers show their images? (i cant find a good tutorial...)
    a code would be usefull, where 1 BufferedImage is added to Frame so it gets shown.
    2) If i draw these layers one after another, the first one should be at the bottom, and the last one on top of all right?
    can i change this order too? is there a command to say - the 3. layer?

    thx already

    -Coold0wn

  2. #2
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default

    I am not too sure I know what you are talking about. Is this for an animation? That is the only reason that I could forge with you talking about arrays and BufferedImages.

  3. #3
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    i want to do a JumpNRun map editor. and the map will be 2D arrays of pictures lying on top of each other.
    did that bring any clearence? its like having a big picture containing small pictures lying on top of each other... ^^

  4. #4
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default

    So... besides having one really long image and making the coordinates go left or right, you want to go with one picture that changes to another, then it changes to another and another giving the illusion of movement? If that is the case... could you give me some details on how you are attempting to implement this? I have my own method of doing animations but yours might be different and I would like to see an example in order to compare them.

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,582
    Rep Power
    25

    Default

    Are you looking for a class like the JLayeredPane?
    Or do you want all the images drawn in one panel with different origins so a corner would show here and there.
    I think this could be done in the paintComponent method by choosing the x,y coordinates and the size of the image.
    The order the images were drawn would determine what part of what image shows.

  6. #6
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    hm.. i planned to only show 40x20 images per layer, and if the player moves the pics will change their x coordinate to the left or right and if the x-amount is behind a given x2 the image will disapper, or be drawn.

  7. #7
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,582
    Rep Power
    25

    Default

    40x20 = 800 images?
    What does "per layer" mean?

    if the x-amount is behind a given x2
    No idea what this means.
    If the amount of movement in the x direction is less than the value in the x2 variable, then ... ???

  8. #8
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default

    I am still in the dark with what you are trying to do. Sorry, but I cannot figure out your side scrolling strategy.

  9. #9
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    800 images... yes :P per layer...
    that means we have 800xamount of layers..
    those layers are 800 images of a specific type.. like the first layer will be sky-images
    the second might be trees in the background or sth and the 3 layer will grass where you can stand on.

    if the x-amount is behind a given x2

    i wanted to say that there is a line like this: | here are the image | :another line
    and if the x of an images reaches the first line it will disappear.. and if it will reach the 2. line it will appear
    so there are always only 40x20 images


    if you have a better solution for that... tell me^^

  10. #10
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,582
    Rep Power
    25

    Default

    How many layers are drawn at the same time?

    if the x-amount is behind a given x2
    There are areas where an image is not drawn. Is this for each of the 800 images?

  11. #11
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default

    Oh... I think I am catching on. You want to make a limit on the images on the screen to make sure you do not overload your computer's RAM, your programs allowed buffer memory or have your CPU have to deal with all of the images at once. You are trying to optimize your program, no? Anyway, what have you produced in order to deal with this... or do you have absolutely no idea what to do for this problem.

  12. #12
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    -planned are ... as many layers as you want :P
    but i think 5 is the max needed..
    -yes for each one.. so there will be only 40x20xamountoflayer shown at the time
    -you just answered your question i think
    i think the computer will manage to show and move 800x40xL images.. wont he?

    if this is not the best way for a jump n run, just tell me please..
    i never done sth like that .. its my holiday project :P

  13. #13
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default

    Just one more question before I come up with something. Are your layers really layers or just segments? Like, for instants, you have a square that represents a part of land and you have 5x2 of them to represent the floor. Because layers imply that you have a full image that will change each time your press a something or maybe its like layers in Flash. If you can tell me this, then I will see what I can come up with.

  14. #14
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    öhm... i dont use any premade class here if you mean that.
    my layers know a path to a 512x512 image. and they split it into 32x32 images.
    then they check their tiles (tile is another class, who has a image and a int imagenumber) and these layers give their tiles the needed 32x32 - part of their big image, looking at their int imagenumber.
    imagenumber tells the layer which 32x32 picture it should give the tile.

    hope you got it from that weird explaining.. if not, just ask please..
    im very bad in explaining ... :D

  15. #15
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default

    I think you have just stumped me, because I do not know how to help you beyond this point. It seems like you are making this a bit more difficult than it needs to be, but I do not know what your intentions for breaking up a 512x512 image into smaller 32x32 images. Do you have a function, class or a variable that stores which titles are currently on the screen?

  16. #16
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    my 512x512 image contains smaller 32x32 images.. i put them like in a grid. and i can pick 1 out and place it in the map..
    so i take my dirt with gras on top for the ones who are next to the air...
    and i take my pure dirt 32x32 image for dirt that has no gras on the side
    and i take my 32x32 bush out of the big image, so i can place a bush..

    and yes. i will make a camera kind of thing, which will contain and change tiles that are currently on the screen.
    ( that the thing with the 2 lines.. )

    edit:
    i dont know what stump means :P
    and i still have these 2 problems which are essencial to be solved..
    1) how do images work? ... -.-
    2) and can i put the images of layer 1 over the images of layer 2? or in the mid between 4 and 5 or sth like that...
    Last edited by Coold0wn; 08-12-2011 at 02:01 AM.

  17. #17
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Cool

    oh! Now i know what you are talking about. You have a bitmap type scheme. Alright, do you have a variable that stores the value of a tile in the game and a array that holds all of the tile values and lastly do you have some sort of file or array variable that knows what tiles should be in where to create the map. For example:

    level 1 map:
    Java Code:
    55555555555555555555555555
    44444444444444444444444444
    33333333333333333333333333
    22222222222722222227222222
    00000000000600000006000000
    lets say that
    5 = the sky 32x32 image
    4 = the sky but closer to the ground 32x32 image
    3 = Mountains or something
    2 = area above the ground
    0 = ground
    7 = top part of a tree
    6 = bottom part of a tree

    And lets say you only want the first 6 numbers in the map file to be present when the level starts.

    For example, only the first
    Java Code:
    555555
    444444
    333333
    222222
    000000
    will show?

    Sound good, or am I totally off?

  18. #18
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default

    To answer your edit, why do you need to overlap images and second, you could always google "How to use Images in Java"

  19. #19
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,582
    Rep Power
    25

    Default

    1) how do images work?
    I think they are a way to record the color and transparency of the pixels that are shown. There are some different classes that define and control the color schemes. Look at some of the classes in the java API doc for classes whose names contain the word color such as ColorModel.
    2) and can i put the images of layer 1 over the images of layer 2?
    If you use the drawImage method, draw the images in layer 1 after you draw those in layer 2

  20. #20
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    I think they are a way to record the color and transparency of the pixels that are shown. There are some different classes that define and control the color schemes. Look at some of the classes in the java API doc for classes whose names contain the word color such as ColorModel.
    first i would like to get some images on the screen :P
    it works fine if i put them ontop of buttons... but not if i dont..
    and there is no single good tutorial in the internet..

    at oracle.. they tell you the methods again.. but not what to do/import/extend/what you need, like some 2D Graphic thing and stuff...
    it would be awsome if you could give me a code, where 1 BufferedImage is shown at the screen..^^

    If you use the drawImage method, draw the images in layer 1 after you draw those in layer 2
    okay.. thats allright, and if i have drawn both, can i put 1 of them ontop of the other?
    or do i have to delete them and redraw?

Page 1 of 5 123 ... LastLast

Similar Threads

  1. where the stuff goes?
    By Izabela in forum New To Java
    Replies: 16
    Last Post: 08-31-2010, 02:00 PM
  2. Replies: 6
    Last Post: 05-26-2010, 12:17 AM
  3. Table, beginner stuff
    By drwk in forum New To Java
    Replies: 1
    Last Post: 01-24-2010, 07:19 PM
  4. Simple Stuff 0.1
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 07-19-2008, 04:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •