Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (589)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Help on GUI - Quick Start on: 2010-10-18 07:49:30
I've taken quite a bit of my time to look through the Java GUI tutorials, but I cannot find exactly what I want.  And what do I want?  Code for a window that has a frame that has save and a journal button that will initialize another window that will hold a uneditable text area that will hold text that comes from "journal.txt."  Also, I want a text box for entering text---the application I want to make is specified http://thsotusgames.wordpress.com/2010/10/10/12-learning-java-twin-days-4/---it is a text-based adventure game.

It's been taking awhile for me to get ahold of something, but I cannot find anything.  How do I create a frame that can hold two buttons that will be about quarter of an inch off of the right margin, a text area and text box that will hold text and I/O, and other things?  Many tutorials don't cover this area.

Plus, this is only an experimental game that I want to create.  This game is for learning experiences so that I can begin on my simulation game.  I figured that a text-based adventure game of a good size would be good to start me off in.  It covers I/O, file manipulation, GUI, scanners, and writing skills/creativity.  I want the end product to be a good, nice-sized game that will take about two hours or three hours to go through the entire thing.  Plus, I have designed the storyline so that it will have three possible endings, and multiple secrets to create re-playability.  I've already created the basic command line I/O--now, I want to convert it to a text-based GUI.

Can someone help me out here? 
2  Game Development / Newbie & Debugging Questions / Can someone point me to some basic Java tutorials? on: 2010-10-10 04:50:01
I'm having a hard time in the official Java tutorials, so can someone post a tutorial for:

- Reading and writing to text files

Thanks.
Or, perhaps, can you show me how to do it here?

Edit: Never mind, I have a new question.  How do you print only certain lines that you want?  For example, if I want to print line 4 to line 7 in dialogue.txt, how can I do this?
3  Game Development / Newbie & Debugging Questions / Re: Help with installing Eclipse on: 2010-10-07 20:12:41
How do I do this?
4  Game Development / Newbie & Debugging Questions / Re: How to create a simple encoder and decoder? on: 2010-10-07 09:42:30
Perhaps I am.
5  Game Development / Newbie & Debugging Questions / Re: Help with strings and if statements. on: 2010-10-07 03:16:50
There is no Java class at my school.  Er...
6  Game Development / Newbie & Debugging Questions / Re: How to create a simple encoder and decoder? on: 2010-10-07 03:15:11
The thing is, I don't understand the official tutorials.  This is why I'm asking here--the tutorials jump ahead too fast.
7  Game Development / Newbie & Debugging Questions / Re: How to create a simple encoder and decoder? on: 2010-10-06 11:06:36
I have no idea what you are talking about, sadly.
8  Game Development / Newbie & Debugging Questions / How to create a simple encoder and decoder? on: 2010-10-06 10:38:46
Hey guys, I've been posting many, MANY threads on this forum, but I'd like to ask another question:

How do I make an encoder for my game and decoder, or rather, how do I read, write, and encode files?

I want to make this as my key for Twin Days, my personal gaming project to create a text-based adventure written in Java.
As there is a lot of dialogue in an adventure game, is there a way I can store lines and strings inside of a text file, then have my program read it, decode it according to a switch block, then store it inside an array or variable in my program?  I don't want to increase the file size by coding all of the dialogue in Java.

By the way, I also want to create an encoder program that will take text and numbers and create a text file that I can decode into the game. 
I thought about doing this through using a counter to count the line number I would need to import next.  I would run this method every time I imported a line.  After importing the line (which will be a string of encoded characters, of, let's say, eph, then turn it all back one character, which will make the word "dog"), I would uncode the code and store it as a line in an array list.  After using it, I would release it from the array list.

This seems very complicated to me.  How do I even write a file, and how do I read it according to line?
How do I create a string-driven switch statement block?


9  Game Development / Newbie & Debugging Questions / Re: Help with strings and if statements. on: 2010-10-05 22:37:24
Please expand on this.  I don't know how to use the command you are trying to show me.
10  Game Development / Newbie & Debugging Questions / Re: Help with strings and if statements. on: 2010-10-05 16:38:54
Thanks for taking the time to address me.
11  Game Development / Newbie & Debugging Questions / Re: Help with strings and if statements. on: 2010-10-05 10:46:32
Ah, I see.

By the way, this will be used for a text-based game I call "Twin Days."  It will be a simple text based adventure.
12  Game Development / Newbie & Debugging Questions / Re: Help with strings and if statements. on: 2010-10-05 10:33:03
So, I'll just change the variable to the name "yORn."


Thank you, but can I ask some more?

How does the method yesOrNo import the variable yesOrNoInt without having it in the parenthesis?
Wait, so Java performs the two methods at the same time?
13  Game Development / Newbie & Debugging Questions / Re: Help with strings and if statements. on: 2010-10-05 10:27:05
How about the whole code?


package twindays;

import java.util.Scanner;

public class Main {
    private static int yesOrNoInt = -1;
    public static void main(String[] args) {
        System.out.println("You have reached a yes or no choice.");

        yesOrNo(yesOrNoInt);
        System.out.println(yesOrNoInt);
        yesOrNoMessage(yesOrNoInt);

       
           

    }

    public static int yesOrNo(int yesOrNoInt){

        System.out.println("Please input (y)es or (n)o.");
        Scanner scan = new Scanner(System.in);
        String yOrN = scan.nextLine();
        if (yOrN.equals("y")) {
            yesOrNoInt = 1;
        }
        if (yOrN.equals("n")) {
            yesOrNoInt = 0;
        }
        return yesOrNoInt;
    }
    public static void yesOrNoMessage(int yesOrNoInt)  {
                    if (yesOrNoInt == 1) {
                    System.out.println("You have chosen yes.");
                    }
                    if (yesOrNoInt == 0) {
                    System.out.println("You have chosen no.");
                    }
        }
}


The output for the program when I put "y" in is this:

You have reached a yes or no choice.
Please input (y)es or (n)o.
y
-1
14  Game Development / Newbie & Debugging Questions / Re: Help with strings and if statements. on: 2010-10-05 10:18:12
My code still doesn't work, even with the == true statement.
15  Game Development / Newbie & Debugging Questions / Help with strings and if statements. on: 2010-10-05 10:02:12
How can I check if "y" is true?

My current code is:  if (yOrN == null ? "y" == null : yOrN.equals("y"))

How can I check if y is true?


___________________________________________________


Check out Thsotus Games http://thsotusgames.wordpress.com/.
16  Game Development / Newbie & Debugging Questions / How to get input? on: 2010-10-04 20:07:14
I really don't understand the input commands.

Can someone give me a short tutorial to use them?  I need definitions.

By the way, what is the "try" and "catch?"

Edit:  Never mind, I've found a great tutorial at <http://www.java-made-easy.com/java-scanner.html>.

I've named my independent indie game developer studios "http://thsotusgames.wordpress.com/."
17  Game Development / Newbie & Debugging Questions / Help with installing Eclipse on: 2010-10-04 19:55:07
Hi, guys, I've downloaded the 64-bit version of Eclipse.

But, I'm having trouble installing it.

It says that I need to have "javaw.exe" in the directory, but I've already tried bringing the JDE folder into the Eclipse directory.

How do I get it working?
18  Game Development / Newbie & Debugging Questions / Lots of basic questions to help my understanding of Java, and my personal proj. on: 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.


Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

trollwarrior1 (27 views)
2014-11-22 12:13:56

xFryIx (69 views)
2014-11-13 12:34:49

digdugdiggy (48 views)
2014-11-12 21:11:50

digdugdiggy (42 views)
2014-11-12 21:10:15

digdugdiggy (36 views)
2014-11-12 21:09:33

kovacsa (60 views)
2014-11-07 19:57:14

TehJavaDev (64 views)
2014-11-03 22:04:50

BurntPizza (62 views)
2014-11-03 18:54:52

moogie (77 views)
2014-11-03 06:22:04

CopyableCougar4 (77 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!