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

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




PostPosted: Tue May 31, 2011 9:07 pm   Post subject: Player Controls

What is it you are trying to achieve?
<I'm trying to make an option in my bomberman game so that you may change the controls of a player because certain people have certain preferences. I was just wondering if somebody could give me some base code and/or explain to me how to do this since I have tried and failed miserably so I'm am turning to the good people of comsci for help>
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Tue May 31, 2011 11:33 pm   Post subject: RE:Player Controls

Right now, you probably have some code that looks like the following, assuming you're using Input.KeyDown():

Turing:

if keys ( 'a' ) then
    % go left because player pressed A
end if


You should change it to:

Turing:

if keys ( control_left ) then
    % go left because player pressed left
end if


Then you need to have a separate settings file that your program can read. Then you need a way for a human to change the file. Either it should be possible to change the file manually (human-readable), or your program should be able to change it for the user (or both).
Raknarg




PostPosted: Wed Jun 01, 2011 10:19 am   Post subject: RE:Player Controls

If you wanted to have a choice between arrow keys and chars, you would use 2 if statements.
Turing:

if key (KEY_LEFT_ARROW) or key (KEY_RIGHT_ARROW)  or key (KEY_UP_ARROW)  or key (KEY_DOWN_ARROW)  then
     % set keys here as arrow buttons
else
     % set keys here as letters
end if

Chars and KEY_LEFT_ARROW aren't interchangable (as far as I know), so its a bit more difficult to use them at the same time.
Raknarg




PostPosted: Wed Jun 01, 2011 10:21 am   Post subject: RE:Player Controls

You could even make it simple and ask the user for their key preference (either arrows or WASD).
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: