Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 physics particle engine...
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Homer_simpson




PostPosted: Sun Dec 07, 2003 6:06 pm   Post subject: physics particle engine...

mess around with reset procedure to make projectiles do different things
code:
colorback (black)
cls
color (white)
put "Enter draw mode (1,2,3)[recommended = 3] :"
var mode : char
mode := getchar

put "Enter Max Number of Particles [recommended = 1000]:"
var mx := 0
get mx
cls
View.Set ("offscreenonly")
%%%%%%%%%%Declaring projectile type as an object%%%%%%%%%%5
type projectile_t :
    record
        startx, starty, x, y, angle, weight, velocity, bounciness, time1 : real
    end record

var projectile_a : array 1 .. mx of projectile_t

procedure Reset (var projectile_a : projectile_t, v1, v2, a1, a2, w1, w2, b1, b2 : int)
    projectile_a.startx := 0
    projectile_a.starty := 50
    projectile_a.velocity := Rand.Int (v1, v2)
    projectile_a.angle := Rand.Int (a1, a2)
    projectile_a.weight := Rand.Int (w1, w2)
    projectile_a.time1 := 0
    projectile_a.bounciness := Rand.Int (b1, b2)
end Reset

procedure Projectile (var obj : projectile_t)
    obj.x := (obj.velocity * cosd (obj.angle) * obj.time1) + obj.startx
    obj.y := (obj.velocity * sind (obj.angle) * obj.time1 - (obj.weight) * obj.time1 ** 2 / 2) + obj.starty
end Projectile

procedure Bounce (var obj : projectile_t)
    if obj.y <= obj.starty then
        if (obj.velocity) > 0 then
            obj.time1 := 0
            obj.startx := obj.x
            obj.starty := obj.y
            obj.velocity -= obj.bounciness
        end if
        if (obj.velocity) < 0 then
            obj.velocity := 0
        end if
    end if
end Bounce


for i : 1 .. upper (projectile_a)
    Reset (projectile_a (i), 40, 80, 45, 45, 5, 15, 10, 30)
end for



loop
    for i : 1 .. upper (projectile_a)
        %Reset (projectile_a (i))
        projectile_a (i).time1 += .1
        Projectile (projectile_a (i))
        Bounce (projectile_a (i))
        case mode of
            label "1" :
                drawfilloval (round (projectile_a (i).x), round (projectile_a (i).y), 2, 2, white)
            label "2" :
                drawfilloval (round (projectile_a (i).x), round (projectile_a (i).y), round (projectile_a (i).weight / 2), round (projectile_a (i).weight / 2), white)
            label "3" :
                drawdot (round (projectile_a (i).x), round (projectile_a (i).y), white)
            label :
        end case
    end for
    %drawline (0, 45, maxx, 45, white)
    drawfillbox (0, 0, maxx, 45, brown)
    View.Update
    for i : 1 .. upper (projectile_a)
        case mode of
            label "1" :
                drawfilloval (round (projectile_a (i).x), round (projectile_a (i).y), 2, 2, black)
            label "2" :
                drawfilloval (round (projectile_a (i).x), round (projectile_a (i).y), round (projectile_a (i).weight / 2), round (projectile_a (i).weight / 2), black)
            label "3" :
                drawdot (round (projectile_a (i).x), round (projectile_a (i).y), black)
            label :
        end case
        if projectile_a (i).velocity <= 0 then
            Reset (projectile_a (i), 10, 80, 15, 60, 5, 15, 10, 30)
        end if
    end for
end loop
Sponsor
Sponsor
Sponsor
sponsor
santabruzer




PostPosted: Sun Dec 07, 2003 6:15 pm   Post subject: (No subject)

pretty cool... the only problem.. don't like the color of the ground..... but who cares about that... Pretty cool .. good job
Homer_simpson




PostPosted: Sun Dec 07, 2003 6:21 pm   Post subject: (No subject)

dont like the color of the ground... LOL! man yer funny....
here man :drawfillbox (0, 0, maxx, 45, the color u like)
change that...
santabruzer




PostPosted: Sun Dec 07, 2003 6:24 pm   Post subject: (No subject)

i was just fooling with ya.. i know it's simple.. it's just because you made such an amazing program Embarassed
shorthair




PostPosted: Wed Jan 07, 2004 10:49 am   Post subject: (No subject)

Very well done homer , its well done , AND I DO LIKE HTE COLOR OF HTE GROUND
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: