Pictures not drawing unless i minimize the window?
Author |
Message |
Pearse
|
Posted: Fri Nov 06, 2009 11:27 am Post subject: Pictures not drawing unless i minimize the window? |
|
|
What is it you are trying to achieve?
Im making a ball game and when your ball collides with another ball, I am trying to make it so the ball cracks open like an egg.
What is the problem you are having?
When the ball collides, the game freezes for about 3 or 4 seconds. While its frozen, I minimize the window, and then i maximize it, and then it shows the picture. I repeat doing this an it shows each picture until the three or four seconds is up, and then the game continues.
Describe what you have tried to solve this problem
I know all the picture file names are correct because the do draw, but only when i minimize the run window and maximizeit. I have no idea what else to do.
Turing: |
var y : int := 200
var x : int := 30
var bool : boolean := true
var char1 : array char of boolean
var y1 : int := 140
var radx1, rady1 : int := 15
var radx2, rady2 : int := 15
var startscreen : int := Pic.FileNew ("BALLS.bmp")
var eggdead1 : int := Pic.FileNew ("eggdead1.bmp")
var eggdead2 : int := Pic.FileNew ("eggdead2.bmp")
var eggdead3 : int := Pic.FileNew ("eggdead3.bmp")
var eggdead4 : int := Pic.FileNew ("eggdead4.bmp")
var eggdead5 : int := Pic.FileNew ("eggdead5.bmp")
var maplevel2 : int := Pic.FileNew ("level2map.bmp")
View.Set ("graphics: 400;400")
View.Set ("offscreenonly")
procedure balldead
Pic.Draw (eggdead1, 200, 200, 0)
delay (500)
cls
Pic.Draw (eggdead2, 200, 200, 0)
delay (500)
cls
Pic.Draw (eggdead3, 200, 200, 0)
delay (500)
cls
Pic.Draw (eggdead4, 200, 200, 0)
delay (500)
cls
Pic.Draw (eggdead5, 200, 200, 0)
delay (1000)
end balldead
procedure maplevel1
drawline (30, 185, 200, 185, red)
drawline (200, 185, 200, 125, red)
drawline (200, 125, 250, 125, red)
drawline (250, 185, 250, 125, red)
drawline (250, 185, 350, 185, red)
drawline (345, 185, 345, 215, green)
drawline (345, 215, 355, 210, green)
drawline (355, 210, 345, 205, green)
end maplevel1
procedure yellowball
if bool = true then
y1 := y1 + 10
elsif bool = false then
y1 := y1 - 10
end if
drawfilloval (220, y1, 15, 15, yellow)
delay (10)
if y1 >= 350 then
bool := false
elsif y1 <= 145 then
bool := true
end if
end yellowball
procedure level2
loop
cls
Pic.Draw (maplevel2, 0, 0, 0)
x := 30
y := 250
Input.KeyDown (char1 )
if char1 (KEY_RIGHT_ARROW) then
x := x + 10
elsif char1 (KEY_LEFT_ARROW) then
x := x - 10
end if
if x < 30 then
x := 30
elsif x > 350 then
x := 350
elsif y < 0 then
y := 400
elsif y > 400 then
y := 0
end if
drawfilloval (x, y, 15, 15, blue)
delay (50)
end loop
end level2
procedure level1
loop
maplevel1
yellowball
Input.KeyDown (char1 )
if char1 (KEY_RIGHT_ARROW) then
x := x + 10
elsif char1 (KEY_LEFT_ARROW) then
x := x - 10
end if
if x < 30 then
x := 30
elsif x > 350 then
x := 350
elsif y < 0 then
y := 400
elsif y > 400 then
y := 0
end if
drawfilloval (x, y, 15, 15, blue)
delay (50)
if x = 190 and y = y1 then
cls
balldead
end if
if x = 200 and y = y1 then
cls
put "You lose"
delay (2000)
end if
if x = 210 and y = y1 then
cls
put "You lose"
delay (2000)
quit
end if
if x = 220 and y = y1 then
cls
put "You lose"
delay (2000)
quit
end if
if x = 230 and y = y1 then
cls
put "You lose"
delay (2000)
quit
end if
if x = 240 and y = y1 then
cls
put "You lose"
delay (2000)
quit
end if
if x = 250 and y = y1 then
cls
put "You lose"
delay (2000)
quit
end if
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if x = 190 and y = y1 + 15 then
cls
put "You lose"
delay (2000)
quit
end if
if y = y1 - 15 then
cls
put "You lose"
delay (2000)
quit
end if
if x = 350 then
level2
end if
View.Update
cls
end loop
end level1
Pic.Draw (startscreen, 0, 0, 0)
loop
Input.KeyDown (char1 )
if char1 (KEY_ENTER ) then
level1
end if
end loop
|
Please specify what version of Turing you are using
4.1.1 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Superskull85
|
Posted: Fri Nov 06, 2009 2:06 pm Post subject: RE:Pictures not drawing unless i minimize the window? |
|
|
I don't have the pictures you used so I am unable to effectively run your code. However, if this is happening after entering the level2 procedure, than it is most likely because you do not have a View.Update () call; which means the window will not update while maximized.
If the window has previously minimized and you than maximize the window, the window will be updated based on whatever was in the off-screen buffer (where changes to the window occur when in "offscreenmode").
What Vew.Update () does is draws whatever is in the off-screen buffer to the window. The same thing happens when you maximize a window that was previously minimized. |
|
|
|
|
|
|
|