
-----------------------------------
Myst
Sat Jan 12, 2008 6:22 pm

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.

-----------------------------------
Tony
Sat Jan 12, 2008 7:02 pm

RE:need some help...
-----------------------------------

if hasch
   getch var_c
end if

or
Input.KeyDown() approach

-----------------------------------
Myst
Sat Jan 12, 2008 7:23 pm

RE:need some help...
-----------------------------------
i need the Key Down approach

-----------------------------------
Tony
Sat Jan 12, 2008 7:28 pm

RE:need some help...
-----------------------------------
there's example code available in Turing's Help document files, or here, in the Tutorials section.

-----------------------------------
Myst
Sat Jan 12, 2008 7:30 pm

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
Sat Jan 12, 2008 9:24 pm

RE:need some help...
-----------------------------------
anyone know?

-----------------------------------
StealthArcher
Sat Jan 12, 2008 9:37 pm

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
Sat Jan 12, 2008 9:51 pm

RE:need some help...
-----------------------------------
ahh thanks thats what i needed to kno.

-----------------------------------
Myst
Sat Jan 12, 2008 10:54 pm

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.

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... 
