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

Username:   Password: 
 RegisterRegister   
 RPG Items
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
rownale




PostPosted: Wed May 31, 2006 7:23 am   Post subject: RPG Items

I am trying to make an rpg and it will have lots of items. I dont know the best way to program it though. So far im using this.... (I know its probably a really bad way to do it.)

code:

%This is the loot subprogram

var mindamage : int
var maxdamage : int
var sellvalue : int
var item_number : int
var item_description : string
var item_name : string
var loot_roll : int := Rand.Int (1, 100)

procedure item_1
    item_name := "Short Sword"
    item_description := "This sword is unsharpened, rusty and the handle is partially broken."
    mindamage := 3
    maxdamage := 5
    sellvalue := 4
end item_1

procedure item_2
    item_name := "Hatchet"
    item_description := "A small axe, barely powerful enough to cut through a small branch"
    mindamage := 2
    maxdamage := 4
    sellvalue := 2
end item_2

if loot_roll >= 1 and loot_roll <= 19 then
    item_1
    put "You pick up ", item_name, "!"
elsif loot_roll >= 20 and loot_roll <= 100 then
    item_2
    put "You pick up ", item_name, "!"
end if


You can ignore the stuff at the bottom. Thats not the real way itll work really. I just need help with the procedure part. Is there a better way to do this??
Sponsor
Sponsor
Sponsor
sponsor
Albrecd




PostPosted: Wed May 31, 2006 7:36 am   Post subject: (No subject)

Most definatly. Check out Cervantes' tutorial on Classes (part 1, part 2, and part 3) In which he covers pretty much this exact topic.
sylvester-27




PostPosted: Wed May 31, 2006 7:41 am   Post subject: (No subject)

well...all it does so far is tell u what u pick up
[You pick up a Hatchet!]
Yes there is a way way simpler method of having the comp output this. it is called "put" statements which i am sure you are familiar with. You can't really do anything with the program untill you add more things. start with the actual adventure mode and get some basics down like moving the character and background.
rownale




PostPosted: Wed May 31, 2006 2:55 pm   Post subject: (No subject)

Thanks Albrecd. I will try to learn classes but they look really confusing. Im only in GR10 Compsci and we have only just learned colour. We havent learned procedures or classes or anything cool. But i will try to learn classes on my own..

In response to syvelster, I cant have something that just says you pick up a hatchet because I want every item to have different variables like gold sell price, min wep damage, max wep damage, Strength bonuses, armor, etc. Some items will share the same variables, (eg. Hatchet uses sell price and damage as does short sword.) others wont (eg. Emerald Gem has health bonuses but the hatchet wont...)
Basically it has to be more in depth than "You pick up hatchet"....
Cervantes




PostPosted: Wed May 31, 2006 6:10 pm   Post subject: (No subject)

rownale wrote:
Thanks Albrecd. I will try to learn classes but they look really confusing. Im only in GR10 Compsci and we have only just learned colour. We havent learned procedures or classes or anything cool. But i will try to learn classes on my own..

Excellent! Learning outside of the classroom is arguably a better way to learn.

sylvester-27 wrote:

well...all it does so far is tell u what u pick up
[You pick up a Hatchet!]
Yes there is a way way simpler method of having the comp output this. it is called "put" statements which i am sure you are familiar with. You can't really do anything with the program untill you add more things. start with the actual adventure mode and get some basics down like moving the character and background.

That's not good advice at all. First, hardcoding a
code:
put "[You pick up a Hatchet!]"

gets you nowhere. What's more, there is plenty he can do with the program before he starts adding graphics and making the adventure and the background and all those other fancy things that mean squat to the meat of the program: the engine.
Clayton




PostPosted: Wed May 31, 2006 7:21 pm   Post subject: (No subject)

you could use a folder to store all information on an item and using file I/O get the information you need in a class(best way) or procedure(decent way)Very Happy
[Gandalf]




PostPosted: Wed May 31, 2006 9:56 pm   Post subject: (No subject)

Umm... As much as I appreciate learning classes early on, I really don't think rownale is ready for them in Turing. How about learning about arrays, records, functions, file I/O, and a bunch of other stuff first? You can do this by following the general order of the Turing Walkthrough.
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  [ 7 Posts ]
Jump to:   


Style:  
Search: