Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 rpg with arrays
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
diablo




PostPosted: Fri Nov 05, 2004 1:22 pm   Post subject: rpg with arrays

i am making an RPG and my code is as follows:
%Land of Lost Souls RPG
var classes:array 1..4 of int
var class_classes:array 1..4,1..4 of string
var monsters:array 1..20 of string
var bosses:array 1..5 of string
var x:int
var health:int
var atk:int
var defence:int
var mag:int
var spd:int
var spcl:int
var inventory:array 1..10 of string
/*
class_classes(1,1):="soldier"
class_classes(1,2):="knight"
class_classes(1,3):="teutonic knight"
class_classes(1,4):="king's guard"*/


%choosing classes
put "welcome to the land of lost souls, mortal"
put "are you ready to die?"
put "choose your class of hero"
put "1=soldier, 2=mage, 3=crypt fiend, 4=rifleman"
get classes(x)<----(when i run it, is says that the"get classes(x)" line has no value


can you tell me what i did wrong?
i set my x-variable as an integer and my class array as integers as well
Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Fri Nov 05, 2004 1:28 pm   Post subject: (No subject)

The problem is that x has no value. This line of code:
code:
get classes (x)

Says to get a value from the user and store it in the array classes in the location x.

Try
code:
get x

To get the number. After that, I'm not sure what you are trying to do.
diablo




PostPosted: Mon Nov 08, 2004 8:06 am   Post subject: (No subject)

oh, well after the user enters a number, they will be given a class of character and specific stats to go along with it.
Delos




PostPosted: Mon Nov 08, 2004 9:42 am   Post subject: (No subject)

Ok...here's your problem:

code:

get classes (x)


You have a variable within a variable here. The subscript is not defined. You could either use:
code:

get classes (1)

for a for loop that will allow the User to select the value of each element in 'classes'.

BTW, please use [code] tags in the future. Thanks.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: