Monday, August 09, 2021

My Journey So Far - Developing Dungeon Crawler RPG in Java

I've been developing a 3D dungeon crawler RPG called "Rayndia" in Java... for quite a while.

My first dungeon crawler game in Java


It's been a while since I started the development for sure. Actually I started it right after I started learning Java and programming back in 2015.


At first, I just thought learning programming by developing a game would be fun. And 3D dungeon crawler RPGs such as Wizardry was one of my favorite genre so the decision was quite simple. Although I had already made a couple of text-based adventure games at this point I wasn't sure how hard making a dungeon crawler would be and I wasn't sure if I could really make it.

Wizardry I (NES). My favorite game of all time.


At the time I didn't even know how to write programs with multiple classes! So the first prototype of Rayndia was written in a single class and I think the class had more than 15K lines in the end lol

The very early state of the game.
The program was written in a single class!


Then I learned how to split the code into multiple classes. And I think I created 4 or 5 floor maps that were different from the current maps. But then I stopped the development. I'm not really sure why I stopped it but I guess I was somehow satisfied. I could somehow succeed to draw a dungeon and move around in it. I could implement an inventory system and a battle system as well.

I started it to learn Java and I felt like I could learn what I wanted to learn so didn't really need to finish the development. 

I learned how to split code into multiple classes.


Also I wasn't sure how I should handle the monster graphics. I was using my crappy monster illustrations and I knew I needed to replace them at some point but I wasn't sure how to do it. I was developing Rayndia just to learn Java so asking someone to draw illustration felt a bit too much.

My crappy monster graphic lol 
And I was developing the game in Japanese at the time.


So I stopped it and didn't touch the program for like 2 years. 


Then I started my YouTube channel. One day, I talked about my dungeon crawler RPG that I stopped developing a while ago. It was just out of a whim. I just made the video because I just ran out of the topics for the video at the time.




But that video changed the future of Rayndia. To my surprise, the video was received very positively and viewed much more than I expected (13K views as of this writing).

 
The video was received surprisingly well



And a guy who watched the video contacted me via Twitter. His name was Henry (@_henry_wilcox) and he was an illustrator. 

In the video, I said how crappy my illustrations are and drawing monsters are the hardest part of the development. Henry said he can draw illustrations for my game so I said "That would be great!"

My slime illustration


I gave him my crappy sketches and told him what kind of illustrations I like (I showed him some Jun Suemi's work). Then he draw some monsters based on my sketches. 



Kobold by Henry

Firebat by Henry


They were really nice but I realized (or felt) that they didn't fit so well with the simple black and white dungeon graphics. 

A Henry's illustration with the simple dungeon graphics.


Henry's illustrations were good and I thought I should be satisfied considering how bad the original illustrations were. But in the end I asked him if he could try drawing everything in black and white. He said "I was thinking the same". He re-drew everything in black and white. They were beautiful and gave my game new life. 

The black and white monster illustrations fit the game really well.


I was pretty excited but then realized something at this point. 

"Oh wait, now I have to complete this game no matter what." 

Don't get me wrong. It was not a negative feeling but a positive feeling. The game was no longer my learning material. I felt like I got a new goal and motivation to push me further so Henry's work won't be wasted. At this point, Rayndia became a "serious" project for me.


Then one day, I found this picture when I was looking through the internet.

From https://www.ragingswanpress.com


I liked my game's early 80ish simple line-drawing dungeon background and wanting more felt a bit too much. But I couldn't help but imagine how my game would look like if it had a background like this picture. 


So I did some experiment on my end and created some mockup dungeon images (thankfully I had a moderate experience of Photoshop) and shared them with Henry. Based on those images, Henry drew some wall and floor images.

The images that Henry had drawn


I edited the images and merge them with the dungeon graphics. I also added some shadows.



When I saw the result, I was excited.



It was so beautiful and reminded me of those old choose your own adventure books such as The Warlock of Firetop Mountain. I loved it. I reconstructed my dungeon drawing code almost from the scratch for this new graphic style. 


I split the dungeon into multiple parts so the program only needs to draw the parts that need to be updated

I reconstructed the rendering system to optimize the process.


I also created a dungeon map editor to speed up the development (it worked wonderfully).
My dungeon map editor


The graphics are ready. Now I just need to finish the program. As of this writing, I have finished all the floor maps and the game is somewhat playable till the final boss although it's still in a rough state. I still need to adjust tons of parameters such as monster strength, weapon attack, EXP to level up etc. I'm finding this balancing much harder than I had expected. 

I'm using an Excel file to handle the parameters


Sometimes a monster is too strong or a new weapon is too weak... so you need to adjust the parameter... it is a pretty tiresome process since you need to play the game again and again to find a correct balance. But I'm getting there.


Although there were some intervals, it's been 5 years since I started programming this game. It's been a bit too long. It's about time to reach the goal.


*If you feel like following the development, please check my YouTube channel (RyiSnow). I've been posting vlog-style videos on this game :)







Tuesday, August 03, 2021

Creating Legend of Zelda in Java (and my struggle for it)

I tried to re-create NES version's Legend of Zelda in Java.

Legend of Zelda (NES, 1986)


It wasn't so easy but a fun experience. I had developed a few 2D games before but never really tackled on this kind of action-oriented 2D game.


The challenging part:

1. How to create a map

In my previous 2D games, I used a text file to create a map. It's a pretty common way to create a 2D map and you can find a lot of tutorials about this method. However, this is not a great method when you want to create a large map. Not only it requires tons of inputting, since all the tile information is described by numbers, it is kind of hard to visualize the actual map image and which makes editing difficult.

Each number represents tiles.


So I decided to create a map/tile editor. I know there are already many tile editors exist but I thought developing one by myself would be fun. 

My tile editor (version 1)

My tile editor (version 2)


And it is done and I succeeded to re-create the entire Zelda field map. The editor made this process a lot faster and I was really happy about it.

My tile editor (version 3)



2. How to move monsters?

Moving player character only is relatively easy and I had done it before. But moving multiple monsters at the same time while controlling your player character was a new thing for me. The key is how to implement monster movement into the game loop. 

I created a class called DrawMonster (drawM) and instantiated this as an array.


So whenever a monster spawns, create a class like drawM[0], drawM[1]... and when you killed a monster, the class becomes blank. 

The DrawMonster class has methods that handle monster movement, monster hit detection, attack/dying animation, drop items etc.



So the game loop checks these classes in every game loop and update every monster status.



I also created:

DrawPlayer class

DrawObject class

DrawTiles class

DrawUI class

DrawDialogue class

These classes are checked in every game loop and the program updates all the status on the screen.



And here are some screenshots from the resulted game.

Legend of Zelda in Java


Legend of Zelda in Java


Legend of Zelda in Java


If you are interested, please check my video on YouTube as well.


(My Java Zelda is done... kind of)


Creating 2D games from scratch is fun but also pretty confusing. I often felt I was writing the code while I was not 100% sure what I was doing. I was repeating tries and errors and it was like, "Oh, I guess this works (but I'm not really sure why it worked) so let's use this", "Hmm it seems this doesn't work so let's try some other ways..." It was tough to wrap my head around all the classes and understand the whole system. 

I'm hoping to create 2D game tutorial videos to record my progress but I guess I need to sort out what I have learned a bit more before do that. I also feel that there are better ways to handle it. My code works fine but not organized well enough.


Man, programming is fun but tough!