slow down joystick movement
Author |
Message |
Hemin
|
Posted: Fri Jun 13, 2008 8:03 am Post subject: slow down joystick movement |
|
|
how do i slow down the joystick movement because it is to sensitive also the left does not work all the other sides do heres the code:
Turing: |
var x,y: int
var move: int
x:= 20
y:= 20
drawfillbox(100, 0, 140, 400, 4)
loop
drawfilloval(x,y, 2, 2, 3)
move:= parallelget
if move = 104 then
drawfilloval(x,y, 2, 2, 0)
y:=y+ 1
if whatdotcolor(x+ 3,y+ 3)=(4) then
y:=y- 1
end if
elsif move = 88 then
drawfilloval(x,y, 2, 2, 0)
y:=- 1
if whatdotcolor(x- 3,y- 3)=(4) then
x:=x- 1
end if
elsif move = 248 then
drawfilloval(x,y, 2, 2, 0)
x:=x+ 1
if whatdotcolor(x+ 3,y+ 3)=(4) then
x:=x- 1
end if
elsif move = 112 then
drawfilloval(x,y, 2, 2, 0)
y:=y- 1
if whatdotcolor(x+ 3,y+ 3)=(4) then
y:=y+ 1
end if
end if
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
DemonWasp
|
Posted: Fri Jun 13, 2008 8:14 am Post subject: RE:slow down joystick movement |
|
|
First, you really need to use the [ syntax ] tags, or at the very least [ code ] tags. It's almost impossible to read your code otherwise. Both syntax and code tags will preserve code formatting (indents and such) and syntax provides colour-coding.
Second, you need to learn about commenting your code. I have absolutely no idea what you were trying to accomplish with your whatdotcolor nonsense, nor do I have any idea what inputs move = 104, 88, 248, 112 correspond to.
Third, the easiest way to make it less sensitive is to slow it down. Right now, your loop checks the parallel port, updates your oval, then loops again, as fast as it can. Put in a delay(some number of milliseconds) or even better, a Time.DelaySinceLast() call. That should make it take input slower, thus making it less sensitive.
Fourth, please use proper sentence structure when posting. I can't claim to speak for everyone else, but I'm much more inclined to help people who state their problem clearly, using complete sentences. If English isn't your first language, I understand, but if it's your first language there's no excuse for poor grammar. |
|
|
|
|
![](images/spacer.gif) |
Hemin
|
Posted: Fri Jun 13, 2008 8:26 am Post subject: Re: slow down joystick movement |
|
|
Dude i do know english but i don't know where to put the delay can you please help me. |
|
|
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Fri Jun 13, 2008 8:57 am Post subject: RE:slow down joystick movement |
|
|
Perhaps right after you've drawn everything? |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Fri Jun 13, 2008 9:08 am Post subject: Re: slow down joystick movement |
|
|
Hemin @ Fri Jun 13, 2008 8:26 am wrote: Dude i do know english but i don't know where to put the delay can you please help me.
Dude, I do know English, but I don't know where to put the delay. Can you please help me?
Your problem with movement likely lies in this part of code:
y:=-1 looks like a typo.
The delay be called when you are done with everything else in the main loop. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Hemin
|
Posted: Fri Jun 13, 2008 7:05 pm Post subject: Re: slow down joystick movement |
|
|
i know have another problem on hand i can't get the left to work and also now none of the controls work and its not because i have modifed any of the program. i have also checked if the wires are touching and none of them are and the weird thing is the dot moves by itself to the right without me using the joystick or any other keys but i can't move it with the joystick. It was working at school fine and when i brought it home and i run it it gets an error that says cannot find port I/O and i have tried re connecting it but and when i run it again it says DLPORTIO.sys is cannot be found which is werid because i reconnect the parallel port to the computer |
|
|
|
|
![](images/spacer.gif) |
Euphoracle
![](http://compsci.ca/v3/uploads/user_avatars/11170373664bf5f25f636f1.png)
|
Posted: Fri Jun 13, 2008 8:28 pm Post subject: RE:slow down joystick movement |
|
|
You need to install the DLPORTIO.exe package on the turing CD or in the support folder if you downloaded 4.1.1 from the website. Must be done as administrator, I think. |
|
|
|
|
![](images/spacer.gif) |
Hemin
|
Posted: Sat Jun 14, 2008 9:25 am Post subject: Re: slow down joystick movement |
|
|
thanks i will see if it now works |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Hemin
|
Posted: Sat Jun 14, 2008 11:24 am Post subject: Re: slow down joystick movement |
|
|
I got the joystick to work but I can't seem to get the left to work the wire i have are 11,12,13,14,and 15 which are availlable is it the code thats the problem or the wiring
Turing:
put" The game will begin in"
delay(500)
cls
put"5"
delay(1000)
cls
put"4"
delay(1000)
cls
put"3"
delay(1000)
cls
put"2"
delay(1000)
cls
put"1"
delay(1000)
cls
put"Go!"
delay(1000)
procedure Maze
drawfillbox (100, 35, 120, 160, black)
drawfillbox (50, 35, 100, 52, black)
drawfillbox (110, 35, 192, 52, black)
drawfillbox (0, 110, 35, 129, black)
drawfillbox (0, 0, 25, 52, black)
drawfillbox (200, 13, 180, 140, black)
drawfillbox (0, 0, 120, 19, black)
drawfillbox (55, 120, 80, 140, black)
drawfillbox (0, 593, 190, 285, black)
drawfillbox (81, 137, 179, 121, black)
% Middle
drawfillbox (250, 150, 230, 282, black)
drawfillbox (145, 180, 200, 162, black)
drawfillbox (140, 95, 180, 110, black)
drawfillbox (350, 100, 220, 120, black)
drawfillbox (0, 200, 65, 180, black)
drawfillbox (525, 35, 310, 51, black)
drawfillbox (340, 78, 69, 62, black)
drawfillbox (350,168,328,121,black)
%Top Right Corner of maze
drawfillbox (593, 190, 234, 212, black)
drawfillbox (245, 239, 103, 223, black)
drawfillbox (619,297,638,300,black)
% Top left corner of maze
drawfillbox (385, 250, 0, 269, black)
drawfillbox (594,300,618,153,black)
drawfillbox (618,152,413,128,black)
%Bottom Right Corner of maze
drawfillbox (524,51,548,0,black)
drawfillbox (508,127,493,73,black)
drawfillbox (463,48,448,108,black)
drawfillbox (428,128,413,62,black)
drawfillbox (413,113,368,101,black)
drawfillbox (596,127,578,18,black)
drawfillbox (548,50,533,108,black)
%Colored boxes/Traps these are good and bad
drawfillbox (230, 150, 201, 121, green)
drawfillbox (80, 20, 101, 35, blue)
%Winning Area
drawfillbox (0, 249, 65, 200, 14)
end Maze
Maze
%Moving Dot/Preventing dot from going through walls prevent outside clipping region
var x,y:int
var move:int
var answer : string
x := 625
y := 290
loop
drawfilloval(x,y,2,2,3)
move:=parallelget
Time.DelaySinceLast(50)
if move = 104 and y < 298 then
drawfilloval(x,y,2,2,0)
y:=y+1
if whatdotcolor(x+3,y+3)=(black) then
y:=y-1
end if
Time.DelaySinceLast(50)
elsif move = 88 and x > 2 then
drawfilloval(x,y,2,2,0)
y:=-1
if whatdotcolor(x-3,y-3)=(black) then
x:=x-1
end if
Time.DelaySinceLast(50)
elsif move = 248 and x < 638 then
drawfilloval(x,y,2,2,0)
x:=x+1
if whatdotcolor(x+3,y+3)=(black) then
x:=x-1
end if
Time.DelaySinceLast(50)
elsif move = 112 and y > 3 then
drawfilloval(x,y,2,2,0)
y:=y-1
if whatdotcolor(x+3,y+3)=(black) then
y:=y+1
end if
end if
end loop
%Color Trap # 1
if whatdotcolor (x, y) = (green) then
y := 293
x := 630
end if
%Color Trap # 2
if whatdotcolor (x, y) = (blue) then
y := 140
x := 155
end if
%Invisible Trap asks a skill testing question for the player to win
if x >= 68 and x <= 230 and y >= 190 and y <= 220 then
cls
put "What is the biggest star in the world ?"
get answer
if answer = "Antares" then
x := 28
y := 235
cls
Maze
colour(10)
colourback(255)
cls
loop
delay(10)
put"YOU WIN!"
end loop
else
y := 100
x := 130
cls
Maze
colour(10)
colourback(255)
cls
loop
delay(10)
put"YOU LOSE!"
end loop
end if
end if |
|
|
|
|
![](images/spacer.gif) |
|
|