Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
How would I simulate the function "degtorad" in tu
Author Message
s_climax

Posted: Mon May 03, 2004 3:15 pm   Post subject: How would I simulate the function "degtorad" in tu

How would I go about converting this into Turing?
[/code]

Delos

Posted: Mon May 03, 2004 3:22 pm   Post subject: (No subject)

Just a quick thought:

by default sin, cos, and tan all return radian values. sind, cosd, and tand return degree values. May be of some help.
Mazer

Posted: Mon May 03, 2004 4:58 pm   Post subject: (No subject)

Delos, you meant to say that sin and cos take radian values and sind and cosd take degree values, right?

Anyways, s_climax if you can use trig you should probably already know how to convert from degrees to radians, but if not I believe it was pi / 180 = r / d. Or something... I never use radians (they're for sissies ).
s_climax

Posted: Mon May 03, 2004 4:58 pm   Post subject: (No subject)

Thanks. One more question then. Why is it that in my code, when the direction is 180 the character does not move straight up?

 code: var chars : array char of boolean var x, y, dir, speed, timer : int speed := 2 dir := 0 x := maxx div 2 y := maxy div 2 timer := 0 loop     timer += 1     Input.KeyDown (chars)     if chars (KEY_UP_ARROW) then         y += round (sin (360 - dir) * speed)         x += round (cos (360 - dir) * speed)     end if     if chars (KEY_DOWN_ARROW) then         y += round (sin ((360 - dir)) * -speed)         x += round (cos ((360 - dir)) * -speed)     end if     if chars (KEY_LEFT_ARROW) and timer mod 10 = 0 then         dir += 1     end if     if chars (KEY_RIGHT_ARROW) and timer mod 10 = 0 then         dir -= 1     end if     drawfilloval (x, y, 5, 5, 2)     delay (10)     cls     if x > maxx then         x := 1     elsif x < 0 then         x := maxx - 1     end if     if y > maxy then         y := 1     elsif y < 0 then         y := maxy - 1     end if     put dir end loop

By the way, the part about the timer being mod 10 is only necessary as a tempory fix. I should not need it. However, without it my character turns too quick. Any help?
zylum

Posted: Mon May 03, 2004 7:29 pm   Post subject: (No subject)

i didnt want to alter your code too much but this should help:

 code: var chars : array char of boolean var ang, speed : int var x, y, dx, dy : real ang := 0 speed := 2 x := maxx div 2 y := maxy div 2 loop     Input.KeyDown (chars)     if chars (KEY_UP_ARROW) then         speed := 2     elsif chars (KEY_DOWN_ARROW) then         speed := -1     else         speed := 0     end if     if chars (KEY_LEFT_ARROW) then         ang += 3     end if     if chars (KEY_RIGHT_ARROW) then         ang -= 3     end if     dx := cosd (ang) * speed     dy := sind (ang) * speed     x += dx     y += dy     drawfilloval (round (x), round (y), 5, 5, 2)     delay (10)     cls     if x > maxx then         x := 1     elsif x < 0 then         x := maxx - 1     end if     if y > maxy then         y := 1     elsif y < 0 then         y := maxy - 1     end if end loop

-zylum
s_climax

Posted: Mon May 03, 2004 9:02 pm   Post subject: (No subject)

Thanks.

Judging from the differences, I see two main things I did wrong. First it was cosd and sind instead of just sin and cos. Second I should have rounded at the end to prevent jerkiness. Can you tell me if this is correct?
djlenny_3000

Posted: Tue May 04, 2004 1:53 pm   Post subject: (No subject)

hey not bad but i have one coment y not put a triangle or somesort of marker to show the front and make a car driving program cuz what u have so far is very cool
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 7 Posts ]
 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: