Making a Game with Java with No Experience

Alphabets Sounds Video

share us on:

In this lesson, the author shares their journey of learning Java to create a game from scratch, inspired by classic RPGs. Starting with a simple “Hello World” program, they progressed to developing a more complex RPG, implementing features like a tile map system, character interactions, and sound effects, while also experimenting with different art styles. The author emphasizes the rewarding experience of coding without a game engine and encourages others to explore programming through interactive resources like Brilliant.

Making a Game with Java with No Experience

Java has always intrigued me, not just because of its catchy name, but because some of my favorite childhood games, like RuneScape and Minecraft, were developed using it. Java’s ability to “write once, run everywhere” means that code written in Java can run on different operating systems without needing to be recompiled. Since its inception in 1995, Java has remained a popular programming language, and I’ve been eager to explore its capabilities.

Starting My Java Journey

My initial attempt to learn Java was when I was 12, inspired by a book titled “Programming Video Games for the Evil Genius.” Despite its cheesy title, it was a Java learning resource. However, my early efforts were met with frustration, and I abandoned the endeavor. Fast forward nearly 15 years, and I decided to give it another shot, aiming to create a game from scratch using Java.

To kickstart my Java journey, I enrolled in a brief online course to familiarize myself with the syntax. For beginners, this is a great way to get a feel for a new programming language. Armed with the basics, I downloaded Eclipse, a popular Integrated Development Environment (IDE) for Java coding. Although I had used NetBeans in the past, Eclipse seemed to be the preferred choice now.

Creating My First Java Program

With Eclipse set up, I embarked on creating a simple “Hello World” program. This involved creating a package named “Main” and a class with the same name. By adding the line System.out.println("Hello, World!");, I successfully ran my first Java program.

Developing an RPG

Encouraged by this success, I decided to work on a more ambitious project: an RPG inspired by classic NES games like Dragon Quest and EarthBound Beginnings. These games’ simplistic art style and quirky characters have always appealed to me.

The first step was to create a window using Java’s built-in JFrame class. This allowed me to set up the game’s visual frame. Next, I created two classes: Entity and Player. The Entity class would serve as a foundation for both players and NPCs, enabling code reuse for tasks like drawing sprites and handling collisions.

Building the Game World

To create the game world, I implemented a tile map system. This involved using a text file with numbers representing different tiles, such as water, grass, and sand. By loading this data into an array and using a loop, I generated the tile map. To optimize performance, I implemented a camera system that only renders visible tiles, and added collision detection to prevent players from walking on water.

Enhancing Visuals and Sound

Recognizing the importance of visuals in RPGs, I experimented with different art styles. Initially, I aimed for a vector art style but switched to pixel art for better scalability. Using the NES color palette, I created an animal-inspired RPG world. I also utilized pixel art software to export tiles as text files, effectively turning it into a level editor.

Sound was another crucial aspect. I generated various sound effects, including a satisfying door sound, and composed music using a new tool. Although my composition was a bit rough, it added to the game’s atmosphere.

Adding Game Features

To enhance gameplay, I implemented a pausing system for inventory and stats viewing, and added text rendering for dialogue. I also created a world map and room transition system, allowing players to explore different areas. Adding NPCs was straightforward, thanks to the Entity system, and I developed a dialogue system for character interactions.

Future Plans and Reflections

While the RPG is still missing combat, which is a vital component, I plan to tackle that in the future. Creating a game without a game engine is challenging yet rewarding, as it provides a sense of accomplishment. I have many ideas for this RPG and may continue working on it as a passion project.

Overall, I thoroughly enjoy using Java. It’s been my favorite language in this series, and I highly recommend checking out the tutorial series I followed. It’s incredibly informative and covers everything discussed here.

Learning Resources

If you’re interested in learning programming, consider exploring Brilliant, a platform offering interactive lessons in math, data analysis, programming, and AI. Brilliant emphasizes hands-on problem-solving, helping you develop critical thinking skills. Their programming courses are an excellent starting point for building foundational skills and understanding real-world applications.

To try Brilliant for free for 30 days, visit brilliant.org/gus or click the link in the description. You’ll also receive 20% off annual premium subscriptions.

Lastly, feel free to visit my website, gus.fun, for updates on my latest projects. Let me know if there are any coding challenges you’d like me to tackle in the future!

  1. Reflecting on your own learning experiences, what challenges have you faced when trying to learn a new skill or subject, and how did you overcome them?
  2. How do you think the author’s early interest in Java and video games influenced their decision to revisit learning Java after many years?
  3. What are some key takeaways from the author’s journey in creating a game with Java, and how can these lessons be applied to other projects or areas of interest?
  4. In what ways do you think the choice of programming language impacts the development process and final outcome of a project?
  5. How important do you believe visuals and sound are in enhancing the user experience of a game, and why?
  6. What are your thoughts on the author’s approach to learning Java through a combination of online courses and hands-on projects?
  7. Considering the author’s future plans for their RPG, what features or elements would you prioritize if you were in their position?
  8. How do you think platforms like Brilliant can contribute to effective learning, and what role do they play in developing critical thinking skills?
  1. Create a Simple Java Program

    Start by writing a basic “Hello World” program in Java using an IDE like Eclipse. This will help you get familiar with the Java syntax and the development environment. Once you successfully run the program, try modifying it to display different messages or perform simple calculations.

  2. Design a Basic RPG Character

    Using Java, create a simple class structure for an RPG character. Define attributes such as name, health, and strength. Implement methods to simulate actions like attacking or healing. This exercise will help you understand object-oriented programming concepts in Java.

  3. Build a Tile Map System

    Develop a basic tile map system using Java. Create a text file that represents different tiles with numbers, and write a Java program to read this file and display the corresponding tiles in a window. This will give you hands-on experience with file handling and graphical interfaces in Java.

  4. Experiment with Pixel Art

    Try creating simple pixel art for your RPG game using a pixel art tool. Export your designs as text files and integrate them into your Java game. This activity will enhance your understanding of how graphics are handled in game development.

  5. Implement a Dialogue System

    Create a basic dialogue system for NPC interactions in your RPG game. Use Java to display text on the screen and allow players to navigate through different dialogue options. This will help you practice text rendering and user interaction in Java.

Here’s a sanitized version of the YouTube transcript:

Java has always fascinated me. Not only is it the most delicious-sounding programming language I’ve ever heard, but some of my favorite childhood games, like RuneScape and Minecraft, were made using it. It was created to let programmers “write once, run everywhere,” meaning Java code automatically works on other operating systems without having to recompile, which is truly a beautiful thing. Ever since its release in 1995, it has remained one of the most popular programming languages. Needless to say, I’ve been anxious for a long time to try it out and see what I can do with it.

Now, I must confess, when I was 12, before I even made video games, I went to my local library and picked up a book called “Programming Video Games for the Evil Genius.” A pretty cheesy name for a book that was just about learning Java. Of course, after skim-reading a chapter or two and trying to copy the code, I quickly became frustrated and completely gave up. Fast forward almost 15 years later, I think it’s time for me to redeem myself and see if I can actually make a game from scratch using Java.

So, starting off on my Java quest, I did something I haven’t done in a while: I took a little Java course on my phone. By “take a course,” I mean I just did a couple of levels to get a feel for what the syntax was like. Honestly, if you’re a beginner or new to programming languages, I feel like this is a good thing to do. It gives you a general idea before you start jumping into it.

After getting familiar with the basics, I downloaded Eclipse, which is an IDE (Integrated Development Environment). Just in case you don’t know what that is, it’s basically software that you use to code in, specifically for Java. I seem to remember using an IDE called NetBeans as a kid, but Eclipse seems a lot more popular now, so I figured I would go with the crowd.

