flashing lights loop with falling snow problem
Author |
Message |
Bozey
|
Posted: Sun Nov 28, 2010 7:38 pm Post subject: flashing lights loop with falling snow problem |
|
|
What is it you are trying to achieve?
someone to guide me
What is the problem you are having?
falling snow loop and flashing lights loop not working together and cant split them
Describe what you have tried to solve this problem
broke up to procs and tryed removing offscreenonly (worked but had flickering)
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
View.Set ("offscreenonly")
const NoOfFlakes := 700
var flakeX : array 1 .. NoOfFlakes of int
var flakeY : array 1 .. NoOfFlakes of int
for flake : 1 .. NoOfFlakes
flakeX (flake ) := Rand.Int (0, maxx)
flakeY (flake ) := Rand.Int (0, maxy)
end for
var pic2 : int: = Pic.FileNew ("c:/Users/Pwnage/Downloads/night-sky.jpg")
loop
Pic.Draw (pic2, 0, 200, picUnderMerge)
drawfillbox (200, 200, 350, 274, black)
drawfillbox (200, 20, 400, 200, black)
Draw.FillBox (0, 0, 800, 17, white)
drawfillbox (400, 200, 1000, 0, 0)
drawfill (1, 16, white, white)
drawfillbox (20, 20, 200, 200, blue)
drawline (20, 200, 200, 200, white)
drawline (20, 200, 20, 20, white)
drawline (20, 20, 200, 20, white)
drawline (200, 20, 200, 200, white)
drawdot (115, 275, white)
drawline (115, 275, 20, 200, white)
drawline (115, 275, 200, 200, white)
drawline (115, 275, 250, 350, white)
drawdot (350, 270, white)
drawline (250, 350, 350, 270, white)
drawline (200, 200, 350, 270, white)
drawline (350, 270, 350, 180, white)
drawline (80, 80, 80, 20, white)
drawline (80, 80, 125, 80, white)
drawline (125, 80, 125, 20, white)
drawdot (40, 170, white)
drawbox (40, 170, 80, 130, white)
drawfill (41, 171, black, white)
drawdot (140, 170, 1)
drawbox (140, 170, 180, 130, white)
drawfill (141, 135, blue, white)
drawdot (230, 270, 1)
drawline (230, 270, 230, 310, white)
drawline (210, 250, 210, 300, white)
drawline (190, 270, 190, 310, white)
drawline (190, 270, 210, 250, white)
drawline (210, 250, 230, 270, white)
drawline (190, 310, 210, 300, white)
drawline (210, 300, 230, 310, white)
drawline (210, 320, 230, 310, white)
drawline (210, 320, 190, 310, white)
drawline (205, 10, 360, 95, white)
drawline (205, 100, 360, 185, white)
drawline (205, 10, 205, 100, white)
drawline (360, 185, 360, 95, white)
drawfill (210, 80, red, white)
drawfilloval (570, 345, 35, 35, grey)
drawfillbox (500, 10, 520, 50, brown)
drawline (580, 50, 440, 50, green)
drawdot (510, 100, green)
drawline (580, 50, 510, 100, green)
drawline (440, 50, 510, 100, green)
drawline (460, 100, 560, 100, green)
drawline (460, 100, 510, 150, green)
drawline (510, 150, 560, 100, green)
drawline (540, 150, 480, 150, green)
drawline (540, 150, 510, 200, green)
drawline (480, 150, 510, 200, green)
drawfill (485, 155, green, green)
drawfill (470, 105, green, green)
drawfill (450, 51, green, green)
drawline (350, 90, 350, 185, white)
drawline (340, 83, 340, 173, white)
drawline (330, 78, 330, 167, white)
drawline (320, 73, 320, 161, white)
drawline (310, 68, 310, 155, white)
drawline (300, 62, 300, 150, white)
drawline (290, 57, 290, 145, white)
drawline (280, 52, 280, 140, white)
drawline (270, 47, 270, 135, white)
drawline (260, 42, 260, 130, white)
drawline (250, 37, 250, 125, white)
drawline (240, 32, 240, 120, white)
drawline (230, 27, 230, 115, white)
drawline (220, 22, 220, 108, white)
drawline (210, 17, 210, 102, white)
drawfillbox (400, 0, 362, 200, white)
drawline (210, 12, 360, 94, white)
drawline (210, 13, 360, 96, white)
drawline (210, 14, 366, 97, white)
drawline (210, 15, 367, 98, white)
drawline (210, 17, 372, 100, white)
drawline (360, 70, 360, 95, white)
drawline (360, 70, 220, 20, white)
drawline (220, 20, 360, 95, white)
drawfill (305, 60, 0, 0)
drawfillbox (400, 200, 360, 80, white)
drawline (400, 0, 400, 000, white)
drawline (401, 0, 401, 200, white)
drawline (402, 0, 402, 200, white)
drawline (403, 0, 403, 200, white)
drawline (404, 0, 404, 200, white)
drawline (405, 0, 405, 200, white)
drawline (406, 0, 406, 200, white)
drawline (407, 0, 407, 200, white)
drawline (408, 0, 408, 200, white)
drawline (409, 0, 409, 200, white)
drawline (410, 0, 410, 200, white)
drawline (411, 0, 411, 200, white)
drawline (412, 0, 412, 200, white)
drawline (413, 0, 413, 200, white)
drawline (414, 0, 414, 200, white)
drawline (415, 0, 415, 200, white)
drawline (416, 0, 416, 200, white)
drawline (417, 0, 417, 200, white)
drawline (418, 0, 418, 200, white)
drawline (419, 0, 419, 200, white)
drawline (420, 0, 420, 200, white)
drawline (421, 0, 421, 200, white)
drawline (422, 0, 422, 200, white)
drawline (423, 0, 423, 200, white)
drawline (424, 0, 424, 200, white)
drawline (425, 0, 425, 200, white)
drawline (426, 0, 426, 200, white)
drawline (427, 0, 427, 200, white)
drawline (428, 0, 428, 200, white)
drawline (429, 0, 429, 200, white)
drawline (430, 0, 430, 200, white)
drawline (431, 0, 431, 200, white)
drawline (432, 0, 432, 200, white)
drawline (433, 0, 433, 200, white)
drawline (434, 0, 434, 200, white)
drawline (400, 0, 400, 200, white)
drawline (400, 0, 300, 0, white)
drawline (195, 8, 400, 100, 0)
drawline (190, 8, 400, 100, 0)
drawline (198, 10, 400, 100, 0)
drawline (400, 100, 350, 50, 0)
drawfill (300, 40, white, white)
drawline (400, 100, 350, 52, white)
drawline (400, 100, 350, 54, white)
drawfillbox (500, 10, 420, 44, white)
drawfillbox (500, 50, 445, 40, white)
drawfillbox (0, 0, 20, 200, white)
drawfillbox (380, 200, 350, 183, 0)
drawfill (200, 205, white, white)
drawfill (100, 205, 0, 0)
drawline (200, 200, 115, 275, black)
drawline (20, 200, 115, 275, black)
for flake : 1 .. NoOfFlakes
flakeY (flake ) - = Rand.Int (1, 1)
if flakeY (flake ) < 0 then
flakeY (flake ) := Rand.Int (1, maxy)
flakeY (flake ) := Rand.Int (1, maxx)
end if
Draw.FillOval (flakeX (flake ), flakeY (flake ), 1, 1, white)
end for
drawfilloval (460, 100, 5, 5, brightblue)
drawfilloval (560, 100, 5, 5, brightblue)
drawfilloval (580, 50, 5, 5, brightblue)
drawfilloval (440, 50, 5, 5, brightblue)
drawfilloval (480, 150, 5, 5, brightblue)
drawfilloval (540, 150, 5, 5, brightblue)
drawfilloval (510, 160, 5, 5, brightblue)
drawfilloval (510, 110, 5, 5, brightblue)
drawfilloval (510, 60, 5, 5, brightblue)
delay (500) % this is the delay i want it as, but whenever i try move it to another loop it affects the output and it gets messed
drawfilloval (460, 100, 5, 5, red)
drawfilloval (560, 100, 5, 5, red)
drawfilloval (580, 50, 5, 5, red)
drawfilloval (440, 50, 5, 5, red)
drawfilloval (480, 150, 5, 5, red)
drawfilloval (540, 150, 5, 5, red)
drawfilloval (510, 160, 5, 5, red)
drawfilloval (510, 110, 5, 5, red)
drawfilloval (510, 60, 5, 5, red)
delay (500)
View.Update
end loop
|
Please specify what version of Turing you are using
4.0.3 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
TokenHerbz
|
Posted: Sun Nov 28, 2010 11:15 pm Post subject: Re: flashing lights loop with falling snow problem |
|
|
Okay, i'm going to help you out a bit. 1st with YOUR program.
remove all the "delays" in it, and Add a delay (20) maybe (50) AFTER the "View.Update" at the bottom of the loop.
you have your snow flakes appearing after they hit the ground anywhere on the map, so "dots" tend to appear out of no where, you should fix this by spawning them up in the clouds. its not so bad when you first start the picture, as it gives you a sense that its already been snowing.
i have no idea what you mean about "Lights"... |
|
|
|
|
|
Bozey
|
Posted: Mon Nov 29, 2010 7:44 am Post subject: Re: flashing lights loop with falling snow problem |
|
|
ok thank you this is what i meant when i said lights this is how it is suppose to work, (these will be on the tree)
loop
drawfilloval (460, 100, 5, 5, brightblue)
drawfilloval (560, 100, 5, 5, brightblue)
drawfilloval (580, 50, 5, 5, brightblue)
drawfilloval (440, 50, 5, 5, brightblue)
drawfilloval (480, 150, 5, 5, brightblue)
drawfilloval (540, 150, 5, 5, brightblue)
drawfilloval (510, 160, 5, 5, brightblue)
drawfilloval (510, 110, 5, 5, brightblue)
drawfilloval (510, 60, 5, 5, brightblue)
delay (500)
drawfilloval (460, 100, 5, 5, red)
drawfilloval (560, 100, 5, 5, red)
drawfilloval (580, 50, 5, 5, red)
drawfilloval (440, 50, 5, 5, red)
drawfilloval (480, 150, 5, 5, red)
drawfilloval (540, 150, 5, 5, red)
drawfilloval (510, 160, 5, 5, red)
drawfilloval (510, 110, 5, 5, red)
drawfilloval (510, 60, 5, 5, red)
delay (500)
end loop |
|
|
|
|
|
copthesaint
|
Posted: Mon Nov 29, 2010 12:16 pm Post subject: Re: flashing lights loop with falling snow problem |
|
|
Turing: | View.Set ("Graphics,Offscreenonly,nobuttonbar")
var dynIndex, bound : int := - 1
var x, y, c : int
var xEx, yEx, cEx, iDEx : flexible array 0 .. - 1 of int
proc initFlake
dynIndex := - 1
for i : 0 .. bound
if iDEx (i ) ~ = 1000 + i then
dynIndex := i
exit
end if
end for
if dynIndex = - 1 then
dynIndex := upper (iDEx ) + 1
new xEx, dynIndex
new yEx, dynIndex
new cEx, dynIndex
new iDEx, dynIndex
xEx (dynIndex ) := x
yEx (dynIndex ) := y
cEx (dynIndex ) := c
iDEx (dynIndex ) := 1000 + dynIndex
bound := dynIndex
else
xEx (dynIndex ) := x
yEx (dynIndex ) := y
cEx (dynIndex ) := c
iDEx (dynIndex ) := 1000 + dynIndex
end if
end initFlake
proc drawFlake
for i : 0 .. bound
if iDEx (i ) = 1000 + i then
drawdot (xEx (i ), yEx (i ), cEx (i ))
end if
end for
end drawFlake
proc newFlake
x := Rand.Int (0, maxx)
y := maxy - Rand.Int (1, 100)
c := Rand.Int (23, 25)
initFlake
end newFlake
fcn lastFlake : int
result 1000 + dynIndex
end lastFlake
for i : 0 .. 18
newFlake
end for
loop
drawfillbox (0, 0, maxx, maxy, black)
drawFlake
View.Update
cls
end loop |
|
|
|
|
|
|
TokenHerbz
|
Posted: Mon Nov 29, 2010 2:12 pm Post subject: RE:flashing lights loop with falling snow problem |
|
|
don't use his code,
how delays work is it "pauses" your game. you don't want to use so many of them, infact the only reason i use them is to slow down the speed of the game.
you definately dont want to have more then 1 delays in your loop when your trying to do this.
Add another variable for the lights, and use it how you wish to but the idea would be to "Turn lights red if variable is 1 status, and turn lights blue if this variables another status" and run that in your main loop WITH the falling snow, so everything runs smoothly.
attempt this and i'll assist you further. |
|
|
|
|
|
copthesaint
|
Posted: Mon Nov 29, 2010 3:30 pm Post subject: RE:flashing lights loop with falling snow problem |
|
|
Lol I wasn't posting it for him to use. Its just to show him how you can organize all of the flakes the way it seems he wanted to... from what he posted he should understand what I did from that example.
Of course I wasn't posting it for him to use to hand in or something... it was just to help him... |
|
|
|
|
|
TokenHerbz
|
Posted: Tue Nov 30, 2010 8:34 am Post subject: RE:flashing lights loop with falling snow problem |
|
|
I don't think its helpful to him because I feel he wouldn't be able to understand it, having limited knowledge in the topic, Judging by his original code. So we should first assist him at his level of knowledge to allow him to grasp the basic ideas behind whats trying to be accomplished, which then later could be put to much more "efficient and effective" code. |
|
|
|
|
|
|
|