Transition Between Maps - How to Make a 2D Game in Java #38

preview_player
Показать описание
In this video, we implement a new map and handle switching maps function.

Now we can create any number of areas and travel around!

If you want to use my assets (images/maps/sound) that are used in this tutorial, here's the link:

Guidelines for using Blue Boy Adventure's code and assets:

Thanks for watching.

Timestamps:
0:00 Quick update
3:52 Preparing a new map
6:01 Changing mapTileNum to three dimensional array
11:30 RESULT & ISSUE
12:18 Changing obj, npc, monster and iTile to three dimensional
13:44 Using the second dimension as the for loop length
15:17 Continue updating the code
24:27 Updating the EventHandler
28:00 Implementing transition events
32:54 FINAL RESULT

#javagamedevelopment #javagametutorial
Рекомендации по теме
Комментарии
Автор

The zoom in when changing mapTileNum to a 3D array was pure gold.

jacobstewart
Автор

I've been looking forward to reaching this part of the tutorial because I think map transitions are crucial for adding depth to a game. This feature really opens up a lot of possibilities. It was more complicated to implement than I anticipated but easier to understand thanks to your clear instructions! Thank you

current_goliath
Автор

i am really looking forward for the boss event tutorial, thanks for all your work! I really love this series <3

robin-conr
Автор

Thank you so much for continuing to make these tutorials. They are really helpful for those trying to make indie games using java instead of unity, unrealengine, etc.

maxconradt
Автор

Thank you very much for this series, it's been extremely helpful, all the videos are easily understandable and entertaining, you've been a great help to many people. Thank you.

supergato
Автор

I wanted to finish this video before I started studying for a tech math course for my job. Glad I made it this far and as soon as I finish ill be back to coding and finishing this series. I have been loving every second of it, thank you ryisnow!

Mypremiumacct
Автор

Keep doing it! Thanks a lot! Your videos have educated me more than books!

Nikitosik_
Автор

you are truly amazing, im learning so much in this! when i make a game my self im not gonna forget about you bro you are such a gem to me!

garciajushua
Автор

The introduction of a new dimension on every map arrays in a very interesting approach! Concerning the for loops and the multi dimension arrays, we could use a for each loop like this :
for (Entity c: npc[currentMap]) {
if (c != null) {
c.update();
}
}
And avoid tons of mistakes in the code ;)

giorgioripani
Автор

Loving the progress on this, keep it up!

Pichuscute
Автор

Thanks so much, this was the video I have been waiting for! Do you think at some point you will create a video on how to add dialogue options for NPCs? Or how to add events that cause cutscenes? Like if the player walks into a house, an NPC will come up to the player and give them a tour of the house?
Also, this might be unlikely but I was wondering if you'd ever do an extra part on how to make turn based combat or tactical RPG combat?

purpleconvict
Автор

Wow so exciting this part, dungeon boss is waiting their 👍👍❤

tvclipsgames
Автор

Thanks Ryu, for the update!!! You are a great among greats

FerodriEste
Автор

Oh man your videos mean a lot for me!!! Thanks for new video!!!

bitalya-g
Автор

I have a suggestion to make a better game perfomance. If you attack and then die, interact with smth/etc game still shows attackingSprite and its some sort of weird.
To fix that set attacking boolean in Entity to public. Then everytime you die, interact with npc set gp.player.attacking to false.

Merkuse
Автор

Oh you are still alive, cool that u upload more videos!

schuhphi
Автор

Thank you so much for this video!
I was looking forward for this tutorial.
Wanted to add a cave layer to my world for so long but just didn't managed to do it right...

laurenzfitzner
Автор

For my project, I have a minimal amount of persistent NPCs. I implemented the A* logic from your other tutorial, but am commenting here as it is multi-map related. Have you ever explored updating NPCs that are offscreen?

I was able to have the NPCs 'moving' on other maps, but when entering said maps, I could see they wandered out of the regular bounds of the maps, into colliding tiles. I troubleshooted how I could have these NPCs manage to avoid doing this, but as soon as I explored checkTiles for these off screen NPCs (was using a method in the Entity class, called simulateOffScreen) they were registering as colliding every time of movement. I tried digging into the checkTiles method and substituting the currentMap with a mapIndex specific to each NPC, but this was breaking my project and felt like a rabbit-hole I was not prepared to resolve.

Long comment... thanks in advance!

russellwaring
Автор

Hello Ryi. I want ask you how to make player do not stop while attacking ? This is so hard for me, java-beginner. I really hope you can explain how to did that. Also thanks for your videos !

Merkuse
Автор

I face a problem in that I only can draw all tiles properly on the interior map. Once I switch to worldV3, only tiles are changed to grass0 image. Everything else is fine like collision, obj, projectile, particle, etc. I check the load and draw methods somehow when draw it with currentMap all data change to 0, but I print out together or without curretMap that works. I don't where problem is and how to fix it....

I think I found the problem. It is not only I keep extra feature on camera, but also the IDE does not show errors in the load method. I do not know how to change it...


private static int[][][] ReadFromFile(File file, int currentMap) {
int[][][] matrix = new
try {
Scanner scanner = new Scanner(file);
int map = 0;
int col = 0;
int row = 0;
while(map < MAX_MAP && col < MAX_WORLD_COL && row < MAX_WORLD_ROW) {
String line = scanner.nextLine();
while(map < MAX_MAP && col < MAX_WORLD_COL) {
String[] numbers = line.split("\t");
int num =
matrix[currentMap][col][row] = num;
col++;
map++;
}
if(col == MAX_WORLD_COL) {
col = 0;
row++;
if(row == MAX_WORLD_ROW) {
row = 0;
map++;
}
}
}
scanner.close();
} catch(FileNotFoundException e) {
e.printStackTrace();
}
return matrix;
}

wonderzhou
welcome to shbcf.ru