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

  Рет қаралды 7,905

RyiSnow

RyiSnow

Күн бұрын

Пікірлер: 39
@Azulicious
@Azulicious 2 жыл бұрын
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 2 жыл бұрын
I'm always so excited when i see a new video on your channel!
@TaariBarungsi
@TaariBarungsi 2 жыл бұрын
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 2 жыл бұрын
Oops you're right, I forgot about that. I will fix it in the next video. Thank you for pointing that out!
@TaariBarungsi
@TaariBarungsi 2 жыл бұрын
@@RyiSnow No problem, I have an old computer, hence i always try to save memory as much as I can...
@deepseatrip
@deepseatrip 2 жыл бұрын
@@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 2 жыл бұрын
@@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 2 жыл бұрын
@@TaariBarungsi Thank you, you explained it great!
@OneLatteComingRightUp
@OneLatteComingRightUp 9 ай бұрын
Hey, Ryisnow! I was looking back and wondered if it was possible to add interactive tiles on the map to avoid confusion. Thanks!
@ProjCRys
@ProjCRys Жыл бұрын
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.
@hatdog2388
@hatdog2388 2 жыл бұрын
Wow cant wait to make my own game to enjoy
@JacobBohley
@JacobBohley Жыл бұрын
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 Жыл бұрын
I am too getting this error with a 250x250 map.
@cristofferostberg1297
@cristofferostberg1297 Жыл бұрын
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 Жыл бұрын
Yeah I use Eclipse@@cristofferostberg1297
@Jushy_
@Jushy_ 9 ай бұрын
Did you ever figure this out? I'm having the same problem
@JacobBohley
@JacobBohley 9 ай бұрын
@@Jushy_ No I didn't cause I decided to do world size changes as well so map doesn't really work with that anyway.
@Langostaz
@Langostaz 2 жыл бұрын
Exciting stuff!
@basilbijichirathilattu7193
@basilbijichirathilattu7193 11 ай бұрын
I am getting white gaps between the tiles, how do I fix this @RyiSnow ?
@64_bit_coding
@64_bit_coding 2 жыл бұрын
When will you implement the load game function? In the title screen video, you mentioned implementing load game
@RyiSnow
@RyiSnow 2 жыл бұрын
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 2 жыл бұрын
@@RyiSnow Ok. Thanks!
@su4amp397
@su4amp397 2 жыл бұрын
Thank you very much!!!
@mightymeet
@mightymeet 2 жыл бұрын
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
@dumdum7099
@dumdum7099 2 жыл бұрын
You are a hero my man
@darkpaladin.
@darkpaladin. 2 жыл бұрын
Amazing 👏
@droidlycodes
@droidlycodes 2 жыл бұрын
Can I request how to make tiles clickable with mouse 😁
@MrLoser-ks2xn
@MrLoser-ks2xn Жыл бұрын
🥰🥰🥰
@MrLoser-ks2xn
@MrLoser-ks2xn 2 жыл бұрын
Thanks!
@momagi6039
@momagi6039 2 жыл бұрын
NICE!
@alexanderlara6850
@alexanderlara6850 2 жыл бұрын
Good man!
@deepseatrip
@deepseatrip 2 жыл бұрын
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 2 жыл бұрын
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
@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 Жыл бұрын
@@teemukaik ok but where shall I put it? please tell me?
@drefter4
@drefter4 Жыл бұрын
@@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 9 ай бұрын
@@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.
Advanced Combat - How to Make a 2D Game in Java #48
40:54
RyiSnow
Рет қаралды 10 М.
Projectiles - How to Make a 2D Game in Java #29
28:49
RyiSnow
Рет қаралды 18 М.
Jaidarman TOP / Жоғары лига-2023 / Жекпе-жек 1-ТУР / 1-топ
1:30:54
Java Game Tutorial:  Ep 48 - Minimap
27:56
M3832
Рет қаралды 1,2 М.
Is 8-Bit Minecraft Possible?
12:58
Inkbox
Рет қаралды 1,4 МЛН
Map and HashMap in Java - Full Tutorial
10:10
Coding with John
Рет қаралды 628 М.
10 Aseprite tips you MUST Know
13:43
Penusbmic
Рет қаралды 53 М.
Photolithography on Silicon with PCB Chemicals
25:31
ProjectsInFlight
Рет қаралды 62 М.
10 Minutes vs. 10 Years of Animation
19:29
Isto Inc.
Рет қаралды 1,5 МЛН
The BEST Mechanical Display You've EVER Seen!!!
13:51
Tin Foil Hat
Рет қаралды 591 М.
How I Made a 3D Platformer in 2D Game Engine
21:23
ggenije
Рет қаралды 597 М.