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

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




PostPosted: Fri May 13, 2005 4:35 pm   Post subject: Input.KeyDown help...

hey need some help on making this movement thing work im having some problems ... i included a dl so that it will help ...

code:
var zelda_right, zelda_up, zelda_down, zelda_left : int
zelda_right := Pic.New (50, 50, 150, 150)
zelda_right := Pic.FileNew ("link movement right.bmp")
zelda_up := Pic.New (50, 50, 150, 150)
zelda_up := Pic.FileNew ("link movement up.bmp")
zelda_down := Pic.New (50, 50, 150, 150)
zelda_down := Pic.FileNew ("link movement down.bmp")
zelda_left := Pic.New (50, 50, 150, 150)
zelda_left := Pic.FileNew ("link movement left.bmp")





var x, y : int
x := 100
y := 100
var chars : array char of boolean


loop
    Input.KeyDown (chars)

    if chars (KEY_UP_ARROW) then
        y := y + 5
        Pic.Draw (zelda_up, x, y, picCopy)

    end if
    if chars (KEY_RIGHT_ARROW) then
        x := x + 5
        Pic.Draw (zelda_right, x, y, picCopy)

    end if
    if chars (KEY_LEFT_ARROW) then
        x := x - 5
        Pic.Draw (zelda_left, x, y, picCopy)

    end if
    if chars (KEY_DOWN_ARROW) then
        y := y - 5
        Pic.Draw (zelda_down, x, y, picCopy)

    end if

    cls
    delay (10)


end loop


if i put that in the pic doesent show until u press a botton and it keeps flickering but i know to use view.Update but i dont know where to put it and how it works and if u find any more problems tell me and ill fix it.. if u teach me that is...



Zelda movment.zip
 Description:
pics for program

Download
 Filename:  Zelda movment.zip
 Filesize:  2.42 KB
 Downloaded:  87 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Fri May 13, 2005 5:37 pm   Post subject: (No subject)

For View.Update to work you need:
code:
View.Set ("offscreenonly")

and then add View.Update before the delay.

The reason that it only shows link when you have something pressed is because you only told the program to do that. When you first start the program out, you have no set position, so it will not show anyways. Also, more importantly, you need to find a way to keep the position still in between press's.

If you are stuck and can't figure out how to by yourself I have included some code below.



link movement.t
 Description:
Newer linkmovement.t

Download
 Filename:  link movement.t
 Filesize:  1.02 KB
 Downloaded:  91 Time(s)

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  [ 2 Posts ]
Jump to:   


Style:  
Search: