Computer Science Canada

explosion help

Author:  Schaef [ Fri Jan 23, 2004 4:32 pm ]
Post subject:  explosion help

Im trying to make something explode for my school project but i dont know how to get a whole bunch of particles to go out in different directions at the sametime after I have drawn them. I had the same problem with a cloud program i was doing. I drew the cloud with a whole bunch of dots and I want all of the dots to move seperately but I didnt know how and i ended up moving the cloud with Pic.Draw . If ne one could give me a code and explain how they did it it would be very helpful

Author:  Tony [ Fri Jan 23, 2004 5:01 pm ]
Post subject: 

there's a number of particle engines available... you just make a radial push force in the center of explosion

Author:  Cervantes [ Fri Jan 23, 2004 5:02 pm ]
Post subject: 

you could look at Kuntzy's blood particle program...


Author:  Schaef [ Fri Jan 23, 2004 5:04 pm ]
Post subject: 

i need a code of a program. just a small explosion with little particles. I have no idea how to create a particle engine.

Author:  Tony [ Fri Jan 23, 2004 5:05 pm ]
Post subject: 

you dont have to create, just borrow an existing one and give credit in your program

Author:  Schaef [ Fri Jan 23, 2004 5:08 pm ]
Post subject: 

lol. I would like to know what I am doing so i can use it in different situations. all of the particle programs seem to have "type" and "record" in the beginning of the program. What do these mean?

Author:  Cervantes [ Fri Jan 23, 2004 5:09 pm ]
Post subject: 

ooh ooh! if you can't do it in Turing then you can always draw a series of pictures in Paint of your thing exploding and then import those into Turing Very HappyVery Happy

Author:  Schaef [ Fri Jan 23, 2004 5:10 pm ]
Post subject: 

i could.. but that would suck Very Happy . lol. could someone just plz post a code and tell me how it works?

Author:  Cervantes [ Fri Jan 23, 2004 5:11 pm ]
Post subject: 

I would but I don't know how to do it either Thinking

Author:  Schaef [ Fri Jan 23, 2004 5:19 pm ]
Post subject: 

lol. does ne one know how i could do it. I can make all of the little dots put then I cannot change the x and y values for each of them because if i do something like:

var x,y:int

for dots:1..1000
randint (x,100,200)
randint (y,200,300)
end for

could i move all of the dots in different directions instead of just taking a picture of the screen and moving the whole thing?

Author:  Schaef [ Fri Jan 23, 2004 6:03 pm ]
Post subject: 

can someone plz post an example for me?

Author:  AsianSensation [ Fri Jan 23, 2004 6:06 pm ]
Post subject: 

you should have searched.

here is Catalyst's code:

setscreen ("offscreenonly,graphics:640;640")
const numP := 800
const accel := 0.8
const maxLife := 510
var clr : int
for i : 1 .. 255
    clr := RGB.AddColor (1, i / 256, 0)
end for
drawfilloval (maxx div 2, maxy div 2 + 100, 10, 10, black)
drawfillbox (maxx div 2-2,maxy div 2+110,maxx div 2+2,maxy div 2+115,black)
drawline (maxx div 2,maxy div 2+115,maxx div 2,maxy div 2+125,15)
drawfilloval (maxx div 2,maxy div 2+125,2,2,42)
delay (1500)
type part :
        x : real
        y : real
        xV : real
        yV : real
        r : int
        life : int
    end record
var main : array 1 .. numP of part
var a : array 1 .. numP of int
for i : 1 .. numP
    main (i).x := maxx div 2
    main (i).y := maxy div 2 + 100
    main (i).xV := Rand.Int (-40, 40) * Rand.Real
    main (i).yV := Rand.Int (-40, 41) * Rand.Real
    main (i).r := Rand.Int (1, 8)
    main (i).life := maxLife + Rand.Int (-100, 0)
    a (i) := Rand.Int (28, 31)
end for
    for i : 1 .. numP
        main (i).xV -= main (i).xV / 16
        main (i).yV -= accel + main (i).yV / 16
        main (i).x += main (i).xV
        main (i).y += main (i).yV
        main (i).life -= 10
        if main (i).life >= 255 then
            drawfilloval (round (main (i).x), round (main (i).y), main (i).r, main (i).r, round (((main (i).life / maxLife) * 255) + 255))
            drawfilloval (round (main (i).x), round (main (i).y), main (i).r, main (i).r, a (i))
        end if
    end for
end loop

Author:  Schaef [ Fri Jan 23, 2004 6:08 pm ]
Post subject: 

ya i did search. I found that one. I am just not sure how "type" and "record" commands work..

Author:  AsianSensation [ Fri Jan 23, 2004 6:12 pm ]
Post subject:

dodge wrote it

Author:  Schaef [ Fri Jan 23, 2004 6:19 pm ]
Post subject: 

ok thx that is a really helpful tutorial

Author:  Kuntzy [ Sun Jan 25, 2004 3:40 pm ]
Post subject: 

If you use my particle engine, the engine is in a proccedure and the names of the arguments are pretty self explanitory.