Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
basic tutorial on simple projectle movement(a bit advanced)
Author Message
Homer_simpson

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

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!

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)
Tony's programming blog. DWITE - a programming contest.
Schaef

Posted: Mon Jan 19, 2004 4:40 pm   Post subject: (No 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
Cervantes

Posted: Wed Jan 21, 2004 5:21 pm   Post subject: (No subject)

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

Posted: Thu Jan 22, 2004 12:20 pm   Post subject: (No subject)

lol... i still haven't had physics! taking it next semester...
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 2  [ 30 Posts ]
Goto page 1, 2  Next
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: