Help with text-based (Javascript) RPG

Post: #1
I am making a game at that i need help with. So far it is not very developed but i basically want it to be a text-based rpg. However i need help writing a code in html or javascript that will allow me to have random numbers show up when the player clicks to attack something. I need it so the player can attack and that then the monster attacks. If anyone could help i would really appreciate it. My e-mail is
Quote this message in a reply
Posts: 776
Joined: 2003.04
Post: #2
Considering you are using Geocities, may I suggest using a LOT more compression for your background picture, Abstract.JPEG? Its over 500KB (!)

In Javascript, to get a number between 0 and "max - 1":
var max = 4;
var num = Math.floor(Math.random() * max);

num will end up with 0, 1, 2 or 3.

To get a number between say, 10 & 20:
var max = 11; // there are 11 numbers between 10 & 20
var num = 10+Math.floor(Math.random() * max);
Quote this message in a reply
Posts: 469
Joined: 2002.10
Post: #3
I'd highly recommend using asynchrounous loads (like AJAX) for the dynamic interaction. This is dirt simple nowadays with many a Javascript lib.

15.4" MacBook Pro revA
Quote this message in a reply
Posts: 64
Joined: 2005.06
Post: #4
I actually got a text-rpg about half-written using php, but I realized that I should probably get other actual software done, so I stopped work, designed and put together my website and now working on Cocoa projects.

I should note that I was writing a text-adventure, so I had to design an entire parser system in php, which isn't terribly easy believe you me, when php is server-side only. Half the parser code was just how to respond to user input if the parser needed more information (keeping track of what the user put in, what function was originally called, ect).
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Odd javascript bug anthony 2 4,307 Nov 28, 2010 08:29 AM
Last Post: anthony
  ALT: Creating a text-based RPG?? endkiller 31 23,505 Dec 31, 2008 03:37 PM
Last Post: Hendo
  JavaScript Wise Druid 13 7,305 Oct 15, 2008 05:55 AM
Last Post: Wise Druid
  Text based RPG in Python pipposanta 7 9,523 Feb 27, 2008 09:10 AM
Last Post: pipposanta
  I Need Help Creating A Text Based MMORPG (aka MUD) GoldenLegacy 5 5,189 Dec 10, 2007 01:57 PM
Last Post: AndyKorth