This is driving me crazy!!!
Author |
Message |
Fashoomp
|
Posted: Wed Mar 07, 2007 4:07 pm Post subject: This is driving me crazy!!! |
|
|
OMG this is driving me crazy. Its arrow key movement, and enter key to change the colours. I got that working, but i cant get the diagnols to work. It will go left-up, and left-down, but it will not go right up/down. I have looked over the code, and can not find ANY difference in the direction if statements (other than +/-). Please, can someone look over it and tell me why it wont work?
code: | View.Set ("offscreenonly")
var counter : int := 0
var x1 : int := 0
var x2 : int := 100
var y1 : int := 0
var y2 : int := 100
var colours : array 1 .. 7 of int := init (9, 12, 10, 13, 14, 7, 3)
var c_c : int := 1
var chars : array char of boolean
loop
put "(", x1 + 50, ")" ..
put "," ..
put "(", y1 + 50, ")" ..
delay (10)
drawfillbox (x1, y1, x2, y2, colours (c_c))
drawdot (x1 + 50, y1 + 50, 0)
Input.KeyDown (chars)
View.Update
%200 up
%208 down
%205 right
%203 left
if chars (chr (10)) then
c_c := c_c + 1
end if
if c_c = 7 then
c_c := 1
end if
cls
if chars (chr (205)) then %right
x1 := x1 + 2
x2 := x2 + 2
else
if chars (chr (205)) and chars (chr (200)) then %right-up
x1 := x1 + 2
x2 := x2 + 2
y1 := y1 + 2
y2 := y2 + 2
else
if chars (chr (205)) and chars (chr (208)) then %right-down
x1 := x1 + 2
x2 := x2 + 2
y1 := y1 - 2
y2 := y2 - 2
else
if chars (chr (203)) and chars (chr (200)) then %left-up
x1 := x1 - 2
x2 := x2 - 2
y1 := y1 + 2
y2 := y2 + 2
else
if chars (chr (203)) and chars (chr (208)) then %left down
x1 := x1 - 2
x2 := x2 - 2
y1 := y1 - 2
y2 := y2 - 2
else
if chars (chr (203)) then %left
x1 := x1 - 2
x2 := x2 - 2
else
if chars (chr (208)) then %up
y1 := y1 - 2
y2 := y2 - 2
else
if chars (chr (200)) then %down
y1 := y1 + 2
y2 := y2 + 2
else
end if
end if
end if
end if
end if
end if
end if
end if
% cls
end loop
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
BenLi
|
Posted: Wed Mar 07, 2007 5:32 pm Post subject: Re: This is driving me crazy!!! |
|
|
code: |
View.Set ("offscreenonly")
var counter : int := 0
var x1 : int := 0
var x2 : int := 100
var y1 : int := 0
var y2 : int := 100
var colours : array 1 .. 7 of int := init (9, 12, 10, 13, 14, 7, 3)
var c_c : int := 1
var chars : array char of boolean
loop
put "(", x1 + 50, ")" ..
put "," ..
put "(", y1 + 50, ")" ..
delay (10)
drawfillbox (x1, y1, x2, y2, colours (c_c))
drawdot (x1 + 50, y1 + 50, 0)
Input.KeyDown (chars)
View.Update
%200 up
%208 down
%205 right
%203 left
if chars (chr (10)) then
c_c := c_c + 1
end if
if c_c = 7 then
c_c := 1
end if
cls
if chars (chr (205)) then %right
x1 := x1 + 2
x2 := x2 + 2
end if
if chars (chr (203)) then %left
x1 := x1 - 2
x2 := x2 - 2
end if
if chars (chr (208)) then %up
y1 := y1 - 2
y2 := y2 - 2
end if
if chars (chr (200)) then %down
y1 := y1 + 2
y2 := y2 + 2
end if
% cls
end loop
|
that'll work
deal is, you don't have to check it manually, if you just put everything in its own if statement, then it'll work perfectly
And also instead of the number values you could've used KEY_UP_ARROW, KEY_DOWN_ARROW, etc.
So the problem was solved by getting rid of lines, but if you wanted to solve the problem that other way then the problem was in your if statements |
|
|
|
|
|
Fashoomp
|
Posted: Wed Mar 07, 2007 5:55 pm Post subject: Re: This is driving me crazy!!! |
|
|
One more thing, whenever i press enter, it cycles through the colours very quickly. Is there something i can put in there so it does not think i am holding enter? |
|
|
|
|
|
Clayton
|
Posted: Wed Mar 07, 2007 6:04 pm Post subject: Re: This is driving me crazy!!! |
|
|
First thing, your avatar is about two times too big, just resize and re-upload it and it'll all be good
Second, you need to either have some sort of variable to see if the key is actually being pressed for the first time (preferred), or have some sort of delay to prevent the colors from speeding by (not so preferred). |
|
|
|
|
|
|
|