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

Username:   Password: 
 RegisterRegister   
 Setting Boundaries for Key inputs
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
w00t




PostPosted: Thu Dec 16, 2004 3:25 pm   Post subject: Setting Boundaries for Key inputs

code:
   
        loop

        Input.KeyDown (chars)

        if chars (KEY_RIGHT_ARROW) then
            x := x + 2
        end if
        if chars (KEY_LEFT_ARROW) then
            x := x - 2
        end if
        if chars (KEY_DOWN_ARROW) then
        end if
        Pic.Draw (ship, x, 10, picCopy)
        View.Update
    end loop


this is what i have for key inputs so far i was wondering if there is a way to set boundaries so that an object doesn't go to far off the screen?!? Becuase that would be bad in a game like space invaders!

Any help is greatly appreciated..
w00t

and yes i realized i just posted a topic about key inputs like 15 mins ago.. please over look that
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Thu Dec 16, 2004 3:30 pm   Post subject: (No subject)

code:
if chars (KEY_RIGHT_ARROW) then
   x := x + 2
end if


Use something like:

code:
if chars (KEY_RIGHT_ARROW) and x <= MAX_X - 2 then
   x += 2
end if
bill_ion_boi




PostPosted: Thu Dec 16, 2004 4:55 pm   Post subject: (No subject)

what if tere are specific boundaries like a square in the midle of the screen, like you can go anywhere exept through the square....Is that possible?
wtd




PostPosted: Thu Dec 16, 2004 5:00 pm   Post subject: (No subject)

bill_ion_boi wrote:
what if tere are specific boundaries like a square in the midle of the screen, like you can go anywhere exept through the square....Is that possible?


Yes, just add more conditions:

sort of psuedo-code

code:
if right_arrow and x < max_x and x < left_side_of_square then
  ...
end if
w00t




PostPosted: Thu Dec 16, 2004 5:11 pm   Post subject: (No subject)

Now that i have it working with Boundaries , thnx alot

code:
    loop

        Input.KeyDown (chars)

        if chars (KEY_RIGHT_ARROW) and x <= maxx - 50
                then
            x += 2
        end if
        if chars (KEY_LEFT_ARROW) and x >= maxx - 550 then
            x -= 2
        end if
        if chars (KEY_DOWN_ARROW) then

        end if
        Pic.Draw (ship, x, 10, picCopy)
        View.Update
    end loop


please tell me that will work on turing 3.1.1 because thats what i have at school and if it doesn't what will work so i can fix my program.
Tony




PostPosted: Thu Dec 16, 2004 5:14 pm   Post subject: (No subject)

you might want to consider having two versions of Turing on your machine. 4.0.5 for yourself and 3.1 for school related work.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
w00t




PostPosted: Thu Dec 16, 2004 5:58 pm   Post subject: (No subject)

curses, it doesn't work ,gah
anyone know what i could put to replace my code?
Cervantes




PostPosted: Fri Dec 17, 2004 10:40 am   Post subject: (No subject)

Is it the View.Update that is causing the trouble? Personally, I've never used any of the Turing 3.x's, but if I remember correctly, those don't have View.Update.
If that's giving you problems, I don't think there's much you can do about it.
Otherwise, tell us where the error is.
Sponsor
Sponsor
Sponsor
sponsor
w00t




PostPosted: Fri Dec 17, 2004 12:35 pm   Post subject: (No subject)

You're right,

thee is now view,update in any 3.x but i figured how to get it working again.. thanks alot

w00t Laughing
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  [ 9 Posts ]
Jump to:   


Style:  
Search: