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

Username:   Password: 
 RegisterRegister   
 About Keyboard Use...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TheLostSoul




PostPosted: Thu May 13, 2004 8:12 am   Post subject: About Keyboard Use...

I Know How To Do The Whole

(KEY_UP_ARROW) And Such...And I Am Messing Around In Computer Class To Make A Little Modified Etch-And-Sketch Razz

Anyhow, I Was Wondering If There Is A Way To Clear The Screen, Like...If The User Presses The Key 'A' Or Something....Any Help On This Would Be Apreciated.

If I Posted This In The Wrong Spot, Sorry...Just Don't Have Much Time Of Class Left Today And I Was In A Panic And Very Confused Lol.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu May 13, 2004 8:21 am   Post subject: (No subject)

code:

var c:string(1)

if hasch then
     getch(c)
     if c="a" then
          cls
     end if
end if


stick that into a loop somewhere
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
gamer




PostPosted: Thu May 13, 2004 11:10 pm   Post subject: Why "char (variable)" does not work?

Hi all. I have got a question is ask. There is a lot of games out there which allow players to set their own controls. I myself have tried doing that too:
var x,y,go:int:=1
var up :string
var char :array char of boolean
if *someting* then
up :='w'
elsif *something* then
up:=KEY_UP_ARROW
end if
loop
cls
drawfillbox (x,y,x+50,y+50,black)
if char (up) then
x:=x+go
end if
end loop

My problem is, I get this error saying someting like "array subscipt out range" for this line "if char (up) then". However, when I altered it abit simply to "if char ('w') then" or "if char (KEY_UP_ARROW) then", this worked perfectly fine. Does anyone know why the first situation does not work? I really need to know this because I am planning to use variables to store the players control. Thankyou.
Mazer




PostPosted: Fri May 14, 2004 6:24 am   Post subject: Re: Why "char (variable)" does not work?

gamer wrote:
var char :array char of boolean

I didn't read the whole thing, but there's one problem at least. You want to name your variable something else. Call it "chars" or "key" or something. Also you didn't call Input.KeyDown.
gamer




PostPosted: Fri May 14, 2004 10:25 am   Post subject: (No subject)

ok yea my mistake cuz i was busy and gtg reli soon
fine now make it var chars:array char of boolean
n add Input.KeyDown(chars)

so my main problem is, how come i cant use a variable for the chars...like chars (up) doesnt work, while ONLY chars ('w') works....y is that?
Tony




PostPosted: Fri May 14, 2004 1:06 pm   Post subject: (No subject)

because up is not a letter... if you look closely, it is two letters Laughing

hah, anyways... KEY_UP_ARROW is a constant for up arrow's ASCII value. So to use that with char array you'd have to use
code:

chr(up)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: