Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
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  
  command line  (Read 697 times)
0 Members and 1 Guest are viewing this topic.
Offline Javec

Senior Newbie





« Posted 2007-11-21 19:46:36 »

How you implement "commands" in a console based game? I though about some sort of parse(String input) method to take in input and "guess" what the user wishes to do. However, differrent commands are available depending on whch stage of the game you are? How to go round this?

Thanks.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2007-11-21 20:04:51 »

This is a science in itself.

Parsing the command is not that hard, but interpreting is.


There are RPG-games now that can parse commands like:
"Drop the yellow book in my pocket"
but it will be years of coding before your interpreter gains any remotely usable understanding-capabilities.


It's far easier to pick an item and show some options.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Javec

Senior Newbie





« Reply #2 - Posted 2007-11-21 20:10:31 »

I see, well, my game is cards.

What you suggest I use of input? Is a console game for now.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #3 - Posted 2007-11-21 20:19:09 »

Think of it like a menu-structure.

You first select what to do (select, drop, bet) then pick an action, if there are still options left, let the player choose. Just go deeper and deeper, until you find out enough about what the player wants.

You have to code this behaviour in a tree-like structure.
You could process the input as "5.3.4.2.1.1"
(user picked 5, then 3 then 4 then 2 then 1 then 1)
The user ofcourse won't be seeing these numbers.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline broumbroum

Junior Member





« Reply #4 - Posted 2007-11-21 23:46:11 »

Command line interface is already available as the default System.in. While running in your main loop, simply call System.in.readLine() to get the user command line input.
The user will press the "enter" or "return" keystroke to validate, while the System.in.readLine() while block until that key stroke is pressed. Cheesy

::::... :..... :::::: ;;;:::™ b23:production 2006 GNU/GPL @ http://b23prodtm.webhop.info
on sf.net: /projects/sf3jswing
Java (1.6u10 plz) Web Start pool
dev' VODcast[/ur
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.

xsi3rr4x (36 views)
2014-04-15 18:08:23

BurntPizza (32 views)
2014-04-15 03:46:01

UprightPath (47 views)
2014-04-14 17:39:50

UprightPath (30 views)
2014-04-14 17:35:47

Porlus (47 views)
2014-04-14 15:48:38

tom_mai78101 (68 views)
2014-04-10 04:04:31

BurntPizza (128 views)
2014-04-08 23:06:04

tom_mai78101 (228 views)
2014-04-05 13:34:39

trollwarrior1 (193 views)
2014-04-04 12:06:45

CJLetsGame (200 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!