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

Username:   Password: 
 RegisterRegister   
 this is my turtle class,you can do alot with it try it out
Index -> Programming, Turing -> Turing Submissions
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
kit-kat-kid




PostPosted: Wed May 05, 2004 5:38 pm   Post subject: this is my turtle class,you can do alot with it try it out

code:
%File "turtleCl.tu" the Turtle Object
unit
class TurtleCl
    export SetColour, SetPosition, SetAngle, TurnRight, TurnLeft, Move,
        ShowTrace, HideTrace
    var x := maxx div 2
    var y := maxy div 2
    var angle := 90
    var clr := black
    var showing : boolean := true
    proc SetColour (newClr : int)
        clr := newClr
    end SetColour
    proc SetPosition (newX, newY : int)
        x := newX
        y := newY
    end SetPosition
    proc SetAngle (newAngle : int)
        angle := newAngle
    end SetAngle
    proc TurnRight (turnAngle : int)
        angle -= turnAngle
        angle := angle mod 360
    end TurnRight
    proc TurnLeft (turnAngle : int)
        angle += turnAngle
        angle := angle mod 360
    end TurnLeft
    proc ShowTrace
        showing := true
    end ShowTrace
    proc HideTrace
        showing := false
    end HideTrace
    proc Move (distance : int)
        var newX, newY : int
        newX := round (x + cosd (angle) * distance)
        newY := round (y + sind (angle) * distance)
        if showing then
            Draw.Line (x, y, newX, newY, clr)
        end if
        x := newX
        y := newY
    end Move
end TurtleCl
Sponsor
Sponsor
Sponsor
sponsor
MyPistolsIn3D




PostPosted: Sat May 15, 2004 1:24 pm   Post subject: (No subject)

Who are you kit-kat-kid?
kit-kat-kid




PostPosted: Wed May 26, 2004 7:48 pm   Post subject: (No subject)

who am i why do you wanna know that?
Mazer




PostPosted: Wed May 26, 2004 8:48 pm   Post subject: (No subject)

Does anyone want to guess what the Posted Image, might have been reduced in size. Click Image to view fullscreen. button does?

Don't make me lock this topic.
beard0




PostPosted: Fri May 28, 2004 8:53 am   Post subject: (No subject)

I've got my version that I like, because It keeps a value for the turtle's location, and direction as a real number, then rounds it when drawing, so that multiple complex manouvers still end up where they should:

code:

unit
module Turtle

    export Go, ChangeDirection, SetDirection, SetColor, Trace, SetPosition
    var tx, ty, td : real := 0
    var tc : int := 1
    var tdwn : boolean := true

    proc Go (d : real)
        var ox, oy : real
        ox := tx
        oy := ty
        tx -= sind (td) * d
        ty += cosd (td) * d
        if tdwn then
            drawline (round (ox), round (oy), round (tx), round (ty), tc)
        end if
    end Go

    proc ChangeDirection (d : real)
        td += d
    end ChangeDirection

    proc SetDirection (d : real)
        td := d
    end SetDirection

    proc SetColor (c : int)
        tc := c
    end SetColor

    proc Trace (trc : boolean)
        tdwn := trc
    end Trace

    proc SetPosition (x, y : int)
        tx := x
        ty := y
    end SetPosition

end Turtle
poly




PostPosted: Fri May 28, 2004 9:43 am   Post subject: (No subject)

Mazer wrote:
Does anyone want to guess what the Posted Image, might have been reduced in size. Click Image to view fullscreen. button does?

Don't make me lock this topic.

Mazer, this kid is from my computer science class. THIS IS NOT HIS OWN WORK! Our teacher wrote this and gave it to us as an example, Please do NOT give him credit for this!
zylum




PostPosted: Fri May 28, 2004 3:46 pm   Post subject: (No subject)

poly wrote:
Mazer wrote:
Does anyone want to guess what the Posted Image, might have been reduced in size. Click Image to view fullscreen. button does?

Don't make me lock this topic.

Mazer, this kid is from my computer science class. THIS IS NOT HIS OWN WORK! Our teacher wrote this and gave it to us as an example, Please do NOT give him credit for this!


lmao, your school must be a bunch of plagerisers Twisted Evil j/k.. your teacher didnt even write that... i have a textbook from school that has the exact same class in it lol...
Paul




PostPosted: Fri May 28, 2004 8:44 pm   Post subject: (No subject)

wow Shocked and my teacher worries about us copying stuff from compsci.ca lol.
Sponsor
Sponsor
Sponsor
sponsor
poly




PostPosted: Sat May 29, 2004 4:25 pm   Post subject: (No subject)

zylum wrote:
poly wrote:
Mazer wrote:
Does anyone want to guess what the Posted Image, might have been reduced in size. Click Image to view fullscreen. button does?

Don't make me lock this topic.

Mazer, this kid is from my computer science class. THIS IS NOT HIS OWN WORK! Our teacher wrote this and gave it to us as an example, Please do NOT give him credit for this!


lmao, your school must be a bunch of plagerisers Twisted Evil j/k.. your teacher didnt even write that... i have a textbook from school that has the exact same class in it lol...
well sorry if it sounded like i said the teacher wrote it, i meant he wrote it out to us to use etc, guess i was in a rush to post...but still a lot of kids in my class are copying shit from this site
Dan




PostPosted: Sat May 29, 2004 4:28 pm   Post subject: (No subject)

So tell your teacher to come and look at the site, a quick uses of the search buttion could cheatch any cheaters.

I whould be glad to help them catch cheats espleay when they cheat on there ISU/FP project.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
bugzpodder




PostPosted: Sat May 29, 2004 5:46 pm   Post subject: (No subject)

a sorta off-topic note, my FP is basically a turtle with LOGO language telling it what to do. you can load Demos to see stuff.
Kamikagushi




PostPosted: Thu Jun 10, 2004 7:00 pm   Post subject: (No subject)

~a question~why can't i run it~it returns as error as cannot have unit as main program~
marijuana




PostPosted: Thu Jun 10, 2004 11:16 pm   Post subject: (No subject)

convert the escape function with sprites of terminal use. ASCII will help alot for this.
this_guy




PostPosted: Wed Jul 07, 2004 7:53 pm   Post subject: (No subject)

do what to what?


i dunno if my version is crap or something, but unit is shown in blue (for variables)
RaPsCaLLioN




PostPosted: Fri Aug 20, 2004 8:59 am   Post subject: (No subject)

I'm a turtle.
Errr.. I mean.. How do I use this thing. Any examples?
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 2  [ 17 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: