I am completely new to Java, and I’m currently taking the tutorials at Oracle. However, I still don’t understand some things.
I’m trying to create a small prototype on a game right now. There are two games I wish to create. I’m working on creating social life simulations, and the two games are going to be called “SchoolLife” and “ChildLife.” Obviously, they’re two different simulations. SchoolLife is a watered-down version of ChildLife. The premise of both games is to simulate a child going from age 6 to age 18. SchoolLife will only focus on home life; ChildLife will focus on both school and home life.
The engine should be turn-based, and run on a day-to-day basis. I have not figured out how to do this.
Over summer break, the system will turn to a week-by-week system.
Both games are going to have GUIs, but I’ve decided to go with a text interface before I start making the graphical.
Generating Stats
The character you control will have several values:
(I think this should all be public variables, if I intend to use these variables outside? for ex: parents’ last names = char last name)
int mcharprsnltrait1
int mcharprsnltrait2
int mcharworker
int mcharsocial
int mcharintelligence
int mcharhappiness
int mcharethnicity
string mcharfirstname
string mcharlastname
boolean mcharurban
int mcharpic
int mcharage
int mcharpopularity
int mcharlovemeter
int mcharspecialtrait1
int mcharspecialtrait2
(Of course, “mchar” stands for main character, so that the variable will be unique and stand for only your character among other private and public variables. Other students should have the same exact template, but should have only the prefix “char” instead of “mchar.”)
First off, which command allows me to create random stats? I want random stats for the first five variables. I’ve found a way to create random integers, but how do I create a random last name according to the ethnicity? In my game, there will be three ethnicity: black, white, and asian (it’d be harder to program more). How do I create arrays of last names that I can pick randomly according to the ethnicity? I got a little idea of the coding for it:
If the game starts {
int lastnameno = get random number between x and y;
int charlastname = arrayname[lastnameno];
}
I will create a database of 75 last names, 25 for Asian, then 50 for black+white. I also want there to be a small chance of getting a unusual last name, such as “Lee” if you are white, or “Brown” if you are Asian. Also, I want to make sure that between other, non-sibling npc students, that a last name will not appear more than twice in a game.
Other things, such as the character’s first name and the ethnicity will be filled in by the player through a form.
Also, I want to generate two parents for the player. These will have limited functionality in SchoolLife, but I want it to play a sizable role in ChildLife, because the parents must affect the child’s life. I came up with a system where the parent inherits one trait, charprsnltrait1 for the mother, and charprsnltrait2 for the father. Then, everything else, including a first name, will be generated.
There should also be a fifty/fifty change that the parents are the same ethnicity.
The parents will affect what choice the child can make, such as if he can go to the prom, of if they go to an open house, or if they will scold you for bad grades. There should be a short section at the end of each day which affects your character, a dialogue between parents or with the parents with you. Or, if your parents are okay, there should be nothing to talk about.
I also want to assign pictures to the parents. I want there to be at least eighteen pictures, six to each ethnicity, three to each sex, then to pick a random picture according to their ethnicity and gender.
You should also be able to pick six pictures for yourself as well at the start of the game.
Also, I also want to assign a Boolean value to whether the character lives in a rural or urban environment. I want this to be chosen by the character.
Starting the Game
When starting the game, there should be a window that pops up, informing you that today is your first day of school. There should be a picture of your house in the background (which is, again, set in a array, and picked randomly similar to how the last names are drawn). When you press okay, the setting and background should also change to the school (which shouldn’t be randomized). Then, the first dialogue should begin. Your mom would be taking you to school, then give you a farewell message. Since your parents have their own picture as well, it should show on the dialogue box, on the left. The text will be on the right. There should be many choices of dialog from the parent according to their two personality traits. For example, if they have the “Angry” and “Uncaring” trait, you should receive, “Go! I’ll see you after school.” Below the dialogue, there should be colored text that shows how this affects your stats. Green text means +, Red text means -. In this case, there would be “Happiness -, Social openness -, Received the “Abused” special trait.” The “Abused” special trait would come up as a specific integer in int mcharspecialtrait1, whose original value is 0. Therefore, it would be set to a number that corresponds to the “Abused” special trait. This number (let’s say it’s 1) will affect future events. For example, if you happen to have a friend that’s abused as well, you might come up with this code:
System.out.println(“You meet with your friend " + studentid[25, 1] + " " + studentid[25,2]”.");
if mcharspecialtrait1 = 1 || mcharspecialtrait2 = 1 && friend’s charspecialtrait1 = 1 || charspecialtrait2 = 1 {
System.out.println(“You are suspicious that your friend is also a victim of abuse.”);
}
I plan to make the dialogue vary greatly according to your personal stats.
Now, for the school component, I plan to create many interactions. You should make a few friends on your first days, then meet everyone in the class. There should be about 20 generated students, or they should be held in a database. Their stats should all be held in an array, in integer form.
Quite a big project for my first project?
Hm… I’m going to make a bit smaller game.
I’ll just make it with two players, but without random variables.
But, can you please answer these questions?
How can I get text input from the player? What is the command for it?
How do I use an interface? I’m looking at the tutorial from Java, but it’s too basic.
How do I get information from using radio buttons and other things from the Swing GUI?
How can I play sound in my game?
How do I import sounds and pictures into my game?
How can I make those gradient bars so often used for stats in games?
How do I make it so that I can make my day-based engine?
How can I change the style of the GUI? Swing’s default GUIs are too plain and generic.
What is a library, and how does it relate to programming? I still don’t understand it.
Why does Java have to import classes such as java.util.Random?
What can I do to make a simple text-based adventure game? My first project should be more of a basic one, so how do I receive input?
How do I use Java’s 2D engine? I haven’t figured it out.
How do I make it so that my dialogue is affected by the stats instead of using a huge if-then block?
How do I make it so that my dialogue goes like this:
You meet up with - a) your friend, Dane.
b) your enemy,
c, d, etc.)
-without creating a huge if-then block?
Thanks for looking at all of this. I’d appreciate your response.