Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (744)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (825)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Minimap using tilemap!  (Read 3021 times)
0 Members and 1 Guest are viewing this topic.
Offline VIrtueeL
« Posted 2015-02-16 11:55:09 »

this is how i get the tiles


i have an image with different colors in it then i run this code to check what the colors are then add blocks on different colors

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
      for(int x = 0; x < 100;x++){
         for(int y = 0; y < 100; y++){
           
            int col = map.getRGB(x, y);
           
            switch(col & 0xFFFFFF){
               case 0x808080:
                  tiles.blocks.add(new Block(new Vector2F(x*48, y*48), BlockType.STONE_1));
               break;
               case 0x404040:
                  tiles.blocks.add(new Block(new Vector2F(x*48, y*48), BlockType.WALL_1).isSolid(true));
               break;
               //////////////////////////////////////////////////////////////////////////////////////////////
               case 0x664A36:
                  tiles.blocks.add(new Block(new Vector2F(x*48, y*48), BlockType.WOOD_DOWN_MID_MID));
               break;
               case 0xFFBB87:
                  tiles.blocks.add(new Block(new Vector2F(x*48, y*48), BlockType.WOOD_DOWN_MID_TOP));
               break;
               case 0xE5A879:
                  tiles.blocks.add(new Block(new Vector2F(x*48, y*48), BlockType.WOOD_DOWN_MID_BOTTOM));
               break;
               
               
               case 0xD89F72:
                  tiles.blocks.add(new Block(new Vector2F(x*48, y*48), BlockType.WOOD_DOWN_RIGHT_TOP));
               break;
               case 0x997051:
                  tiles.blocks.add(new Block(new Vector2F(x*48, y*48), BlockType.WOOD_DOWN_RIGHT_MID));
               break;
               case 0xBF8C65:
                  tiles.blocks.add(new Block(new Vector2F(x*48, y*48), BlockType.WOOD_DOWN_RIGHT_BOTTOM));
               break;
               
               case 0xCC956C:
                  tiles.blocks.add(new Block(new Vector2F(x*48, y*48), BlockType.WOOD_DOWN_LEFT_TOP));
               break;
               case 0x7F5D43:
                  tiles.blocks.add(new Block(new Vector2F(x*48, y*48), BlockType.WOOD_DOWN_LEFT_MID));
               break;
               case 0xB2825E:
                  tiles.blocks.add(new Block(new Vector2F(x*48, y*48), BlockType.WOOD_DOWN_LEFT_BOTTOM));
               break;
               ///////////////////////////////////////////////////////////////////////////////////////////////
            }
           
         }
      }


now how do i create a minimap? i have never done one so would be cool to know how to create one =D

i do devlogs and i do tutorials check em out
https://www.youtube.com/user/InidDevo
Offline Sabomoth

Junior Devvie


Medals: 4
Exp: 3 years



« Reply #1 - Posted 2015-02-16 12:01:42 »

You do the same thing, but instead draw to the minimap. Many people create a new view that hosts the minimap. So like a second game window inside your window.
But dunno if you are using a library or something and i haven't worked in java for a while so can't give any tips on how that is done.
Offline VIrtueeL
« Reply #2 - Posted 2015-02-16 12:04:05 »

i use normal java 2d

i do devlogs and i do tutorials check em out
https://www.youtube.com/user/InidDevo
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Gibbo3771

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Reply #3 - Posted 2015-02-16 12:32:34 »

Just create a buffered image and change the pixel colour values to to that of your tiles and draw the image in the corner or something.

If that makes sense. Or stop using Java2D and move onto LWJGL/LibGDX and experience the awesomeness that is hardware accelerated graphics.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline VIrtueeL
« Reply #4 - Posted 2015-02-16 13:44:56 »

could you make an example?

i do devlogs and i do tutorials check em out
https://www.youtube.com/user/InidDevo
Offline lcass
« Reply #5 - Posted 2015-02-16 14:00:17 »

Try it yourself , here ill give you some pseudo code.

forever x = minimap.x , x < width , x += 1){
forever y = minimap.y , y < height , y +=1){
pixels[x + (y * width)] = get_color()
}
}
Just change get color() to your method and figure out how to select the tiles.
Offline Soulfoam
« Reply #6 - Posted 2015-02-16 19:08:06 »

You literally just do the same thing you're doing now. Create a new BufferedImage and scale it down and place it where ever you want on screen.
Offline VIrtueeL
« Reply #7 - Posted 2015-02-16 19:20:50 »

what if i want to move it so it follows where i'am on in the big map?

i do devlogs and i do tutorials check em out
https://www.youtube.com/user/InidDevo
Offline CodeHead

JGO Knight


Medals: 52


From rags to riches...to rags.


« Reply #8 - Posted 2015-02-16 20:45:54 »

You do the same thing you'd do when drawing your full map. Determine where the character is, and render x amount of "tiles" around him on the mini-map. The only difference between a mini-map and your regular map is that your regular map renders tiles at full size, but your mini-map renders the tiles at a scaled down size or representation. Beyond that, the logic and underlying data sources are the same. Wink

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Offline Ed_RockStarGuy
« Reply #9 - Posted 2015-02-16 20:53:04 »

https://github.com/4H1Z1/Horizon
A very old version of my game but it has a map and a mini map, feel free to have a look and get some ideas
Pages: [1]
  ignore  |  Print  
 
 

 
Ecumene (145 views)
2017-09-30 02:57:34

theagentd (213 views)
2017-09-26 18:23:31

cybrmynd (294 views)
2017-08-02 12:28:51

cybrmynd (284 views)
2017-08-02 12:19:43

cybrmynd (294 views)
2017-08-02 12:18:09

Sralse (287 views)
2017-07-25 17:13:48

Archive (966 views)
2017-04-27 17:45:51

buddyBro (1092 views)
2017-04-05 03:38:00

CopyableCougar4 (1663 views)
2017-03-24 15:39:42

theagentd (1425 views)
2017-03-24 15:32:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!