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

Username:   Password: 
 RegisterRegister   
 input.keydown... seems to favour the right arrow key... help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Bunny_Man_OC




PostPosted: Tue Dec 26, 2006 4:19 pm   Post subject: input.keydown... seems to favour the right arrow key... help

i have a procedure "controls" that chedks for keyboard inpout of the arrow keys. and i use ifs to see if there is keyboard input...

if (key up) then
elsif (key down) then.
etc.
and an else statement for 'noinput". (a fairly standard input check)

and the coding in each other the if's is relativly the same.

code:
if keys (KEY_UP_ARROW) then
            noinput := false
            lastPic := "up"
            clear
            up := true

            if whatdotcolor (pX, pY + speed) = brightblue then
                safe := true
                pY += speed
            elsif whatdotcolor (pX, pY + speed) = blue then
                safe := true
                pY := 375
            elsif whatdotcolor (pX, pY + speed) = black then
                safe := false
                pY += speed
            end if


noinput tells a future procedur wether there was a direction input from the keyboard. if there was, it is false (hehe, double negatives Laughing ) last pic is used to tell that procedure what teh last direction the ship moved it, so it knows what picture to draw. (cause otherwise it draws the pic based on "up = true, left = true, etc.)

clear sets up, down, left and right to equal false.

and each if staement has its corespnoding direction's boolean := true.

(the rest finds teh location of the borders and has nothing to do with my problem)

now heres my problem...
when i press up, it sets up = true, and draws the ship in its up position, and writes up to a dat file. then i press left and it will do the same. I release the key, and it stays in that position. BUT! if i prss right, it will go right, and stay right, however. it continually writes "right" to the dat file (unlike the other three (cause down works properly as well) and when i press another direction, it does what its supposed ot whiel its pressed. but once I release it, it draws the ship facing right again! *angry face* and continues to continually write "right" to the dat file.

the optehr 3 direction work perfectly, and only writethe direction once, (unless its held for more than one move, then they right it for howevermany move sthey made) and when relased they stop writing the direction. but as soon as you hit right, it immediatly messes up, and writes right, over, and over, and over again!

anyone know of anyway i could fix this??
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Tue Dec 26, 2006 7:37 pm   Post subject: (No subject)

any paricular reason you are writing all of this to a .dat file? this seems a bit extravagant for just moving a ship.... use the KISS principle, and get the movement working right, then, if it is a must, use a .dat file to write the movement to a file.
Bunny_Man_OC




PostPosted: Wed Dec 27, 2006 12:32 am   Post subject: (No subject)

Freakman wrote:
any paricular reason you are writing all of this to a .dat file? this seems a bit extravagant for just moving a ship.... use the KISS principle, and get the movement working right, then, if it is a must, use a .dat file to write the movement to a file.


well, it was so i can check to make sure that it is working properly, and then i was gonna read the file back in to draw a line (atarting from the start position) in the directions moved (by reading in from the dat file) so there would be a line behinde the ship.

but cervantes informed me of flexible arrays, so i'll change the program to accomidatye flexible arrays, rather than reading in from an outside file.

buut befor ei do that, i need to stop the program from returning "right" when right is no longer pressed.

this whole situation confuses me becasue it doenst do it for the other 3 directions.
Bunny_Man_OC




PostPosted: Wed Dec 27, 2006 7:29 pm   Post subject: (No subject)

wow, im such an idiot... i found the problem... and it was a stupid error...

and here it is.
code:

procedure clear
up := false
down := false
left := false
down := false
end clear


i missed that error sooo many times... oh well, im really relieved that i found it now Smile
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: