Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
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 / Re: loop help on: 2004-10-12 00:49:38
well I added a keylistener, but get the same results. also I've been looking around the net at problems similar to mine and they don't seem to have working solutions to them. Is there not something that can wait for user input in a loop? Huh
2  Game Development / Newbie & Debugging Questions / Re: loop help on: 2004-10-11 01:55:16
Quote
At the very end of the while loop you just add this line (just before the final closing braket):

first_player=!first_player;

first_player gets the value of the opposite of first_player. So... you get alternating true/false there.


um i already have that there? or if you mean between the two } at the end, i get the same results.
3  Game Development / Newbie & Debugging Questions / loop help on: 2004-10-11 00:37:04
I've made a text based turn based fighting application game. You fight an enemy until your enemy or your life points run out. It works perfectly as a plain application, but I'm running into problems converting it to swing, so I can make it look nice with a GUI. I'm having the text display in a JTextArea. Problem is when it loops it never gives me the chance to attack, it only allows the enemy to attack until my life points reach 0. What can I do to have it stop when its my turn, so I can type in my attack?
Here is the part of the code that is creating this problem:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
               while(!gameover) //loops until gameover
           {
                   if(first_player) //what happens if the player or eggman is chosen first
                  {
                     players[r] = 0; //eggman's turn
           
                    //attack damages
                    int E_attack1 = 5;
                     int E_attack2 = 10;
                     int E_attack3 = 15;
                     
                     //attacks in an array
                    int[] attacks = { E_attack1, E_attack2, E_attack3 };
                     int A = attacks.length;
                     int p = (int) (Math.random() * A); //makes the attacks random

                     //the effects of what the damages will do to the Player's Life Points
                    if(attacks[p] == E_attack1)
                    {
                     
                     Player_LP -=E_attack1;
                     
                     }
                     else
                     if(attacks[p] == E_attack2)
                     {
                     
                     Player_LP -=E_attack2;

                     }
                     else
                     if(attacks[p] == E_attack3)
                     {
                     
                          Player_LP -=E_attack3;
                     
                      }
                      text.append("Eggman does "+ attacks[p] + " damage." + "\n"); //the print out of the attack and damage
             
                      }
                      //players turn
                     else
                     {
                       
                       //players attack damages
                      int attack1 = 5;
                       int attack2 = 10;
                       int attack3 = 15;
                       text.append( "Choose attack1 , attack2, or attack3: "  + "\n"); //gives player a choice of attacks
                      inputField.getText(); //gets the text
                      text.getText(); //gets the text from the text area

                       //what happens when one of the attacks is chose
                      if(text.equals("attack1"))
                      {
                        //the effect of the attack on Eggman's life points
                      Eggman_LP -=attack1;
                       //the print out of the attack and the damage
                      text.append( "\n" + "You attack with attack1 causing " + attack1 + " damage to Eggman."+"\n");
                       }
                       else

                      if (text.equals("attack2"))
                     {
                            Eggman_LP -=attack2;
                            text.append( "\n" + "You attack with attack2 causing " + attack2 + " damage to Eggman."+"\n");
                     }
                     else
                     if(text.equals("attack3"))
                    {
                         Eggman_LP -=attack3;
                         text.append( "\n" + "You attack with attack3 causing " + attack3 + " damage to Eggman."+"\n");
                    }
                    }
                    //make it turn base
                   first_player = !first_player;
                    //how to determine gameover
                   if (Player_LP <=0)
                   {
                       gameover = true;
                       text.append("Eggman Wins");
                   }
                   else
                   if (Eggman_LP <=0)
                  {
                        gameover = true;
                        text.append("You Win");  
                 
                  }
            }

And the game appears like this when I run it:

Quote

What is your player name: DKN
You chose DKN as your player name.
Your enemy will be Eggman.
You and your opponent will have 100 life points.
The player to lose all of their life points loses the game.
You go first
Choose attack1 , attack2, or attack3:
Eggman does 10 damage.
Choose attack1 , attack2, or attack3:
Eggman does 5 damage.
Choose attack1 , attack2, or attack3:
Eggman does 5 damage.
Choose attack1 , attack2, or attack3:
Eggman does 10 damage.
Choose attack1 , attack2, or attack3:
Eggman does 5 damage.
Choose attack1 , attack2, or attack3:
Eggman does 5 damage.
Choose attack1 , attack2, or attack3:
Eggman does 5 damage.
Choose attack1 , attack2, or attack3:
Eggman does 5 damage.
Choose attack1 , attack2, or attack3:
Eggman does 15 damage.
Choose attack1 , attack2, or attack3:
Eggman does 5 damage.
Choose attack1 , attack2, or attack3:
Eggman does 15 damage.
Choose attack1 , attack2, or attack3:
Eggman does 5 damage.
Choose attack1 , attack2, or attack3:
Eggman does 5 damage.
Choose attack1 , attack2, or attack3:
Eggman does 15 damage.
Eggman Wins
4  Game Development / Newbie & Debugging Questions / game help on: 2004-09-30 17:29:56
I started to create this application turn based fighting game, but I'm not sure what I could do to record the attacks, so once a player reaches 0 life points then it's game over.
5  Game Development / Newbie & Debugging Questions / Re: Books on: 2004-06-04 23:59:20
Ok I'll keep in mind on that book, but I rather buy a book rather than print tutorials(wastes to much ink and thats expensive).
6  Game Development / Newbie & Debugging Questions / Books on: 2004-06-04 17:14:11
Ok I know there are a ton of tutorials online for java, but I have problem a with computer screens where if I stare at it for a while I get very bad headaches that causes me to go to sleep. So I am asking what are the best books for learning Java and Java 2d gaming. Because I want to one day create a 2d rpg like Zelda and those kinds of games.
7  Game Development / Newbie & Debugging Questions / Sprite Newbie on: 2004-06-03 20:56:57
I want to create a sprite class on my own, where I can have an object on a screen move up, down, left and right with the keypad. Is there a tutorial out there that teaches the basics of doing this in detail.
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.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (25 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
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!