| yan - May-28-2004 server time |
| this is wat i have so far..... var player1, player2 : string var n : int var choice : array 1 .. 50 of string procedure x drawline (20, 200, 70, 260, 0) drawline (22, 202, 72, 262, 0) drawline (24, 204, 74, 264, 0) drawline (26, 206, 76, 266, 0) drawline (20, 260, 70, 200, 0) drawline (21, 261, 71, 201, 0) drawline (22, 262, 72, 202, 0) drawline (23, 263, 73, 203, 0) end x procedure o drawoval (200, 233, 35, 35, 0) end o put "Who wants to go first? X or O?" get player1 drawfill (maxx, maxy, 1, 2) if player1 = "x" or player1 = "X" then player2 := "O" %x elsif player1 = "o" or player1 = "O" then player2 := "X" %o else loop put "Try again. Please enter X or O." get player1 exit when player1 = "x" or player1 = "X" or player1 = "o" or player1 = "O" end loop if player1 = "x" or player1 = "X" then player2 := "O" %x elsif player1 = "o" or player1 = "O" then player2 := "X" %o end if end if var file : int /* open : file, "questions and answers.txt", get assert file not = o for i : 1 .. 50 get : file, choice (i) end for put "Enter the question you want to answer (1 to 50). " .. get n if choice (n) not= "xxx" then put choice (n) choice (n) := "xxx" else put "The question was already answered. Choose another one. " .. loop get n exit when choice (n) not= "xxx" end loop end if*/ %drawfill (maxx, maxy, 13, 2) drawbox (100, 200, 150, 250, 10) %last row, first box drawbox (150, 200, 200, 250, 10) %last row, middle box drawbox (200, 200, 250, 250, 10) %last row,last box drawbox (100, 250, 150, 300, 10) %second row, first box drawbox (150, 250, 200, 300, 10) %second row, middle box drawbox (200, 250, 250, 300, 10) %second row, last box drawbox (100, 300, 150, 350, 10) %first row, first box drawbox (150, 300, 200, 350, 10) %first row, second box drawbox (200, 300, 250, 350, 10) %first row, last box var test : array 1 .. 3, 1 .. 3 of string var over : boolean := true var whowon : string := "noone" procedure check1 var z : string for i : 1 .. 3 if test (i, 1) = "x" or test (i, 1) = "X" or test (1, i) = "X" or test (1, i) = "x" then z := "X" else z := "Y" end if end for if test (1, 1) = "X" or test (1, 1) = "x" then z := "X" else z := "Y" end if if test (1, 3) = "x" or test (1, 3) = "X" then z := "X" else z := "Y" end if end check1 procedure check (z : string) for i : 1 .. 3 if test (i, 1) = z and test (i, 2) = z and test (i, 3) = z or test (1, i) = z and test (2, i) = z and test (3, i) = z then over := false whowon := z end if end for if test (1, 1) = z and test (2, 2) = z and test (3, 3) = z then over := false whowon := z end if if test (1, 3) = z and test (2, 2) = z and test (3, 1) = z then over := false whowon := z end if end check var turn : string if player1 = "X" or player1 = "x"then turn := "X" else turn := "O" end if procedure playing (turn : string) var a, y, buttonnumber, buttonupdown, buttons : int loop buttonwait ("down", a, y, buttonnumber, buttonupdown) colour (black) if turn = "X" then x else o end if end loop end playing playing (turn) check1 var z : string check (z) |
| yan - May-28-2004 server time |
| hi m using turing for windows 4.0.4c.. i tried ur program bt then i havent modified them yet... so all that shows up is the box.. i just dont get how to put the x and o in the boxes..neways. thanks for all those who replied |
| C-well - May-28-2004 server time |
| OK so I had to try, besides red handles the newer stuff so I'll try the older stuff. Here goes: var takenx : array 1 .. 9 of boolean var takeny : array 1 .. 9 of int var boxx, boxy : array 1 .. 9 of int var turn, who_won_game : string := "nobody" var x, y, b : int := 0 var answer : string var u, c : array 1 .. 5 of int %process playstuff % loop % Music.PlayFile ("Whatever you want.mp3") % end loop %end playstuff %fork playstuff procedure Initialize (var c, u : array 1 .. 5 of int) for initial : 1 .. 5 u (initial) := -999 c (initial) := -999 end for end Initialize for i : 1 .. 9 takenx (i) := false takeny (i) := 0 turn := "player 1" end for boxx (1) := 60 boxx (2) := 160 boxx (3) := 260 boxy (1) := 60 boxy (2) := 60 boxy (3) := 60 boxx (4) := 60 boxx (5) := 160 boxx (6) := 260 boxy (4) := 160 boxy (5) := 160 boxy (6) := 160 boxx (7) := 60 boxx (8) := 160 boxx (9) := 260 boxy (7) := 260 boxy (8) := 260 boxy (9) := 260 procedure Draw_Screen for i : 1 .. 9 Draw.Box (boxx (i) - 50, boxy (i) - 50, boxx (i) + 50, boxy (i) + 50, 255) end for end Draw_Screen function Get_Users_Move:int for i : 1 .. 9 if (turn = "player 1") and (x > boxx (i) - 50 and x < boxx (i) + 50) and (y > boxy (i) - 50 and y < boxy (i) + 50) and (b = 1) then takenx (i) := true takeny (i) := 1 turn := "computer" end if end for end Get_Users_Move procedure Plot_Move for i : 1 .. 9 if (takenx (i) = true) and (takeny (i) = 1) then Draw.Line (boxx (i) - 50, boxy (i) + 50, boxx (i) + 50, boxy (i) - 50, 12) Draw.Line (boxx (i) - 50, boxy (i) - 50, boxx (i) + 50, boxy (i) + 50, 12) elsif (takenx (i) = true) and (takeny (i) = 2) then Draw.Oval (boxx (i), boxy (i), 45, 45, 2) end if end for end Plot_Move %!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! function Block_User :int if (takenx (2) = true and takenx (3) = true) and (takeny (2) = 1 and takeny (3) = 1) then Draw.Oval (boxx (1), boxy (1), 45, 45, 2) elsif (takenx (1) = true and takenx (3) = true) and (takeny (1) = 1 and takeny (3) = 1) then Draw.Oval (boxx (4), boxy (2), 45, 45, 2) elsif (takenx (1) = true and takenx (2) = true) and (takeny (1) = 1 and takeny (2) = 1) then Draw.Oval (boxx (7), boxy (3), 45, 45, 2) elsif (takenx (5) = true and takenx (6) = true) and (takeny (5) = 1 and takeny (6) = 1) then Draw.Oval (boxx (2), boxy (4), 45, 45, 2) elsif (takenx (4) = true and takenx (6) = true) and (takeny (4) = 1 and takeny (6) = 1) then Draw.Oval (boxx (5), boxy (5), 45, 45, 2) elsif (takenx (4) = true and takenx (5) = true) and (takeny (4) = 1 and takeny (5) = 1) then Draw.Oval (boxx (8), boxy (6), 45, 45, 2) elsif (takenx (8) = true and takenx (9) = true) and (takeny (8) = 1 and takeny (9) = 1) then Draw.Oval (boxx (3), boxy (7), 45, 45, 2) elsif (takenx (7) = true and takenx (9) = true) and (takeny (7) = 1 and takeny (9) = 1) then Draw.Oval (boxx (6), boxy (8), 45, 45, 2) elsif (takenx (7) = true and takenx (8) = true) and (takeny (7) = 1 and takeny (8) = 1) then Draw.Oval (boxx (9), boxy (9), 45, 45, 2) elsif (takenx (5) = true and takenx (9) = true) and (takeny (5) = 1 and takeny (9) = 1) then Draw.Oval (boxx (1), boxy (1), 45, 45, 2) elsif (takenx (1) = true and takenx (9) = true) and (takeny (1) = 1 and takeny (9) = 1) then Draw.Oval (boxx (5), boxy (5), 45, 45, 2) elsif (takenx (1) = true and takenx (5) = true) and (takeny (1) = 1 and takeny (5) = 1) then Draw.Oval (boxx (9), boxy (9), 45, 45, 2) elsif (takenx (5) = true and takenx (3) = true) and (takeny (5) = 1 and takeny (3) = 1) then Draw.Oval (boxx (3), boxy (7), 45, 45, 2) elsif (takenx (7) = true and takenx (3) = true) and (takeny (7) = 1 and takeny (3) = 1) then Draw.Oval (boxx (5), boxy (5), 45, 45, 2) elsif (takenx (7) = true and takenx (5) = true) and (takeny (7) = 1 and takeny (5) = 1) then Draw.Oval (boxx (7), boxy (3), 45, 45, 2) elsif (takenx (4) = true and takenx (7) = true) and (takeny (4) = 1 and takeny (7) = 1) then Draw.Oval (boxx (1), boxy (1), 45, 45, 2) elsif (takenx (1) = true and takenx (7) = true) and (takeny (1) = 1 and takeny (7) = 1) then Draw.Oval (boxx (2), boxy (4), 45, 45, 2) elsif (takenx (1) = true and takenx (4) = true) and (takeny (1) = 1 and takeny (4) = 1) then Draw.Oval (boxx (3), boxy (7), 45, 45, 2) elsif (takenx (5) = true and takenx (8) = true) and (takeny (5) = 1 and takeny (8) = 1) then Draw.Oval (boxx (2), boxy (4), 45, 45, 2) elsif (takenx (2) = true and takenx (8) = true) and (takeny (2) = 1 and takeny (8) = 1) then Draw.Oval (boxx (5), boxy (5), 45, 45, 2) elsif (takenx (2) = true and takenx (5) = true) and (takeny (2) = 1 and takeny (5) = 1) then Draw.Oval (boxx (6), boxy (8), 45, 45, 2) elsif (takenx (6) = true and takenx (9) = true) and (takeny (6) = 1 and takeny (9) = 1) then Draw.Oval (boxx (7), boxy (3), 45, 45, 2) elsif (takenx (3) = true and takenx (9) = true) and (takeny (3) = 1 and takeny (9) = 1) then Draw.Oval (boxx (8), boxy (6), 45, 45, 2) elsif (takenx (3) = true and takenx (6) = true) and (takeny (3) = 1 and takeny (6) = 1) then Draw.Oval (boxx (9), boxy (9), 45, 45, 2) end if end Block_User %!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! function Get_Computers_Move :int for i : 1 .. 5 if u (i) not= -999 and u (i) = 5 then Draw.Oval (boxx (i), boxy (i), 45, 45, 2) turn := "player 1" end if end for end Get_Computers_Move function User_Won : boolean if (takenx (1) = true and takenx (2) = true and takenx (3) = true) and (takeny (1) = 1 and takeny (2) = 1 and takeny (3) = 1) or (takenx (4) = true and takenx (5) = true and takenx (6) = true) and (takeny (4) = 1 and takeny (5) = 1 and takeny (6) = 1) or (takenx (7) = true and takenx (8) = true and takenx (9) = true) and (takeny (7) = 1 and takeny (8) = 1 and takeny (9) = 1) or (takenx (1) = true and takenx (5) = true and takenx (9) = true) and (takeny (1) = 1 and takeny (5) = 1 and takeny (9) = 1) or (takenx (7) = true and takenx (5) = true and takenx (3) = true) and (takeny (7) = 1 and takeny (5) = 1 and takeny (3) = 1) or (takenx (1) = true and takenx (4) = true and takenx (7) = true) and (takeny (1) = 1 and takeny (4) = 1 and takeny (7) = 1) or (takenx (2) = true and takenx (5) = true and takenx (8) = true) and (takeny (2) = 1 and takeny (5) = 1 and takeny (8) = 1) or (takenx (3) = true and takenx (6) = true and takenx (9) = true) and (takeny (3) = 1 and takeny (6) = 1 and takeny (9) = 1) then who_won_game := "player 1" end if end User_Won function Computer_Won : boolean if (takenx (1) = true and takenx (2) = true and takenx (3) = true) and (takeny (1) = 2 and takeny (2) = 2 and takeny (3) = 2) or (takenx (4) = true and takenx (5) = true and takenx (6) = true) and (takeny (4) = 2 and takeny (5) = 2 and takeny (6) = 2) or (takenx (7) = true and takenx (8) = true and takenx (9) = true) and (takeny (7) = 2 and takeny (8) = 2 and takeny (9) = 2) or (takenx (1) = true and takenx (5) = true and takenx (9) = true) and (takeny (1) = 2 and takeny (5) = 2 and takeny (9) = 2) or (takenx (7) = true and takenx (5) = true and takenx (3) = true) and (takeny (7) = 2 and takeny (5) = 2 and takeny (3) = 2) or (takenx (1) = true and takenx (4) = true and takenx (7) = true) and (takeny (1) = 2 and takeny (4) = 2 and takeny (7) = 2) or (takenx (2) = true and takenx (5) = true and takenx (8) = true) and (takeny (2) = 2 and takeny (5) = 2 and takeny (8) = 2) or (takenx (3) = true and takenx (6) = true and takenx (9) = true) and (takeny (3) = 2 and takeny (6) = 2 and takeny (9) = 2) then who_won_game := "computer" end if end Computer_Won %-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= %-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= loop setscreen ("offscreenonly") mousewhere (x, y, B) Draw_Screen Initialize (c, u) Plot_Move exit when who_won_game not= "nobody" end loop locate (3, 1) if who_won_game = "player 1" then put "You Won!!!" elsif who_won_game = "computer" then put "The computer won... Oh well. Try again next time" end if :biglaugh: I still haven't eaten today, lol The very last loop needs changed but I'm not sure what version you are using. If you are using pre-4.0.5 then take out where it says "setscreen ("offscreenonly")" Choose your MP3 in the begining and I recommend changing The last statement to "The Computer wins... Oh well. one day you won't be such a looser" LOL OK now I'm going to get some Food. :lol: |
| C-well - May-27-2004 server time |
| This will Help Search for TIC-TAC-TOE I'd make it for you but it costs 75 bucs for a compiler |
| C-well - May-27-2004 server time |
| Got me on this one, I'll ask my brother for help. For others who are curious here is a start. Turing Basics |
| Red Squirrel - May-27-2004 server time |
| That part I'm not sure, it's more of a GUI issue, you have to detect what position the cursor is pressing on and get this data and go from there. |
| yan - May-27-2004 server time |
| lols... neways.. i no how to draw the "x" and "y".. i just dunno how to put it in the position i want it to.. i think its easier to just ask the user to specify which box they want but then it'll be better for my marks if i let the user click on the boxes... bt either way... how do i get them in that box? when i click.. the "x" or "y" appears on the screen but not even inside the boxes |
| Red Squirrel - May-27-2004 server time |
| to draw a line do you have to go by X and Y? If yes just use a formula like: y = 1x to make a diagnal line then use y= -1x to make one that goes the other way then you have an X. You'd have to do a bit more math to make it stop (otherwise it goes to infinity and you'll end up with a hell of a big X lol) I seen some turing code and it seems to work that way so I assume if you just use a bit of basic math you could do it using lines, then set a width of like 3 or something to get a decent thickness. For a O it's a bit more complicated.... but there is a formula I remember learning in math, I just don't know what it is. Scarry... I just realized some of the stuff I learn in math can be used in a real-life application.. ok I just about freaked myself out here.... *pops 2 advils* |
| yan - May-27-2004 server time |
| *sigh* the thing is... this teacher does not teach... we had an assistant teacher through the school year and he is gone now.. this real teacher has no time for us, so doesnt help us much... we are not allowed to talk in class these days because its a final project and we'll get marks off if we do. the only graphics she taught us is to draw a line, a box, a maple leaf and an arc... nothing else.. so, i dont even no wat to do. like how do you make the "X" and "O" in that particular box? i have no idea how. |
| Red Squirrel - May-27-2004 server time |
| I never did turing, but I assume they must of showed you how? It looks like an easy enough language to learn, just hard to find resources since it's anciant. Sorry I can't help. Hopefully you'll figure it out or someone else can help you. |
| yan - May-27-2004 server time |
| This is turing programming language... its for school and i have to stick with turing...even if u have any ideas of how to make the game, cud u please let me no? i need an idea... |
| Red Squirrel - May-27-2004 server time |
| What programming language? If it's php I may be able to help you, but if it's C++ or some other language I don't know much about custom GUI programming to be able to help. I've done boxes with basic buttons and other windows elements but not sure how to make customones (such as X and Os) |
| yan - May-27-2004 server time |
| I'm really having trouble with my assignment which is due in a week. I have to create a tic tac toe game in which players are allowed to take a turn only if they answer the questions correctly. There are 50 questions in total and they should be generated randomly and are not allowed to appear more than once. All I have done so far is a procedure for getting all the 50 questions and the answers and I put them in a file. I opened a new file and opened the file where my questions and answers are stored but how do I randomize it? and I havent specified which is the correct answer(they are all multiple choice) in the first program. Do I specify the correct answer in the file where I input the questions and answers? How do I make my "X" and "O" appear in the box that the mouse clicks on in the tic tac toe board? please help ... I'm really desperate.. i will fail if i do not get this program done |