Computer Science Canada

basic tutorial on simple projectle movement(a bit advanced)

Author:  Homer_simpson [ Wed Dec 03, 2003 9:26 pm ]
Post subject:  basic tutorial on simple projectle movement(a bit advanced)

code:
View.Set ("offscreenonly")
%%%%%%%%%%Declaring projectile type as an object%%%%%%%%%%5
type projectile_t :
    record
        startx, starty, x, y, angle, weight, velocity : real
    end record

var projectile_1 : projectile_t

%set start point to 0,0
projectile_1.startx := 0
projectile_1.starty := 0
%setting the velocity(the throw power to 80
projectile_1.velocity := 80
%The angle that the projectile's thrown in
projectile_1.angle := 60
%how heavy the object is...
projectile_1.weight := 10
%setting the initial time to 0
var time1 := 0.0

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

loop
    time1 += .1 %The time and how fast it is moving
    Projectile (projectile_1, time1) %applying movements to the projectile
    drawfilloval (round (projectile_1.x), round (projectile_1.y), 5, 5, 12) %draw the projectile
    View.Update
    delay (10)
    drawfilloval (round (projectile_1.x), round (projectile_1.y), 5, 5, white) %erase the projectile
end loop

Author:  Homer_simpson [ Wed Dec 03, 2003 9:38 pm ]
Post subject: 

here's one a bit more advanced...
code:
View.Set ("offscreenonly")
%%%%%%%%%%Declaring projectile type as an object%%%%%%%%%%5
type projectile_t :
    record
        startx, starty, x, y, angle, weight, velocity, bounciness : real
    end record

var projectile_1 : projectile_t

%set start point to 0,0
projectile_1.startx := 0
projectile_1.starty := 200
%setting the velocity(the throw power to 80
projectile_1.velocity := 60
%The angle that the projectile's thrown in
projectile_1.angle := 80
%how heavy the object is...
projectile_1.weight := 10
%setting the bounciness
projectile_1.bounciness := 10
%setting the initial time to 0
var time1 := 0.0

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

procedure Bounce (var obj : projectile_t, var t : real)
    if obj.y <= obj.starty then
        if (obj.velocity) > 0 then
            t := 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
loop
    time1 += .1 %The time and how fast it is moving
    Projectile (projectile_1, time1) %applying movements to the projectile
    Bounce (projectile_1, time1)%Detect ground and bounce back
    drawfilloval (round (projectile_1.x), round (projectile_1.y), 5, 5, 12) %draw the projectile
    View.Update
    delay (10)
    drawfilloval (round (projectile_1.x), round (projectile_1.y), 5, 5, white) %erase the projectile
    exit when projectile_1.velocity <= 0
end loop

Author:  HeTeRiC [ Thu Dec 11, 2003 10:45 pm ]
Post subject: 

That second one is cool, looks like interactive physics. there both sweet tho, good job!

how would i make a program that gets the variables like throw speed ect and the sets them??
so i could play cannons Wink

Author:  Homer_simpson [ Thu Dec 11, 2003 11:13 pm ]
Post subject: 

well... i've basically given u everything u need to know... but if u want something more clear to make cannons check out my "turing worms" post...

Author:  Andy [ Fri Dec 19, 2003 10:28 am ]
Post subject: 

i don't understand physics x_X

Author:  Triple Five [ Tue Jan 06, 2004 7:44 pm ]
Post subject: 

thanks man! Very Happy really helped when i tried to make a sun make make it so that it went throughout the day from east to west in a projectile movenment! Very Happy i also tried to understand it along the way! Very Happy

Author:  Homer_simpson [ Tue Jan 06, 2004 8:59 pm ]
Post subject: 

well to make a sun... i would just use parabola...

Author:  Triple Five [ Wed Jan 07, 2004 12:30 pm ]
Post subject: 

how would u use that! Confused can u give an eg. or maybe a link to a tutorial! Very Happy

Author:  Homer_simpson [ Wed Jan 07, 2004 8:50 pm ]
Post subject: 

how bout this one?
code:
colorback (black)
cls
View.Set ("offscreenonly")
var y := 0.0
for x : -320 .. 320
    y := .001 * (-x ** 2)
    drawdot (x + 320, round (y) + 100, black)
    drawfilloval (x + 320, round (y) + 100, 20, 20, 14)
    View.Update
    drawfilloval (x + 320, round (y) + 100, 20, 20, black)
end for

Author:  Triple Five [ Thu Jan 08, 2004 10:30 am ]
Post subject: 

thanks man i find it much better for sun movement than the projectile one! Very Happy

Author:  Leiak [ Sun Jan 18, 2004 12:03 am ]
Post subject:  im confused

whenever i try to run 95% of the programs on this site on my object oriented turing program it says Update is not part of export list View or something like that do i need a new program to run these or wut im lost plz help

Author:  Tony [ Sun Jan 18, 2004 2:31 am ]
Post subject: 

yes, you need the new program... You need 4.0.x for View.Update.

as a matter of fact, 4.0.5 came out today and there's a link for it on the main page (along with other news)

Author:  Schaef [ Mon Jan 19, 2004 4:40 pm ]
Post subject: 

where does the 0.001 come from in the y:=0.001 * (-x**2)? i dont get how that works. if i change it to 0.01 then it doesnt show nething

Author:  Cervantes [ Wed Jan 21, 2004 5:21 pm ]
Post subject: 

damn I can't wait till I can take gr 11 physics Razz

Author:  Homer_simpson [ Thu Jan 22, 2004 12:20 pm ]
Post subject: 

lol... i still haven't had physics! Laughing taking it next semester...

Author:  Cervantes [ Thu Jan 22, 2004 5:58 pm ]
Post subject: 

your in gr 11 now??

what math courses have you taken so far in gr 11??

Author:  Andy [ Thu Jan 22, 2004 8:02 pm ]
Post subject: 

i think homer is in 12

Author:  Cervantes [ Thu Jan 22, 2004 8:32 pm ]
Post subject: 

gr 12 yet not have taken gr 11 physics!!

for shame... Razz

Author:  Homer_simpson [ Fri Jan 23, 2004 1:21 am ]
Post subject: 

lol dude man...
i'm in 12 but currently i'm taking science 10,english 10,gym 12 and... oh yeah calculus which i have a quiz for tommorow,DAMN!
here's next semester tho: eng 11,compsci 11,physics 11, chemistry 11!

damn guy i'm pretty fvcked with my school crap!

Author:  shorthair [ Fri Jan 23, 2004 10:29 am ]
Post subject: 

Harsh semster but thy this on for size , for my grade 12 , i have to take , geometry and descrete math & Calculus ( Which i cant even spell ? ) and data managment mathmatics , with a side of grade 12 programming and engineering , NOW THAT S A SEMESTER DUDE

Author:  Cervantes [ Fri Jan 23, 2004 2:38 pm ]
Post subject: 

wow that semester kicks ass shorthair. wish I had it Razz (lousy gr. 10)

Author:  Homer_simpson [ Sat Jan 24, 2004 1:07 am ]
Post subject: 

shorthair wrote:
Harsh semster but thy this on for size , for my grade 12 , i have to take , geometry and descrete math & Calculus ( Which i cant even spell ? ) and data managment mathmatics , with a side of grade 12 programming and engineering , NOW THAT S A SEMESTER DUDE

dude man... YER FVCKED! i failed on my calculus when i had it alone... u got friggin calc and geo together!! YER FVCKED Shocked

Author:  shorthair [ Sat Jan 24, 2004 11:15 am ]
Post subject: 

Thats what i need , i have a nice easy semester this year , engineering and programming keep it nice and fun

Author:  Cervantes [ Sat Jan 24, 2004 11:50 am ]
Post subject: 

you have no english that semester and it is therefore an amazing semester Very Happy

Author:  Andy [ Sat Jan 24, 2004 12:24 pm ]
Post subject: 

u think ur lives suck, i have

enriched chem, enriched bio, gr 12compsci, enriched english, gr 12 finite, law, enriched physics and enriched math

Author:  shorthair [ Sat Jan 24, 2004 12:46 pm ]
Post subject: 

Sounds like fun
Very Happy

Author:  rizzix [ Sat Jan 24, 2004 12:53 pm ]
Post subject: 

hmm i have Algeo, Calc, Physics, Bio, Chem, Compsci, Eng, Rel

Author:  Cervantes [ Sat Jan 24, 2004 1:22 pm ]
Post subject: 

dodge... law.... pffft Razz

Author:  Andy [ Sat Jan 24, 2004 2:14 pm ]
Post subject: 

lol thats my only joke course... i go their and draw dotted lines on the board and get 100%

Author:  Cervantes [ Sat Jan 24, 2004 3:04 pm ]
Post subject: 

wow, from what I've seen the law courses at my school are pretty hard


: