Computer Science Canada Help me with Randomized Lightning Bolts! :p |
Author: | Majesty [ Fri Oct 24, 2003 4:34 am ] |
Post subject: | Help me with Randomized Lightning Bolts! :p |
Hey guys, just trying to figure out alittle problem, hopefully you'll beable to answer me sometime today, anyway here it is im trying to make randomized lightning, coming from the top of the screen, these is what i have so far, its saying x has been previously declared, but if i take out var x:real then it says x has not been declared %lightning bolt var lightning:real var y:int:=399 var r1,r2:int var x:real for x:-2..340 end for for size:5..8 end for Draw.ThickLine(x,y,502,361,size,yellow) Draw.ThickLine(x,y,515,349,size,yellow) <-- 1 lightning bolt, Draw.ThickLine(x,y,488,324,size,yellow) something along those lines, hopefully you get the idea.. is it possible to choose the randomized thing, and add to it? soo i can do something like this * ascii graphics ;p * \ \ \ \ / / \ \ so it looks like the lightning is forked? |
Author: | Mazer [ Fri Oct 24, 2003 7:58 am ] |
Post subject: | |
i made a lightning kind of effect a while ago http://www.compsci.ca/v2/viewtopic.php?t=766 try looking at that, if any of it conduses you let me know and i'll help you. |
Author: | AsianSensation [ Fri Oct 24, 2003 8:00 am ] |
Post subject: | |
well, it looks like that you declared x twice, one as a real number, and the other as the id for the FOR loop. give those different names, and put those drawline procedures in the for loop. if you want an example of lightning, Mazer and Homer both did a very very cool one, search for it, it has the complete source code somewhere. |
Author: | Majesty [ Fri Oct 24, 2003 12:01 pm ] | ||
Post subject: | |||
well not exactly what im looking for, but thanks anyway. im trying to make forked lightning start from the top of the screen, and come down, forking in different directions. this is something for a single lightning bolt that im trying to do
i want it to randomly fork like that, i have no clue how to have a random thing ( lightning ) continue ( fork ) from a randomly selected area. [/code] |
Author: | Tony [ Fri Oct 24, 2003 1:07 pm ] | ||||
Post subject: | |||||
well I think you're looking for
It returns a random integer value between low and high values. What you do is you keep X/Y variables for the point up to which your drew your lightning so far. Then randomly select the next point and draw the line up to there, and store the new values. You continue in a loop until the lightning has reached the ground
|
Author: | Majesty [ Fri Oct 24, 2003 5:31 pm ] |
Post subject: | |
how do you store a Rand.Int value? |
Author: | Tony [ Fri Oct 24, 2003 6:11 pm ] | ||
Post subject: | |||
the most basic example of a lightning.
Just that instead of Draw.Dot, you'd have to modify the code to make it Draw.ThinkLine |