Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (707)
Games in Android Showcase (208)
games submitted by our members
Games in WIP (781)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Lots of basic questions to help my understanding of Java, and my personal proj.  (Read 2004 times)
0 Members and 1 Guest are viewing this topic.
Offline Thsotus

Senior Newbie

« Posted 2010-10-03 23:00:14 »

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.

Hey!  Visit the blog (and current home website) for my studios,
Thsotus Games,

My current and most recent project is called "Twin Days."
Offline bobjob

JGO Knight

Medals: 12
Projects: 4

David A M

« Reply #1 - Posted 2010-10-04 01:46:03 »

you should target each question, in its own application, a simple "hello world" for each concept.

It would take a long time for someone to answer your questons, and in that time they could make an engine for themselves.

In all honesty it would be best to go through a Java tutorial website, and follow the lessons in order. It will teach you more than a conversation over the internet, and give you the confidence to tackel all of your future concerns.

Offline zoto

Senior Devvie

Medals: 4

« Reply #2 - Posted 2010-10-04 05:43:19 »

You should look into Classes, this should answer a lot of the questions you have. A simple structure for this program would be to define a Class for Person with a name, parents etc then extend Person as a Student, Teacher, or Parent. This way wont be as good if you want to add advanced features like a way for students to grow up and become teachers, or parent but it should work easily to get you started.

For a small list of names there is no real reason to use a database, why not store the names 1 per line in a text file then just load the file into a String array. When a name is used remove it from the list of available names so you don't have non related students with the same last name.

I would wait on the sound and GUI problems until you get the logic of the game working in a text game as they will make a lot more sense after you know about working with Classes.

You can read console input from the InputStream; here is one way to do that.

public class InputTest {

    public static void main(String[] args) {
            BufferedReader reader = new BufferedReader( new InputStreamReader( ) );
            System.out.println("What is your name?");
            String name = reader.readLine();
            System.out.println("Hello " + name);
        } catch (Exception e) {


I don't understand what you mean by this question although I bet learning more about Classes will probably solve it.
How do I use an interface?  I'm looking at the tutorial from Java, but it's too basic.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Nate

« JGO Bitwise Duke »

Medals: 167
Projects: 4
Exp: 14 years

Esoteric Software

« Reply #3 - Posted 2010-10-04 08:06:08 »

I suggest reading this online book:

Offline gouessej
« Reply #4 - Posted 2010-10-04 13:01:34 »


Rather use the class java.util.Scanner to read console input:

Offline Draps

Senior Newbie

« Reply #5 - Posted 2010-10-06 01:44:08 »

My God man, What you are asking is way too over your head.
it appears that you really dont have an idea of much structure and how certain things work in code.

im hoping your not just doing this because you had this bet with a friend that you could make your idea into a game.

to do you project it will take longer than a month to propperly learn how to struture your code and how to do basic manipulation of data and depending on your dedication 2D graphics.

i would suggest:
If your doing this because you think it will be easy to create a game and show it off to your friends etc
- Probberly quit or atleast inform yourself this is a big task and make something smaller (much smaller, perhaps a maze game)

If you are really into starting to learn java
- Read through tutorials, other peoples code, and definatly take on a smaller project. Write this idea down somewhere for the future when you have a more in depth knowledge of Java and its concepts.

sorry if i sound like tottal pain in your ass.
just this is a big ask from a beginner.
Offline Gudradain
« Reply #6 - Posted 2010-10-06 02:29:26 »

Hahaha. A funny fellow right here Smiley. A lot of enthusiasm and I like it. But there is just a problem, you are asking us question on ''How to make a game'' when you should ask question about ''How do I learn java''.

But don't worry, there is a good way to get both of them together. Learn my making small game. I repeat : small game. For each point, that you need help try to make a situation where you use it. If it can be a small game it's great, if not just make a simple test code that help you to understand really how the thing work. By the way, there is no other way to understand how code work that to run it and use it. Book are... well theory is not enough.

So for each of your question, make a small program to see what it give. I made some game with a couple of thousand of line of code and I still do it every day. Start small think big.

Anyway, just a tip like that. Don't try to make your project at the same time that you learn. Because you don't know enough you will have to restart from the beginning when you will know enough. So don't lose your time thinking about the general idea and how everything fit together. Well that's just how I think Smiley
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Galdo (400 views)
2017-01-12 13:44:09

Archive (555 views)
2017-01-02 05:31:41

0AndrewShepherd0 (1022 views)
2016-12-16 03:58:39

0AndrewShepherd0 (952 views)
2016-12-15 21:50:57

Lunch (1084 views)
2016-12-06 16:01:40

ral0r2 (1317 views)
2016-11-23 16:08:26

ClaasJG (1413 views)
2016-11-10 17:36:32

CoffeeChemist (1405 views)
2016-11-05 00:46:53

jay4842 (1489 views)
2016-11-01 19:04:52

theagentd (1250 views)
2016-10-24 17:51:53
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!