Joystick Progam HElP!
Author |
Message |
Hemin
|
Posted: Mon Jun 09, 2008 8:00 am Post subject: Joystick Progam HElP! |
|
|
i need help making a joystick program but i do not know how to incorporate it into my maze game here is the code for the game:
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 : string (1)
var answer : string
x := 630
y := 290
loop
drawfilloval (x, y, 2, 2, 4)
getch (move)
if move = chr (200) and y < 298 then
drawfilloval (x, y, 2, 2, 0)
y := y + 5
if whatdotcolor (x, y) = (black) then
y := y - 5
end if
elsif move = chr (203) and x > 2 then
drawfilloval (x, y, 2, 2, 0)
x := x - 5
if whatdotcolor (x, y) = (black) then
x := x + 5
end if
elsif move = chr (205) and x < 638 then
drawfilloval (x, y, 2, 2, 0)
x := x + 5
if whatdotcolor (x, y) = (black) then
x := x - 5
end if
elsif move = chr (208) and y > 3 then
drawfilloval (x, y, 2, 2, 0)
y := y - 5
if whatdotcolor (x, y) = (black) then
y := y + 5
end if
end if
%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(1000)
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
end loop
i need the joystick to move up,down,left, right |
|
|
|
|
|
Sponsor Sponsor
|
|
|
nastynika
|
Posted: Mon Jun 09, 2008 8:58 am Post subject: Re: Joystick Progam HElP! |
|
|
have u looked in the Turing Reference section locating in turing itself? |
|
|
|
|
|
Hemin
|
Posted: Tue Jun 10, 2008 7:47 am Post subject: Re: Joystick Progam HElP! |
|
|
yeah but our teacher does not want us to do it that way he wants us to do it like :
var joystick : int
loop
parallelput (200)
delay (1000)
joystick := parallelget
put joystick
end loop |
|
|
|
|
|
Insectoid
|
Posted: Tue Jun 10, 2008 8:06 am Post subject: RE:Joystick Progam HElP! |
|
|
I suppose you need to find the pins that input left/right/up/down, then use an if statment
if joystick = 1 then left
if joystick = 2 then right
if joystick = 4 then up
if joystick = 8 then down)
I have only done parallelput, so I'm not sure if this is how it works. Just remeber that the pins don't use the number printed on the DB, it uses the binary placeholders. |
|
|
|
|
|
Hemin
|
Posted: Tue Jun 10, 2008 4:19 pm Post subject: Re: Joystick Progam HElP! |
|
|
how would i put this in my game the joystick code is having errors |
|
|
|
|
|
Insectoid
|
Posted: Tue Jun 10, 2008 4:50 pm Post subject: RE:Joystick Progam HElP! |
|
|
What kind of errors? I suppose it has to do with what wires are in which pins. Did you make the stick yourself?
To check which pins to what, then make a program that parallelgets from the joystick and prints the input to the screen. I'm sure there's a tutorial somewhere around here... |
|
|
|
|
|
Hemin
|
Posted: Tue Jun 10, 2008 8:23 pm Post subject: Re: Joystick Progam HElP! |
|
|
the error is with the code you gave me:
if joystick = 1 then left
if joystick = 2 then right
if joystick = 4 then up
if joystick = 8 then down)
it doesn't run the program i tried if joystick = 1 then chr(200) and that gets an error |
|
|
|
|
|
Insectoid
|
Posted: Tue Jun 10, 2008 8:31 pm Post subject: RE:Joystick Progam HElP! |
|
|
What error?! |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Hemin
|
Posted: Wed Jun 11, 2008 7:35 am Post subject: Re: Joystick Progam HElP! |
|
|
it doesnt run when i wrote only your code can you tell me how i can put it into the game please |
|
|
|
|
|
Insectoid
|
Posted: Wed Jun 11, 2008 3:17 pm Post subject: RE:Joystick Progam HElP! |
|
|
Of course running my code won't work, it's pseodocode...ish. I won't give you the answer, I'll just help you along until you reach it yourself. Ask your teacher.
I just found out today that pins 10-13 and 15 (I think) are input pins, so those are the ones you need to check for. Note that they should be the binary representation of that number (unless it's different with input). |
|
|
|
|
|
Hemin
|
Posted: Wed Jun 11, 2008 3:54 pm Post subject: Re: Joystick Progam HElP! |
|
|
the pins we have are is 3,5,11,13 |
|
|
|
|
|
Zampano
|
Posted: Wed Jun 11, 2008 4:46 pm Post subject: Re: Joystick Progam HElP! |
|
|
You need to understand that the number returned by parallelget is created by the bases of 2 which correspond to the pins through which the data enters. So, if pin 11 is returning current, the parallelget will return a number that cannot be created in bases of 2 with a 128, as pin 11 (from Turing Help) is alloted 2 to the power of 7. So, if the number of parallelget is one that needs a 128 when created with bases of 2 (I hope you know your binary), then you know that pin 11 is returning current, and is thus pressed on the control pad. |
|
|
|
|
|
|
|