Posted: 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
Sponsor Sponsor
Homer_simpson
Posted: Wed Dec 03, 2003 9:38 pm Post subject: (No 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
HeTeRiC
Posted: Thu Dec 11, 2003 10:45 pm Post subject: (No 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
Homer_simpson
Posted: Thu Dec 11, 2003 11:13 pm Post subject: (No 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...
Andy
Posted: Fri Dec 19, 2003 10:28 am Post subject: (No subject)
i don't understand physics x_X
Triple Five
Posted: Tue Jan 06, 2004 7:44 pm Post subject: (No subject)
thanks man! 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! i also tried to understand it along the way!
Homer_simpson
Posted: Tue Jan 06, 2004 8:59 pm Post subject: (No subject)
well to make a sun... i would just use parabola...
Triple Five
Posted: Wed Jan 07, 2004 12:30 pm Post subject: (No subject)
how would u use that! can u give an eg. or maybe a link to a tutorial!
Sponsor Sponsor
Homer_simpson
Posted: Wed Jan 07, 2004 8:50 pm Post subject: (No 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
Triple Five
Posted: Thu Jan 08, 2004 10:30 am Post subject: (No subject)
thanks man i find it much better for sun movement than the projectile one!
Leiak
Posted: 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
Tony
Posted: Sun Jan 18, 2004 2:31 am Post subject: (No 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)