Computer Science Canada Help With GUI - SO MUCH APPRECIATED! |
Author: | icedesi [ Mon Jan 05, 2004 9:50 pm ] |
Post subject: | Help With GUI - SO MUCH APPRECIATED! |
Hi, I'm Really Quite New at Turing, My Teacher expects me to Make A Program in which where you can choose between different Difficulties of a ball moving randomly across the screen. The Objective: Record the number of clicks the user has made on the moving ball, I have two problems, one, i cannot seem to use 'case' in defining variables, and two, creating a functional counter that records the amount of clicks i have made on the moving ball, much help appreciated, THank YOU! Quote: %The 'Ball' Game (Original) %%%%%% Choosing Portion %%%%%%% setscreen ("graphics:400;350") var easy, medium, hard, text : string var final : int var x, y, button: int var counter := 0 const E1 := 0.1 const M1 := 0.3 const H1 := 0.9 get text %%%%%% Function Portion %%%%%% var ballx, bally : real var ballxmov, ballymov : real ballx := Rand.Int (0, maxx) bally := Rand.Int (0, maxy) ballymov := 0.001 ballxmov := 0.001 loop cls colorback (blue) drawfilloval (round (ballx), round (bally), 5, 5, yellow) if ballx > maxx and ballxmov > 0 then ballxmov := -ballxmov elsif ballx < 0 and ballxmov < 0 then ballxmov := -ballxmov elsif bally > maxy and ballymov > 0 then ballymov := -ballymov elsif bally < 0 and ballymov < 0 then ballymov := -ballymov end if ballx += ballxmov bally += ballymov View.Update end loop %%%% Counter Portion %%%%% loop Mouse.Where (x, y, button) if button = 1 and ballx = x and bally = y then counter := counter + 1 else exit when button = 1 and x not = ballx and y not = bally end if end loop put counter |
Author: | kyoshiro [ Mon Jan 05, 2004 10:20 pm ] |
Post subject: | |
your ball doesnt look like it's moving around the screen. Perhaps use randomize or create a path in which the ball can move. Mayb you can make the ball move in a Z shape across the screen. Also you can add delays and cls. The higher difficulty the user chooses you can put less delay in the movement. You also need a if elsif statement with a buttonwait command. You can put all of this in a loop also. Check your turing help for info on button wait. Basically put all your code into a 1 loop. For your counter, use the if statement, if the mouse hits the x,y coords of the ball, then u add 1 to your counter and put it on the screen. hope this helps o.o |
Author: | Thuged_Out_G [ Tue Jan 06, 2004 4:39 pm ] | ||
Post subject: | |||
hmm your code looks very similar to another program submitted by maverick in the source code forum
|