Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (516)
Games in Android Showcase (123)
games submitted by our members
Games in WIP (577)
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  
  Fight For Arcadia (Text Based)  (Read 2338 times)
0 Members and 1 Guest are viewing this topic.
Offline EatenByAGrue

Junior Duke


Medals: 3



« Posted 2011-09-18 22:49:37 »

Hello JGO,

I've been learning Java (and programming in general) for the last few weeks. I started working on a little text-based game, to put the newly learned things to a use. Doing this, I managed to finish a little text-based Hack 'n Slay (if you can call it like that ... ^^).

You can download the latest version here (You'll need to run it from console/terminal via "java -jar FFA.jar"):

NEW (10/07/11) - V. 0.9
http://dl.dropbox.com/u/40409752/FightForArcadia.zip

Please feel free to crit & comment Wink

Greetings,
EatenByAGrue

It is pitch black. You are likely to be eaten by a grue.
Offline Skarion
« Reply #1 - Posted 2011-09-19 08:46:48 »

Cute game!

Events are randomised right?

Wish to get help with a simple GUI?
Offline EatenByAGrue

Junior Duke


Medals: 3



« Reply #2 - Posted 2011-09-19 11:38:44 »

Thank you Skarion Smiley

Yes the events are currently (pseudo)random. But I intend to change that, as it makes more sense that you can buy Items all the time. As I also try to create a (small) storyline the random events wouldn't really work aswell I guess. But I still want to have the fight against randomized enemies... Basically every random decision in the game is decided by dice (similar to D&D and Warhammer I guess).

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  
import java.util.Random;

public class Dice
{
   Random rnd = new Random();

   public int rollDice(int noOfDie, int sidesOfDie)
   {
      int total = 0;      // the total sum of all thrown dice
      int die;         // the number of one die
      int counter;      // keeps track of how many dice have been rolled
     
      if(sidesOfDie < 2){    // Assures that the die has at least two sides
         sidesOfDie = 2;
      }
      if(noOfDie < 1){      // Assures that at least one die gets rolled
         sidesOfDie = 1;
      }
     
      for(counter = 0; counter < noOfDie; counter++)   {
         die = rnd.nextInt(sidesOfDie);               // generate random number between 1 and sidesOfDie
         total += die;                           //     and add that number to the total
      }
      return total;
   }
}


Of course any help would be appreciated. I am reading about GUI at the moment, but I thought I'd rather learn more about the basics first before I start getting into GUIs. Smiley

Greetings,
EatenByAGrue

It is pitch black. You are likely to be eaten by a grue.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Skarion
« Reply #3 - Posted 2011-09-19 13:39:26 »

I kind of like the text and the general feeling! Smiley

Here is a very simple and quickly made GUI with comments on how to use it!



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  
package test;

import java.awt.Dimension;
import javax.swing.*;

//By Skarion
public class ScWindow extends JFrame{

   private JPanel view;
   
   public ScWindow(int width, int height){
      setTitle("Fight for Arcadia");
      Dimension d = new Dimension(width, height);
      setSize(d);
      setPreferredSize(new Dimension(d));
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   }
   public void setContentPane(JPanel view){
      super.setContentPane(this.view = view);
      pack();
      setVisible(true);
   }
   
   public static void main(String[] args){
      //Example of how to use these classes.
      char newLine = 10;
      View v = new View();
      v.setTitle("Main menu");
      v.setText("FIGHT FOR ARCADIA (now in HD)"+newLine+"Copyright (c) 2011 Robert M."+newLine+"Version 0.8 - 15 Sep 2011");
      v.setEvents(new Event("New Game"), new Event("Load Game"),new Event("Help"),new Event("Exit"));
      ScWindow s = new ScWindow(300,400);
      s.setContentPane(v);
   }
}


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  
package test;

import java.awt.*;
import java.util.HashMap;
import javax.swing.*;
//By Skarion

public class View extends JPanel{

   private JLabel title;
   private JTextArea text;
   private JPanel south;
   private static int MAXEVENTS=6;
   
   public View(){
      super(new BorderLayout());
      title = new JLabel();
      title.setFont(new Font("Verdana",Font.PLAIN,20));
      text = new JTextArea();
      text.setEditable(false);
      text.setBackground(null);
      south = new JPanel(new GridLayout(MAXEVENTS,1));
      Dimension d = new Dimension(200,30*MAXEVENTS);
      south.setSize(d);
      south.setPreferredSize(d);
      add(title, BorderLayout.NORTH);
      add(text, BorderLayout.CENTER);
      add(south, BorderLayout.SOUTH);
   }
   
   public void setTitle(String s){
      title.setText(s);
   }
   public void setText(String s){
      text.setText(s);
   }
   public void setEvents(Event... events){
      south.removeAll();
      if(events.length>MAXEVENTS){
         System.out.println("You need to declare a larger MAXEVENTS to do this, else it will get ugly!");
      }
      for(int i = 0;i<events.length;i++){
         events[i].setSelected(i);
         JButton event = new JButton(events[i].getText());
         event.addMouseListener(events[i]);
         south.add(event);
      }
      updateUI();
   }
   
}


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  
package test;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
//By Skarion
public class Event extends MouseAdapter{

   private int value;
   private String text;
   //private Model model;
   
   public Event(String text /*, Model model*/){
      //Send in the model here for usage.
      //this.model = model;
      this.text = text;
   }
   
   public String getText(){
      return text;
   }
   
   public void setSelected(int value){
      this.value = value;
   }
   
   public void mousePressed(MouseEvent e){
      //Tell model to activate this event.
      //model.eventFired(value);
   }
}


If there is anything you wonder or would like to know, post and I can see if I can fix it.
Offline EatenByAGrue

Junior Duke


Medals: 3



« Reply #4 - Posted 2011-09-21 11:01:46 »

Thank you very much I'll look into that. At the moment I'm still struggling with the basics of OOP. I'll try to make the game work first before I try to create a GUI Smiley

Greetings.

It is pitch black. You are likely to be eaten by a grue.
Offline Skarion
« Reply #5 - Posted 2011-09-21 19:07:43 »

Thank you very much I'll look into that. At the moment I'm still struggling with the basics of OOP. I'll try to make the game work first before I try to create a GUI Smiley

Greetings.

If you wonder anything, just ask.

The code above should easily be used with the code you got (at least the way I think you've programmed your game. Thought that said code would be a nice way to get a simple GUI up and running so you don't get lost while doing the rest of your game. Smiley
Offline max1238

Junior Duke


Projects: 3



« Reply #6 - Posted 2011-09-28 12:23:40 »

There is a game similar to the DOS era, there was a DOS-horror game, play it like watching horror fiction. Although only text, but very attractive.
Offline EatenByAGrue

Junior Duke


Medals: 3



« Reply #7 - Posted 2011-10-07 13:30:34 »

There is a game similar to the DOS era, there was a DOS-horror game, play it like watching horror fiction. Although only text, but very attractive.

Yes indeed. There are many games like this (but all way more complicated than mine Smiley) for example Zork, or 'Hitchhiker's Guide through the Galaxy' (which you can play here: http://www.douglasadams.com/creations/infocomjava.html) by Infocom. I really like them I don't know why. Especially the humor in the Infocom games was really entertaining.

---

Update 10/07/11 - Version 0.9:

I finally managed to update the game. It took me longer than expected because I had so many other things to do :/
Anyways, I shortened the feedback during fight, included items ... etc. but mainly I improved my code Smiley

I think it's a bit harder than before because I changed some of the enemies but I'm gonna fix that soon.

Please feel free to crit,
Greetings

It is pitch black. You are likely to be eaten by a grue.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

TehJavaDev (32 views)
2014-10-27 03:28:38

TehJavaDev (26 views)
2014-10-27 03:27:51

DarkCart (41 views)
2014-10-26 19:37:11

Luminem (22 views)
2014-10-26 10:17:50

Luminem (27 views)
2014-10-26 10:14:04

theagentd (33 views)
2014-10-25 15:46:29

Longarmx (61 views)
2014-10-17 03:59:02

Norakomi (58 views)
2014-10-16 15:22:06

Norakomi (47 views)
2014-10-16 15:20:20

lcass (43 views)
2014-10-15 16:18:58
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!