Author |
Message |
w00t
|
Posted: 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
|
|
|
wtd
|
Posted: 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
|
Posted: 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
|
Posted: 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
|
Posted: 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
|
Posted: 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. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
w00t
|
Posted: 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
|
Posted: 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
|
|
|
w00t
|
Posted: 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 |
|
|
|
|
|
|