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

Username:   Password: 
 RegisterRegister   
 Making a Game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
dymd3z




PostPosted: Mon Apr 30, 2007 8:08 am   Post subject: Making a Game

I have to make a game for an assignment but I'm stuck on changing a characters weapon. I'm trying to get it to work by pressing a number between 1 and 5 using a case structure to switch the characters equipped item whenever a number between 1 and 5 is chosen. I know I need a string variable to store the names of the items but i just cant get it to work xD
Sponsor
Sponsor
Sponsor
sponsor
Drakain Zeil




PostPosted: Mon Apr 30, 2007 3:37 pm   Post subject: RE:Making a Game

Based on what you've said, you should probably think about re-structureing your code.

You could store the strings in an array, for example

itemName(1)="knife"
itemName(2)="sword"
itemName(3)="gun"
etc...

Then have the character use weapon number _whatever_. You can easily do all this using structures, and have:
item(1).name = "gun"
item(1).damage=4000
item(1).blah=blah blah

And the character could have things like:
player.name="Jim the hobo"
player.weapon=1

and so on

here are plenty of tutorials on-site for structures
ericfourfour




PostPosted: Mon Apr 30, 2007 6:58 pm   Post subject: RE:Making a Game

Look up Zylum's bitwise operators tutorial. It contains one approach to this situation.
CodeMonkey2000




PostPosted: Mon Apr 30, 2007 7:17 pm   Post subject: RE:Making a Game

Or just use enumerated types. It's easier. If you aren't sure what that is, it's somewhere in 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  [ 4 Posts ]
Jump to:   


Style:  
Search: