Logo Turtle ...
Übersicht BlitzMax, BlitzMax NG Allgemein
morszeckBetreff: Logo Turtle ... |
Mo, Feb 28, 2005 22:13 Antworten mit Zitat |
|
---|---|---|
Leider habe ich kaum Zeit irgendetwas zu machen drum:
Ich habe mal ein Projekt angefangen: Logo Turtle, dass sicher alt gesockene 386er aus den alten guten Dos-Zeiten sicherlich noch kennen Also, ich wollte es schlussendlich als Modul einfügen und als pub publizieren. Unter Google finden sich viele Seiten die LogoTurtle beschreiben. Wer will kann hier weiter machen... Hier der Quellcode: Code: [AUSKLAPPEN] ' Turtle
Strict Rem bbdoc: Turtle ' End Rem Module PUB.Turtle ModuleInfo "Version: 1.00" ModuleInfo "Author: Morszeck Rene ... ... " ModuleInfo "License: GPL" End Rem Import BRL.Max2D Import BRL.Math Const TURTLECENTER = 0 Type TTurtle Global count:Int Global old_x:Float Global old_y:Float '--- Field home_x:Float Field home_y:Float Field pos_x:Float Field pos_y:Float Field angle:Double Field color_r:Byte Field color_g:Byte Field color_b:Byte Field view:Int Field pen:Int '--- Function Create:TTurtle( x=0, y=0, view=0 ) Local _turtle:TTurtle = New TTurtle _turtle.pos_x = x _turtle.pos_y = y _turtle.home_x = _turtle.pos_x _turtle.home_y = _turtle.pos_y _turtle.color_r = 255 _turtle.color_g = 255 _turtle.color_b = 255 _turtle.view = 0 _turtle.pen = True Return _turtle End Function Method New() count:+1 End Method Method PenColor( r:Byte, g:Byte, b:Byte ) color_r = r color_g = g color_b = b End Method Method PenUp() pen = False End Method Method PenDown() pen = True End Method Method ShowTurtle() view = True End Method Method HideTurtle() view = False End Method Method TurnLeft( _angle:Double ) angle = angle - _angle End Method Method TurnRight( _angle:Double ) angle = angle + _angle End Method Method TurnAbs( _angle:Double ) angle = _angle End Method Method Forward(pixel:Float) SetColor color_r, color_g, color_b old_x = pos_x old_y = pos_y pos_x = old_x + Cos(angle) * pixel pos_y = old_y + Sin(angle) * pixel If pen=True Then DrawLine old_x, old_y, pos_x, pos_y End Method Method Backward(pixel) SetColor color_r, color_g, color_b old_x = pos_x old_y = pos_y pos_x = old_x - Sin(angle) * pixel pos_y = old_y - Cos(angle) * pixel If pen=True Then DrawLine old_x, old_y, pos_x, pos_y End Method Method Rect( width:Float, height:Float ) old_x = pos_x old_y = pos_y Local pos_width_x = Cos(angle) * width Local pos_width_y = Sin(angle) * width Local pos_height_x = Cos(angle) * height Local pos_height_y = Sin(angle) * height SetRotation angle DrawRect pos_x, pos_y, width, height End Method End Type Function CreateTurtle:TTurtle( x=0, y=0, view=0 ) Return TTurtle.Create( x, y, view ) End Function Beispiel: Code: [AUSKLAPPEN] Graphics 800,600,0
Cls Local hans:TTurtle = CreateTurtle(300,300) Local lutz:TTurtle = CreateTurtle(300,300) hans.pencolor(0,255,0) lutz.pencolor(0,0,255) hans.TurnAbs 45 hans.rect 100, 50 Flip WaitKey() |
||
Übersicht BlitzMax, BlitzMax NG Allgemein
Powered by phpBB © 2001 - 2006, phpBB Group