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

Username:   Password: 
 RegisterRegister   
 Input.KeyDown trouble
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
harishmabish




PostPosted: Thu Apr 03, 2008 4:56 pm   Post subject: Input.KeyDown trouble

var carx, cary : int
carx := 350
cary := 250
Input.KeyDown (chars)
if chars1 (KEY_UP_ARROW) then
cary:=cary -10
end if

Pic.Draw (car1, carx, cary, picMerge)
delay (10)
View.Update
cls

That's a part of my code,

when i press the up arrow, the object will move 10 pixels down the y axis, but when i let go of the button, it goes right back to its normal spot. What's goin on here? am i missing something? it should stay 10 mp down?!
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Apr 03, 2008 5:00 pm   Post subject: RE:Input.KeyDown trouble

why would
code:

var carx, cary : int
carx := 350
cary := 250

be inside a loop?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
that-guy




PostPosted: Thu Apr 03, 2008 5:08 pm   Post subject: Re: Input.KeyDown trouble

Make sure you are declaring and assigning your variables outside the loop.

Also, when you tell it to move down 10 pixels, just say:

cary -= 10

instead of:

cary := cary - 10
harishmabish




PostPosted: Fri Apr 04, 2008 5:28 pm   Post subject: RE:Input.KeyDown trouble

thanks for the tips
Nick




PostPosted: Fri Apr 04, 2008 6:35 pm   Post subject: RE:Input.KeyDown trouble

Quote:

Input.KeyDown (chars)
if chars1 (KEY_UP_ARROW) then


notice how chars1 isn't the same as chars
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  [ 5 Posts ]
Jump to:   


Style:  
Search: