%#######VARS#######% var posy1 :int:=200 var posx2 :int:=400 var motorboat :int:=Pic.FileNew("motor boat.bmp") var handwavex :int:=maxx - 270 var handwavey :int:=265 var handwave :int:=5 var T :int:=14 var p, SunCount :int:=0
Posted: Thu May 16, 2013 12:51 pm Post subject: RE:need help to reduce flickering
a friend added the forks (this guy knows his stuff) not me and yea i dont understand a thing... my teacher goes on the method of learn yourself and ive been here for like two months. i just need help, this is my summative its due in a week!!!
Nathan4102
Posted: Thu May 16, 2013 12:58 pm Post subject: RE:need help to reduce flickering
That's what happens when you slack off in class. You should read the Turing Docs pages on "fork", "View.Update" and "View.Set", specifically the "offscreenonly" section. Forks aren't the best method, but they'll work. My personal preference is to have procedures for both events inside a conditional loop (The "loop/end loop" loop). Good luck!
Ghostblade
Posted: Thu May 16, 2013 1:22 pm Post subject: RE:need help to reduce flickering
the guy isnt in my class..... he does courses in the summer during his own free time. I dont slack off, as i said earlier, i must teach myself. ive found a way to reduce the flicker but i need to add some sort of cls because my animations leave a trail. this is my code:
%############Loading Screen#############%
var loadPercent : int := 0
var loadingMessage : string := ""
Font.Draw ( loadingMessage, 30, maxy div 2 + 40, loadingMessageFont, black )
% The actual bar and the percentage listed for it
Draw.FillBox (0, maxy div 2 + 15, maxx, maxy div 2 + 20, black )
Draw.FillBox (0, maxy div 2 - 15, maxx, maxy div 2 - 20, black )
Draw.FillBox (0, maxy div 2 - 15, round (maxx / 100 * loadPercent), maxy div 2 + 15, darkgrey)
Font.Draw ( intstr(loadPercent)+"%", maxx div 2 - 8, maxy div 2 - 8, loadingPercentFont, brightred )
%#######VARS#######%
var posy1 :int:=200
var posx2 : int:= 400
var motorboat : int := Pic.FileNew ("motor boat.bmp")
var handwavex : int := maxx - 270
var handwavey : int := 265
var handwave : int := 5
var newcolour : int := 205
if handwavex < maxx - 300 then
handwave := -handwave
elsif handwavex > maxx - 260 then
handwave := -handwave
end if
end loop
end person
fork person
fork boat
fork moon
Nathan4102
Posted: Thu May 16, 2013 1:32 pm Post subject: RE:need help to reduce flickering
I don't think it's possible to remove the trail without excessive flickering using forks. All these processes are running independent of eachother, so you can't say "Once they've all been drawn, update the screen and clear the buffer". Again, I suggest procedures.
Sponsor Sponsor
Tony
Posted: Thu May 16, 2013 1:46 pm Post subject: Re: RE:need help to reduce flickering
Ghostblade @ Thu May 16, 2013 12:51 pm wrote:
a friend added the forks (this guy knows his stuff) not me and yea i dont understand a thing...
Don't forget to add a citation for his contributions to your project.
You can then ask him to explain why forks can't work with view.update without implementing synchronization.
Posted: Fri May 17, 2013 11:34 am Post subject: RE:need help to reduce flickering
ok thanks guys!
Raknarg
Posted: Fri May 17, 2013 11:45 am Post subject: RE:need help to reduce flickering
Is it possible to synchronize processes, tony?
Ghostblade
Posted: Fri May 17, 2013 12:06 pm Post subject: RE:need help to reduce flickering
im using loops now and all is good no flickering but for some reason ONLY my first loop and background show up? should i put them all in one large loop with procs inside?
Ghostblade
Posted: Fri May 17, 2013 12:15 pm Post subject: RE:need help to reduce flickering
current code:
%############Loading Screen#############%
var loadPercent : int := 0
var loadingMessage : string := ""
Font.Draw ( loadingMessage, 30, maxy div 2 + 40, loadingMessageFont, black )
% The actual bar and the percentage listed for it
Draw.FillBox (0, maxy div 2 + 15, maxx, maxy div 2 + 20, black )
Draw.FillBox (0, maxy div 2 - 15, maxx, maxy div 2 - 20, black )
Draw.FillBox (0, maxy div 2 - 15, round (maxx / 100 * loadPercent), maxy div 2 + 15, darkgrey)
Font.Draw ( intstr(loadPercent)+"%", maxx div 2 - 8, maxy div 2 - 8, loadingPercentFont, brightred )
exit when loadPercent >= 100
end loop
end loadGame
loadGame
%####SETSCREEN###%
setscreen("graphics:max;max")
View.Update
setscreen ("offscreenonly")
cls
%#######VARS#######%
var posy1 :int:=200
var posx2 : int:= 400
var motorboat : int := Pic.FileNew ("motor boat.bmp")
var handwavex : int := maxx - 270
var handwavey : int := 265
var handwave : int := 5
var newcolour : int := 205
var X, Y : int := 700
var R1, R2 : int := 1
var DX, DY : int := -1
var A, B : int :=700
var C1, C2 : int :=1
var DA, DB : int :=-1
if handwavex < maxx - 300 then
handwave := -handwave
elsif handwavex > maxx - 260 then
handwave := -handwave
end if
end loop
%####SHOOTINGSTAR####%
loop
drawfilloval (X, Y, R1, R2, 31)
delay (2)
drawfilloval (X, Y, R1, R2, 31)
X := X + DX
Y := Y + DY
exit when X=400
end loop
delay (200)
loop
drawfilloval (A, B, C1, C2, 127)
delay (2)
drawfilloval (A, B, C1, C2, 127)
A :=A+DA
B :=B+DB
exit when A=400
end loop
end loop
DemonWasp
Posted: Fri May 17, 2013 1:56 pm Post subject: Re: RE:need help to reduce flickering
Raknarg @ Fri May 17, 2013 11:45 am wrote:
Is it possible to synchronize processes, tony?
Possible? Yes. You can use either Dekker's algorithm if Turing's assignment isn't atomic or Peterson's algorithm is assignment is atomic. These are typically covered by a university-level CS course (CS343 Concurrent and Parallel, at UWaterloo)
Based on those, you can implement critical sections. With critical sections, you should be able to implement a Barrier, and Locks, which should allow you to synchronize these methods.
However, it's completely pointless because Turing doesn't actually provide multithreaded execution of Turing code. The Turing runtime actually uses 3-4 threads but I expect that most of those are internal (to handle playing music and Turing's own GUI), while one handles running the program running inside Turing.
You would be introducing a LOT of problems and complexity for a guaranteed loss in performance.
Just use procedures.
Edit: had to fix up links because the forum doesn't seem to like apostrophes or brackets (') in URL entries.
Nathan4102
Posted: Fri May 17, 2013 3:04 pm Post subject: RE:need help to reduce flickering
@Demon, are you sure Turing uses a dedicated thread for forked music? I've made programs that run at 25% speed when music is playing, it's horrible!
@Ghost, could you put the code with indentation in turing syntax tags?