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

Username:   Password: 
 RegisterRegister   
 need some help...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Myst




PostPosted: Sat Jan 12, 2008 6:22 pm   Post subject: need some help...

so im making a basic tic tack toe game for class, which i hope will be okie... but anyways. I want the player to press the space bar to make his/her turn to end and making player 2 to start with his/her own piece. basically i need help with the space bar but i cant remember the code for it, so any help will be appreciated.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sat Jan 12, 2008 7:02 pm   Post subject: RE:need some help...

code:

if hasch
   getch var_c
end if

or
Input.KeyDown() approach
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Myst




PostPosted: Sat Jan 12, 2008 7:23 pm   Post subject: RE:need some help...

i need the Key Down approach
Tony




PostPosted: Sat Jan 12, 2008 7:28 pm   Post subject: RE:need some help...

there's example code available in Turing's Help document files, or here, in the Tutorials section.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Myst




PostPosted: Sat Jan 12, 2008 7:30 pm   Post subject: RE:need some help...

lol ya i just found the tutorial, sorry for the waste of time.

btw how do i enter a ASCII variable into the Key.Down thing? i tried just putting the number between the brackets but it didn't work.
Myst




PostPosted: Sat Jan 12, 2008 9:24 pm   Post subject: RE:need some help...

anyone know?
StealthArcher




PostPosted: Sat Jan 12, 2008 9:37 pm   Post subject: RE:need some help...

If you want an ascii character out of its ordinal value, use chr() example: chr(208)[this giv3es the UPARROW character]
Myst




PostPosted: Sat Jan 12, 2008 9:51 pm   Post subject: RE:need some help...

ahh thanks thats what i needed to kno.
Sponsor
Sponsor
Sponsor
sponsor
Myst




PostPosted: Sat Jan 12, 2008 10:54 pm   Post subject: Re: need some help...

well i hate to make all of these double posts, buuut i need one last thing to complete my game of tic tack toe... well its the only thing that i don't know thats left.

Quote:
var chars : array char of boolean


var ballx, bally : int := 200
var ballx2, bally2 : int := 0
setscreen ("offscreenonly")
setscreen ("graphics:max,max,nobuttonbar")








procedure player1
loop
View.Update
Draw.FillBox (0, 0, maxx, maxy, 255)


Draw.FillOval (400, 450, 25, 25, white)
Draw.FillOval (450, 450, 25, 25, white)
Draw.FillOval (500, 450, 25, 25, white)

Draw.FillOval (500, 400, 25, 25, white)
Draw.FillOval (450, 400, 25, 25, white)
Draw.FillOval (400, 400, 25, 25, white)

Draw.FillOval (500, 350, 25, 25, white)
Draw.FillOval (450, 350, 25, 25, white)
Draw.FillOval (400, 350, 25, 25, white)


Draw.FillOval (ballx, bally, 20, 20, blue)
ballx2 := ballx
bally2 := bally
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) then
bally := bally + 2
elsif chars (KEY_DOWN_ARROW) then
bally := bally - 2
elsif chars (KEY_RIGHT_ARROW) then
ballx := ballx + 2
elsif chars (KEY_LEFT_ARROW) then
ballx := ballx - 2
elsif chars (chr (49)) then
Draw.FillOval (ballx2, bally2, 20, 20, blue)
exit when chars (chr (49))
end if
delay (15)

end loop
end player1

player1


var ballx3, bally3 : int := 0
loop
View.Update

Draw.FillBox (0, 0, maxx, maxy, 255)



Draw.FillOval (400, 450, 25, 25, white)
Draw.FillOval (450, 450, 25, 25, white)
Draw.FillOval (500, 450, 25, 25, white)

Draw.FillOval (500, 400, 25, 25, white)
Draw.FillOval (450, 400, 25, 25, white)
Draw.FillOval (400, 400, 25, 25, white)

Draw.FillOval (500, 350, 25, 25, white)
Draw.FillOval (450, 350, 25, 25, white)
Draw.FillOval (400, 350, 25, 25, white)


Draw.FillOval (ballx, bally, 20, 20, 12)

ballx3 := ballx
bally3 := bally

Input.KeyDown (chars)
if chars (KEY_UP_ARROW) then
bally := bally + 2
elsif chars (KEY_DOWN_ARROW) then
bally := bally - 2
elsif chars (KEY_RIGHT_ARROW) then
ballx := ballx + 2
elsif chars (KEY_LEFT_ARROW) then
ballx := ballx - 2
elsif chars (chr (50)) then
Draw.FillOval (ballx3, bally3, 20, 20, 12)
player1
end if

delay (15)
end loop


so i know its not the prettiest piece of code, but all i really want to do know is just make another FillOval when chr (50) or (49) are pressed. I tried as you can see but i dont get another FillOval...
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: