Map Screen and Minimap - How to Make a 2D Game in Java #47

In this video, we will implement a map screen and minimap function.
Guidelines for using Blue Boy Adventure's code and assets:
docs.google.com/document/d/1q...
Timestamps:
0:00 Introduction
0:23 Creating Map Class
5:22 Map Screen
14:45 Minimap
20:00 FINAL RESULT
#javatutorial #javagamedevelopment

Пікірлер: 39

  • @Azulicious
    @Azulicious Жыл бұрын

    Every time I get close to catching up, a new part releases! I look forward to following along with this one soon, too. Thank you!

  • @Loggog
    @Loggog Жыл бұрын

    I'm always so excited when i see a new video on your channel!

  • @su4amp397
    @su4amp397 Жыл бұрын

    Thank you very much!!!

  • @Langostaz
    @Langostaz Жыл бұрын

    Exciting stuff!

  • @TaariBarungsi
    @TaariBarungsi Жыл бұрын

    As always nice and informative. Remember to dispose of Graphics2D object when you are done drawing to the BufferedImage(image), since you are creating Graphics2D g2 = image.createGraphics(), unless you dispose it, the resource will stay open. Its something that's easily forgotten.

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    Oops you're right, I forgot about that. I will fix it in the next video. Thank you for pointing that out!

  • @TaariBarungsi

    @TaariBarungsi

    Жыл бұрын

    @@RyiSnow No problem, I have an old computer, hence i always try to save memory as much as I can...

  • @deepseatrip

    @deepseatrip

    Жыл бұрын

    @@TaariBarungsi I checked out my memory usage , I was using a 100x100 map and 32x32 tiles. It was pretty high and I have a nice computer , so I cut the map back to 50x50 and it helped a good amount. Ive now upped my tiles from 8x8 >16x16>32x32 and kind of wish I stayed at 16x16 lol but I love the crisp look of the 32x32 and Im too deep with over 200 tiles lol. One thing I noticed with my memory usage is that it consistently climbs and does not stop going up. I haven't really payed attention to this yet cause most the time I am not actually leaving the game running long but this would inevitably cause a crash. I am wondering if yours does the same thing, Ive added some random things like growable plants with a timer , so this probably something I have done or maybe it only significant to me cause tile/maps sizes and assets ive added in game.

  • @TaariBarungsi

    @TaariBarungsi

    Жыл бұрын

    @@deepseatrip Since java uses CPU instead of GPU there is not much you can do about that, but i would recommend you to cut down over-creation of objects inside loops(for/while) and also if you can call on objects only when needed inside game-loop(update,render/draw). Instead of creating a new variable every loop-iteration, create the variables outside of the loop. That way you have a reference to the variable and can change its value instead of creating a new variable n-number of times inside a loop. Think about it for a moment, if you have a reference, you only need to access the memory location of that reference to make changes you don't request the allocation of new memory, but when you create a new variable inside a loop, you allocate memory for that variable and the garbage collector then deletes that variable at the end of a single-iteration and the loop may run for n-amount of times. The memory usage may not be that high for smaller projects but since there are images and drawing involved then surly you would begin to notice the lag. English isn't my language so i hope i explained it in a way that you could understand what i was trying to say.

  • @deepseatrip

    @deepseatrip

    Жыл бұрын

    @@TaariBarungsi Thank you, you explained it great!

  • @hatdog2388
    @hatdog2388 Жыл бұрын

    Wow cant wait to make my own game to enjoy

  • @MrLoser-ks2xn
    @MrLoser-ks2xn Жыл бұрын

    Thanks!

  • @darkpaladin.
    @darkpaladin. Жыл бұрын

    Amazing 👏

  • @OneLatteComingRightUp
    @OneLatteComingRightUpАй бұрын

    Hey, Ryisnow! I was looking back and wondered if it was possible to add interactive tiles on the map to avoid confusion. Thanks!

  • @dumdum7099
    @dumdum7099 Жыл бұрын

    You are a hero my man

  • @ProjCRys
    @ProjCRys11 ай бұрын

    how do you include the other entities such as NPCs and objects into the map? because if I wanted to display a map with abundance of objects the map looks desolated when it only displays the tiles.

  • @momagi6039
    @momagi6039 Жыл бұрын

    NICE!

  • @alexanderlara6850
    @alexanderlara6850 Жыл бұрын

    Good man!

  • @64_bit_coding
    @64_bit_coding Жыл бұрын

    When will you implement the load game function? In the title screen video, you mentioned implementing load game

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    It's coming pretty soon. I was waiting until all the data that we need to save/load are implemented in the program.

  • @64_bit_coding

    @64_bit_coding

    Жыл бұрын

    @@RyiSnow Ok. Thanks!

  • @mightymeet6987
    @mightymeet6987 Жыл бұрын

    Hello, I need some help. I have a problem in KeyHandler, where I want the player to move. Can you solve my problem? Thank you

  • @MrLoser-ks2xn
    @MrLoser-ks2xn7 ай бұрын

    🥰🥰🥰

  • @misterdneh
    @misterdneh Жыл бұрын

    Can I request how to make tiles clickable with mouse 😁

  • @JacobBohley
    @JacobBohley10 ай бұрын

    So when I try to start the game after implementing the map for the first time, it crashes and sends this error: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space I think it's cause my map is too large, cause when I shrink it down it works fine. Right now my map is 341x193. Do you know any way to fix this without changing the map size?

  • @cristofferostberg1297

    @cristofferostberg1297

    8 ай бұрын

    I am too getting this error with a 250x250 map.

  • @cristofferostberg1297

    @cristofferostberg1297

    8 ай бұрын

    You need to increase the heap memory in your JVM (only a plaster fix, i know, but its working temporarily, atleast) What IDE are you using? In IntelliJ = 1. Go to Help menu in IntelliJ 2. Scroll down to Edit Custom VM Options 3. Paste these lines (or update the existing, if they're lower than Xmx2024m) -Xms512m -Xmx2024m -XX:MaxPermSize=700m -XX:ReservedCodeCacheSize=480m 4. Now your IntelliJ IDE is implemented with more JVM memory for your every project, and you can run the game.

  • @JacobBohley

    @JacobBohley

    8 ай бұрын

    Yeah I use Eclipse@@cristofferostberg1297

  • @Jushy_

    @Jushy_

    Ай бұрын

    Did you ever figure this out? I'm having the same problem

  • @JacobBohley

    @JacobBohley

    Ай бұрын

    @@Jushy_ No I didn't cause I decided to do world size changes as well so map doesn't really work with that anyway.

  • @deepseatrip
    @deepseatrip Жыл бұрын

    YAY THANKS! If anyone has added new tilesets/maps I Was running into issue where I would get a : Cannot read field "image" because "this.tile[tileNum]" is null at tile.Map.createWorldMap(Map.java:40) at tile.Map.(Map.java:17) at main.GamePanel.(GamePanel.java:83) at main.Main.main(Main.java:17) Took me a second to figure out, but it was because I still had old maps that were not being used with old tilesets but I had not commented/deleted them out yet. Once I commented it worked just fine again.

  • @D.jerome387

    @D.jerome387

    Жыл бұрын

    Hey, got the same issue and for me the problem was that there were no indexed tiles at 0,1,2,3,4,5,6,7,8,9 . I filled them in and it worked for me.

  • @mck1680

    @mck1680

    Жыл бұрын

    Hello! Can you please tell me what you did? Because I have the same error code. I wanna full screen map work and Mini map too

  • @basilbijichirathilattu7193
    @basilbijichirathilattu71933 ай бұрын

    I am getting white gaps between the tiles, how do I fix this @RyiSnow ?

  • @mck1680
    @mck1680 Жыл бұрын

    Hello! Can somebody help me? When I am doing Map Screen and Minimap - How to Make a 2D Game in Java #47. I get errors: Exception in thread "main" java.lang.NullPointerException: Cannot read field "image" because "this.tile[tileNum]" is null at tile.Map.createWorldMap(Map.java:40) at tile.Map.(Map.java:19) at main.GamePanel.(GamePanel.java:61) at main.Main.main(Main.java:16). I have checked it and nothing is wrong. So please help me.

  • @teemukaik

    @teemukaik

    Жыл бұрын

    You probably don't have maps after 1 or 2?, You should set your maxMap to be same as your mapcount

  • @drefter4

    @drefter4

    10 ай бұрын

    @@teemukaik ok but where shall I put it? please tell me?

  • @drefter4

    @drefter4

    10 ай бұрын

    @@teemukaik The error I get when I try to get worldMap. They say Exception in thread "main" java.lang.NullPointerException: Cannot read field "image" because "this.tile[tileNum]" is null

  • @adnan2734

    @adnan2734

    Ай бұрын

    @@drefter4 in the GamePanel class, //World Settings, you will see public final int maxMap = something.I matched the map number i have so it fixed.You can press CTRL + left click while pointing maxMap to show its location.