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

Username:   Password: 
 RegisterRegister   
 Help With GUI - SO MUCH APPRECIATED!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
icedesi




PostPosted: 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
Sponsor
sponsor
kyoshiro




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




PostPosted: 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:   
   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  [ 3 Posts ]
Jump to:   


Style:  
Search: