Computer Science Canada Pong Menu help and WidgetModule.tu opens |
Author: | uknowhoiam [ Wed Mar 25, 2009 6:23 pm ] |
Post subject: | Pong Menu help and WidgetModule.tu opens |
I dont know how to hide my button, after it is clicked, and my instructions wont show up untill i click somewhere else... any help...........here is my code......(sorry i forgot the syntax code >.<) import GUI View.Set ("graphics:650;400,offscreenonly,nobuttonbar") Mouse.ButtonChoose ("multibutton") var xpos, ypos, ypos1, ypos2, ypos3, ypos4 : int := 1 var x : int := maxx div 2 var y : int := maxy div 2 var y1 : int := maxy div 2 - 35 var y2 : int := maxy div 2 + 35 var y3 : int := maxy div 2 - 35 var y4 : int := maxy div 2 + 35 var key : array char of boolean var x5, y5, button : int var speed : int := 5 var counter : int := 0 var score1, score2 := 0 var answer : string (1) var fontID, height, ascent, descent, internalLeading : int colourback (black) %Macking the whole background Black cls %the Black colour can take over the whole screen process DoMusic %Music process Music.PlayFile ("swizz_beat-It_s_me_snitches_instrumental.mp3") %File name end DoMusic procedure leftbar %Left bar procedure drawfillbox (0, y1, 5, y2, white) %The left paddle end leftbar procedure rightbar %Right bar procedure drawfillbox (maxx - 5, y3, maxx, y4, white) %The right paddle end rightbar procedure keyboard %The whole keyboard procedure %player 1 drawfillbox (0, y1, 5, y2, white) %The left paddle delay (2) cls %The paddle is deleted y1 := y1 + 5 %movement of the paddle y2 := y2 + 5 end keyboard % ^ procedure keyboard2 %same thing as above | %player 1 drawfillbox (0, y1, 5, y2, white) delay (2) cls y1 := y1 - 5 y2 := y2 - 5 end keyboard2 procedure mouse %Mouse procedure %player 2 drawfillbox (maxx - 5, y3, maxx, y4, white) %The right paddle View.Update %Avoiding flickering delay (5) cls %deleting the paddle if button = 1 and y3 > 0 then %If left button is clicked then y3 := y3 - 5 %Move the object down y4 := y4 - 5 elsif button = 100 and y4 < maxy then %If right is clicked then y3 := y3 + 5 %Move Up y4 := y4 + 5 end if end mouse procedure ball %Ball procedure %ball drawfilloval (x, y, 5, 5, white) if counter = 100 then %Changing the speed of the ball speed := speed - 1 end if if counter = 200 then speed := speed - 1 end if if counter = 300 then speed := speed - 1 end if if counter = 400 then speed := speed - 1 end if if counter = 500 then speed := speed - 1 end if delay (speed) if x = 10 and y >= y1 and y <= y2 then %If it hits the left paddle then xpos := -xpos %bounce back elsif y >= y3 and y <= y4 and x = maxx - 10 then %If it hits the right paddle xpos := -xpos %then bounce back end if if x < 5 or x >= maxx - 5 then %If the ball hits the wall, then xpos := -xpos %bounce back end if if y < 5 or y >= maxy - 5 then ypos := -ypos end if end ball procedure loc_ball %If the user does not hit the ball then, relocate the x := maxx div 2 %the ball to the centre y := maxy div 2 end loc_ball procedure instruction colour (yellow) put repeat ("%", maxcol) locate (2, maxcol div 2 - 6) put "Instructions" locate (4, 1) put "Move the Left Paddle with the Left and Right Arrows" put "Move the Right Paddle with the mouse buttons" put "First person to get 5 points Wins" end instruction procedure menu fontID := Font.New ("Ariel:72:bold") Font.Sizes (fontID, height, ascent, descent, internalLeading) Font.Draw ("PONG!!", maxrow div 2, maxcol div 2 - 6, fontID, white) var Instruc : int := GUI.CreateButton (maxx - 200, 10, 0, "Instructions", instruction) loop exit when GUI.ProcessEvent end loop end menu menu |
Author: | saltpro15 [ Wed Mar 25, 2009 7:14 pm ] |
Post subject: | RE:Pong Menu help and WidgetModule.tu opens |
sorry, it really is impossible to read without the tags, once a mod fixes it i'll take a look at it |
Author: | DemonWasp [ Wed Mar 25, 2009 8:18 pm ] |
Post subject: | RE:Pong Menu help and WidgetModule.tu opens |
Your screen is set to "offscreenonly", which means you need to call View.Update() whenever you need the screen to update. You should call this right after making your button and right after drawing your instructions. |
Author: | andrew. [ Wed Mar 25, 2009 9:08 pm ] | ||
Post subject: | RE:Pong Menu help and WidgetModule.tu opens | ||
Just for the record, syntax code is:
|
Author: | uknowhoiam [ Thu Mar 26, 2009 4:14 pm ] | ||
Post subject: | RE:Pong Menu help and WidgetModule.tu opens | ||
thank you for the syntax code ok now my menu is alright, but when i ask for the name from the user, the letters wont show up as they are typing, it will only show up when they hit enter here is my code
|
Author: | andrew. [ Thu Mar 26, 2009 5:12 pm ] | ||
Post subject: | RE:Pong Menu help and WidgetModule.tu opens | ||
I believe the reason that the text doesn't show is that you have offscreenonly on. It doesn't update the screen while typing text. You have to turn off offscreenonly before you get the names, then turn it back on after. Like this:
|
Author: | uknowhoiam [ Fri Mar 27, 2009 11:36 pm ] |
Post subject: | RE:Pong Menu help and WidgetModule.tu opens |
thank you it works now ![]() |