After that, I set off to create a simple “Hello World” program, which was pretty straightforward. Basically, you create a package and name it “Main,” then create a class and also call it “Main.” I know it’s confusing, but just trust me on it. After that, I added the classic `System.out.println(“Hello, World!”);` and there you go—your first Java program. I did it!

After getting my feet wet, I knew I was ready to start working on my real project. Instead of creating a little mini-game like I normally do for these kinds of videos, I wanted to do something I’ve been dreaming about for a while now: making an RPG. I’m not talking about rocket launchers here; I mean like an old grindy RPG that you would play on the NES, like Dragon Quest and EarthBound Beginnings. I find these games’ simplistic art style, strange characters, and repetitive combat to be so charming. They always feel so empty yet so full of character at the same time.

Now that we know what direction the game’s going to take, it’s time to do something basic: draw a window. I’m not talking about getting out a box of crayons and drawing a house with a window; I’m talking about that frame that you see on your desktop when you play a game. Luckily for us, Java has its own built-in container class called JFrame, meaning our game can be built purely with Vanilla Java. I set up JFrame and made some of the parameters. After doing all that, I was able to successfully draw a window, and as you can tell, I was very excited.

Next, I created two new classes: Entity and Player. I’m planning on making NPCs later on, so creating an Entity class allows me to reuse that code for the Player and NPCs, for example, drawing their sprites or checking for collisions. Speaking of sprites, I was able to load and draw the image of a character and make it move around the screen, so yay!

I should also point out that I found a wonderful tutorial series that was beyond helpful. The creator does a really good job explaining how all this works, so if you want to know more about the nitty-gritty details and all the code, definitely check it out.

Next, I wanted to dive into creating a tile map system. This is something that has always been intimidating for me for some reason, but it turns out to be super easy. Essentially, all you have to do is create a text file full of numbers. The numbers represent different types of tiles—like zero is water, one is grass, and two is sand. Then, all you need to do is load the data into an array and slap it into a for loop. Boom! You got yourself a tile map.

That’s great and all, but how do you make a camera system so that the player can move around a larger tile map area? The trick is, instead of moving the player, you move the tile set. After that, I made an if statement to see what tiles were on screen, which allowed me to save performance by only rendering what the player could see. Lastly, I created collisions so you couldn’t just walk on the water.

As you can tell, the artwork is looking a little rough around the edges, and since 50% of RPGs is just artwork, I felt like we should probably update this. My original idea was to create a vector art style inspired by certain illustrations. I’ve been a big fan of that work for a while and thought an RPG could look super fresh in this style. However, I quickly realized that higher resolution vector artwork wasn’t going to scale well down into pixels. This led me to create the same style but using pixel art instead. I thought the results were kind of cool, but I personally felt like this missed that quirky charm I wanted to emulate in my favorite NES RPGs.

After a slightly iterative process and using the NES color palette, I ended up with my animal-inspired RPG. With that done, I got to work replacing and adding in all the new tiles and artwork. I also found that the pixel art software I use has a feature that lets you export tiles as a text file, essentially turning my art software into my level editor, which was pretty sweet.

After this, I felt like the sound aspect of the game needed to be addressed, so I generated a couple of different sounds and added them to the game. I especially love the door sound when you enter a house; it’s oddly satisfying. For music, I made it myself using a new tool, and while my song’s a little clunky, let me know what you think.

After that, I created a pausing state system so you can eventually look at your inventory and view your stats. I also drew text onto the screen, and that text is actually a font. I know that world maps are a pretty big deal in these types of RPGs, so I jumped back into pixel art and made a smaller world map just as a test run to see how I liked it. This also meant I had to create a room transition system so you could go from towns to the overworld. Right now, there’s only one town, but I think it’s pretty cool. It’s starting to feel like an RPG.

At this point, I knew it was probably time to add NPCs. They’re such a critical part of RPGs, and using the entity system I mentioned earlier made adding these NPCs take no time at all. Then, I added a dialogue system so I could have characters say interesting things. With that, we have a basic RPG structure. We’re still missing combat, which is the most crucial part of the game, but I want to save that for a future video because this was a project I really enjoyed working on.

I can’t explain it, but making a game without a game engine is super satisfying. It’s difficult and frustrating, especially when you know you could do it 10 times faster using something else, but it’s also really rewarding because you know that you made it yourself. I have a lot of plans for what I could do with this RPG in the future, even just as a passion project. Please let me know if you’d like to see more of it; if not, I’ll probably just continue to work on it in my own time.

Overall, I really enjoy Java. I think this has probably been my favorite language I’ve used so far in this series. I highly recommend you check out the tutorial series on Java; it’s unbelievably helpful and explains everything that I covered in this video pretty much. Even if you’re just mildly interested, check it out.

Also, if you’re wanting to learn how to code yourself and you don’t know how to get started, check out a word from today’s sponsor, Brilliant. Brilliant is where you learn by doing, with thousands of interactive lessons in math, data analysis, programming, and AI. One thing I really like about it is that Brilliant helps build your critical thinking skills through problem-solving, not memorization. While you’re building real knowledge on specific topics, you’re also becoming a better thinker.

Brilliant is a learning platform designed to be uniquely effective. Each lesson is filled with hands-on problem-solving that lets you play with concepts—a method proven to be six times more effective than just watching boring lecture videos. Plus, all the content on Brilliant is crafted by an award-winning team of teachers, researchers, and professionals from top institutions.

If you want to start programming, Brilliant has a growing number of programming courses that are a great way to start building foundational programming skills and learn real-world applications. You can get familiar with Python and start building programs on day one with a drag-and-drop editor. Learn essential coding elements, things that everyone should know, like loops and variables, and most importantly, develop your mind to think like a programmer.

To try everything Brilliant has to offer for free for a full 30 days, visit brilliant.org/gus or click the link in the description. You’ll also get 20% off annual premium subscriptions, so check it out!

Lastly, I just want to give my website a shout-out: gus.fun. Check it out; it’s got some information on the latest videos and a picture of me. Let me know if there are any other coding challenges you want me to tackle in the future, and I’ll see you next time!

This version removes any informal language, personal anecdotes, or specific references that may not be suitable for all audiences while retaining the core content and structure of the original transcript.

JavaA high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. – Java is widely used for building enterprise-scale applications and Android apps.

CodingThe process of writing instructions for a computer to perform specific tasks, often using a programming language. – Coding in Python can be a great way to learn programming fundamentals.

ProgrammingThe act of creating a set of instructions that tell a computer how to perform a task. – Programming requires logical thinking and problem-solving skills.

RPGRole-Playing Game, a genre of video games where players assume the roles of characters in a fictional setting. – Developing an RPG involves complex coding to manage character interactions and storylines.

EclipseAn integrated development environment (IDE) used in computer programming, particularly for Java development. – Eclipse provides powerful tools for debugging and testing Java applications.

SyntaxThe set of rules that defines the combinations of symbols that are considered to be correctly structured programs in a programming language. – A syntax error in your code can prevent the program from running.

GraphicsThe visual elements displayed on a computer screen, often created or manipulated through programming. – Creating 3D graphics requires understanding both mathematics and programming.

SoundAudio elements that can be integrated into software applications, often requiring specific coding techniques to manage. – Implementing sound effects can enhance the user experience in a video game.

TilesSmall, square graphics used in video games to create a larger scene, often used in 2D game development. – The game developer used tiles to efficiently design the game’s environment.

ResourcesAssets such as images, sounds, and other data used in software development to enhance functionality and user experience. – Managing resources efficiently is crucial for optimizing application performance.

All Video Lessons

Login your account

Please login your account to get started.

Don't have an account?

Register your account

Please sign up your account to get started.

Already have an account?