%---------------------------------------- %Game Basics % var lives :int:=3% var score :int:=0% var timeElapsed :int:=Time.Elapsed% %----------------------------------------
%---------------------------------------------------- %Boundaries (paddle + ball) % var boundary_x1 :int:=((maxxdivmaxx) - 1) + 20% var boundary_x2 :int:=maxx - 20% var boundary_y1 :int:=maxy - 20% var boundary_y2 :int:=((maxydivmaxy) - 1) + 20% %----------------------------------------------------
procedure Instructions
colorback(16) color(48) cls locate(4, 1) put"The objective of the game is..." locate(7, 1) color(58) put"to destroy all of the blocks on your side of the screen (bottom)" locate(10, 1) color(73) put"Before the computer destroys all of his blocks on his side of the screen (top)" locate(13, 1) color(81) put"You will use the 'Left' and 'Right' Arrow keys to move left and right" locate(16, 1) color(96) put"Good Luck and go smash some blocks. HINT : You only have 3 Lives!" end Instructions
procedure TheTitleScreen
var game_Button :int:=GUI.CreateButton(300, 275, 0, "Click To Play!", TheGame) var instruction :string locate(18, 10) put"Please hold 'Click to Play' while you type your answer below!" locate(20, 10) put"You will be redirected to the instructions so keep holding your mouse." locate(22, 10) put"Or drag away from 'Click to Play' then read and Click it afterwards." locate(24, 10) put"Do you want to see the game Instructions? "..
get instruction
if instruction ="yes"then
Instructions
else
Instructions
endif end TheTitleScreen
procedure returnBack
var go_back :char:="n" loop get go_back
if go_back ="y"then
TheTitleScreen
endif endloop end returnBack
Posted: Thu Dec 08, 2011 8:17 pm Post subject: RE:heavy flickering problem
Tony i checked out that document but i tried putting those everywhere still doesnt work... where exactly or how exactly do i have to put the View.Set ("offscreenonly")
and View.Update?
Tony
Posted: Thu Dec 08, 2011 8:21 pm Post subject: RE:heavy flickering problem
You were indeed missing View.Set ("offscreenonly"). Good.
You should defer to the documentation of View.Update and View.Set for examples, or to the tutorial linked to from Turing Walkthrough.
Posted: Thu Dec 08, 2011 10:01 pm Post subject: RE:heavy flickering problem
"putting those everywhere" is exactly the wrong thing to do.
Aange10
Posted: Fri Dec 09, 2011 1:11 am Post subject: RE:heavy flickering problem
Doing what normal, smart people would, you'd look at the stickies & announcements on the forums. Namely the FAQ, which completely answers your question.
Posted: Fri Dec 09, 2011 6:41 am Post subject: Re: heavy flickering problem
First of all, your View.Update ("offscreenonly") should be at the very beginning of your code, before anything happens. Then you put your View.Update after your drawfillbox's,drawfilloval's,put's,ect (anything thats visible on the screen) <-- you only put one View.Update after the code for ALL your visible things hope it helps
example:
(wrong way - will flicker)
%----------------------------------------------------------------------------%
loop
drawfilloval (100,100,20,20,7) % <-- this would flicker like crazy
cls
end loop
(right way - will not flicker)
%-----------------------------------------------------------------------------%
View.Set ("offscreenonly") % <-- at the beginning
loop
drawfilloval (100,100,20,20,7) % <-- You can put anything inbetween your "loop" and your "View.Update" and you can have
% more than one thing
View.Update % <-- After your drawfill's etc. and BEFORE your cls
cls
end loop
Posted: Mon Dec 12, 2011 4:35 pm Post subject: RE:heavy flickering problem
%Ilan Portman
%Grade 11 Final Project
%Brick Breaker vs AI
%December 9th, 2011
import GUI
View.Set ("graphics:638;690")
var PicID : int
var x : int := 700
var y : int := 500
PicID := Pic.FileNew ("ball02.jpg")
Pic.Draw (PicID, maxx div 2 - (638 div 2), maxy div 2 - (690 div 2), picCopy)
procedure TheGame
setscreen ("graphics:700;700")
%----------------------------------------
%Game Basics %
var lives : int := 3 %
var score : int := 0 %
var timeElapsed : int := Time.Elapsed %
%----------------------------------------
%----------------------------------------------------
%Boundaries (paddle + ball) %
var boundary_x1 : int := ((maxx div maxx) - 1) + 20 %
var boundary_x2 : int := maxx - 20 %
var boundary_y1 : int := maxy - 20 %
var boundary_y2 : int := ((maxy div maxy) - 1) + 20 %
%----------------------------------------------------
var arrowKeys : array char of boolean
loop
drawfillbox (5, maxy - 25, maxx - 5, maxy, 48)
locate (1, 10)
put "Lives: ", lives
locate (1, 30)
put "Score: ", score
locate (1, 50)
put "Game Time: ", Time.Elapsed / 1000
Input.KeyDown (arrowKeys)
if arrowKeys (KEY_RIGHT_ARROW) then
x1 += 5
x2 += 5
end if
if arrowKeys (KEY_LEFT_ARROW) then
x2 -= 5
x1 -= 5
end if
if x1 > 250 and x2 < 350 then
x1 := 100
elsif x1 < 250 and x2 > 350 then
x2 := 100
elsif y1 > 25 and y2 < 50 then
y1 := 25
elsif y1 < 25 and y2 > 50 then
y2 := 25
end if
if arrowKeys (KEY_ESC) then
cls
exit
end if
drawfillbox (x1, y1, x2, y2, red)
delay (15)
cls
drawbox (20, 20, maxx - 20, maxy - 20, 51)
drawbox (5, 5, maxx - 5, maxy - 5, 51)
drawfillbox (250, 900, 350, 925, 101)
drawfillbox (20, 355, maxx - 20, 360, 51)
drawfilloval (ball_x1, ball_y1, 15, 15, 48)
drawfill (maxx - 15, maxy - 15, 71, 51)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
View.UpdateArea (0,0,maxx,maxy)
%%%% I PUT IT IN THERE AND IT STILL FLICKERS!
if ball_y1 < 25 then
lives -= 1
% put lives
end if
end loop
end TheGame
procedure Instructions
colorback (16)
color (48)
cls
locate (4, 1)
put "The objective of the game is..."
locate (7, 1)
color (58)
put "to destroy all of the blocks on your side of the screen (bottom)"
locate (10, 1)
color (73)
put "Before the computer destroys all of his blocks on his side of the screen (top)"
locate (13, 1)
color (81)
put "You will use the 'Left' and 'Right' Arrow keys to move left and right"
locate (16, 1)
color (96)
put "Good Luck and go smash some blocks. HINT : You only have 3 Lives!"
end Instructions
procedure TheTitleScreen
var font1 : int
font1 := Font.New ("Arial:13")
assert font1 > 0
Pic.Draw (PicID, maxx div 2 - (638 div 2), maxy div 2 - (690 div 2), picCopy)
var game_Button : int := GUI.CreateButton (265, 275, 0, "Click To Play!", TheGame)
var instruction : string
locate (37, 4)
Font.Draw ("Please hold 'Click to Play' while you type your answer below!", 50, 150, font1, yellow)
locate (38, 4)
Font.Draw ("You will be redirected to the instructions so keep holding your mouse.", 50, 125, font1, green)
locate (39, 4)
Font.Draw ("Or drag away from 'Click to Play' then read and Click it afterwards.", 50, 75, font1, yellow)
locate (40, 4)
Font.Draw ("Do you want to see the game Instructions? ", 50, 40, font1, green)
locate (50, 47)
get instruction
if instruction = "yes" then
Instructions
else
Instructions
end if
end TheTitleScreen
procedure returnBack
var go_back : char := "n"
loop
get go_back
if go_back = "y" then
TheTitleScreen
end if
end loop
end returnBack
TheTitleScreen
loop
exit when GUI.ProcessEvent
end loop
Sponsor Sponsor
Velocity
Posted: Mon Dec 12, 2011 4:43 pm Post subject: RE:heavy flickering problem
%----------------------------------------
%Game Basics %
var lives : int := 3 %
var score : int := 0 %
var timeElapsed : int := Time.Elapsed %
%----------------------------------------
%----------------------------------------------------
%Boundaries (paddle + ball) %
var boundary_x1 : int := ((maxx div maxx) - 1) + 20 %
var boundary_x2 : int := maxx - 20 %
var boundary_y1 : int := maxy - 20 %
var boundary_y2 : int := ((maxy div maxy) - 1) + 20 %
%----------------------------------------------------
var arrowKeys : array char of boolean
loop
locate (1, 10)
put "Lives: ", lives
locate (1, 30)
put "Score: ", score
locate (1, 50)
put "Game Time: ", Time.Elapsed / 1000
Input.KeyDown (arrowKeys)
if arrowKeys (KEY_RIGHT_ARROW) then
x1 += 5
x2 += 5
end if
if arrowKeys (KEY_LEFT_ARROW) then
x2 -= 5
x1 -= 5
end if
if x1 > 250 and x2 < 350 then
x1 := 100
elsif x1 < 250 and x2 > 350 then
x2 := 100
elsif y1 > 25 and y2 < 50 then
y1 := 25
elsif y1 < 25 and y2 > 50 then
y2 := 25
end if
if arrowKeys (KEY_ESC) then
cls
exit
end if
drawfillbox (x1, y1, x2, y2, red)
delay (15)
cls
drawbox (20, 20, maxx - 20, maxy - 20, 51)
drawbox (5, 5, maxx - 5, maxy - 5, 51)
drawfillbox (250, 900, 350, 925, 101)
drawfillbox (20, 355, maxx - 20, 360, 51)
drawfilloval (ball_x1, ball_y1, 15, 15, 48)
drawfill (maxx - 15, maxy - 15, 71, 51)
View.UpdateArea (0,0,maxx,maxy)
Time.DelaySinceLast (50)
cls
end loop
Velocity
Posted: Mon Dec 12, 2011 4:44 pm Post subject: RE:heavy flickering problem
I added the thing at the bottom, i read the faq, it doesnt help.
Tony
Posted: Mon Dec 12, 2011 4:59 pm Post subject: Re: heavy flickering problem
chipanpriest @ Fri Dec 09, 2011 6:41 am wrote:
First of all, your View.Update ("offscreenonly") should be at the very beginning of your code, before anything happens.