Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Help With GUI - SO MUCH APPRECIATED!
Author Message
icedesi

Posted: 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

Sponsor
Sponsor

kyoshiro

Posted: Mon Jan 05, 2004 10:20 pm   Post subject: (No 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
Thuged_Out_G

Posted: Tue Jan 06, 2004 4:39 pm   Post subject: (No subject)

hmm
your code looks very similar to another program submitted by maverick in the source code forum

 code: %n00bish bouncing ball setscreen("nocursor") setscreen("graphics:400;350") var ballx,bally,ballxdir,ballydir:int drawfillbox(1,1,400,350,blue) randint(ballx,0,maxx) randint(bally,0,maxy) ballxdir:=1 ballydir:=1 loop     drawfilloval(ballx,bally,5,5,12)     delay(1)     drawfilloval(ballx,bally,5,5,0)     if ballx>maxx and ballxdir>0 then ballxdir:=-ballxdir elsif ballx<0 and ballxdir<0 then ballxdir:=-ballxdir elsif bally>maxy and ballydir>0 then ballydir:=-ballydir elsif bally<0 and ballydir<0 then ballydir:=-ballydir end if ballx +=ballxdir bally+=ballydir end loop
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 3 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: