Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Input commands for specific keys {DBC}

Author
Message
Seraf
20
Years of Service
User Offline
Joined: 22nd Feb 2004
Location:
Posted: 8th Jun 2006 21:19
Hello, for my Text RPG that I'm working on I've finally made it to the point where I'm ready to start coding a battle system. The battle system I'm going to use is a pretty basic one where it displays on the screen:

Press the following keys to perform the given tasks:

1. Attack
2. Ability
3. Magic
4. Defend
5. Flee


So by pressing the key {1} for example that tells the game that the player is attacking the enemy creature. How would I make it so that the game can detect if the key {1} was pressed?

if _______()=1 then__________

What would go there?
Bahamut
19
Years of Service
User Offline
Joined: 4th Nov 2005
Location: Brighton
Posted: 8th Jun 2006 22:06 Edited at: 8th Jun 2006 22:07
You'll have to use keystates. Look them up in one of the DB examples. There may be some pics out on the net if you're lucky. Each button on the keyboard is assigned a number called a scancode.

if keystate(#)=1 then do stuff.

# is the scancode of the key.

stuff is what you want to happen. I've no idea how your program works, so I can't help you there.

I can never remember any of them, but I have a feeling that numbers have the corresponding scancode.

Hope that helps

IceBound Melodic rock/metal band with loads of lead guitar, clean female vocals, and more guitars! What more could you want?
X Trade
20
Years of Service
User Offline
Joined: 19th Feb 2004
Location: near bristol, UK
Posted: 8th Jun 2006 22:10 Edited at: 8th Jun 2006 22:11
you want something like
IF inkey$() = "1" then ____(etc)____

the inkey$() command returns the current key pressed, as a string (as text), which is why you need the speechmarks.

its all in the help somewhere if you bothered to look

There is a command also to get the input like a command inputline
to do this, it works slightly differently

input "question? "; out

where out is the name of your output, and the text in the speechmarks is the command line/question that will appear.

if you wanted something for the first method, i would suggest



edit:
yeh ok so he got there first! but you only really need to use keystate if you expect the player to be pressing more than one key at a time

www.AoFP.co.uk

Login to post a reply

Server time is: 2024-11-27 17:39:27
Your offset time is: 2024-11-27 17:39:27