ist doch LOGO von ???
Hi, Leudens.

Ich habe hier gerade irgendwas von Logo gelesen, und habe mich jetzt einfach mal drangesetzt, eine eigene Blitzbasicvariante der so schrecklichen Programmiersprache LOGO zu schreiben:

[code:1:b87b8d3e5f]Const TRechts = 205
Const TLinks = 203
Const TUnten = 208
Const TOben = 200

AppTitle("BLITZBASIC LOGO")
Graphics 800,600,16,2
SetBuffer FrontBuffer()

Global XPos#=400,YPos#=300,Kurs#,Sichtbar,Malen=1,altXPos=400,altYPos=300,IgelFarbe

ClsColor 255,255,255
Cls
Color 0,0,0

MaleIgel

While Not KeyDown(1)
R = KeyDown(TRechts)
L = KeyDown(TLinks)
O = KeyDown(TOben)
U = KeyDown(TUnten)
Aktion = Sgn(R + L + O + U)
If Aktion Then
LoescheIgel
If R Then Rechts(1)
If L Then Links(1)
If O Then Vorwaerts(1)
If U Then Rueckwaerts(1)
MaleIgel
VWait()
EndIf
Wend
End

;*****************************************************************************************************

Function StiftAb()
Malen = 1
End Function
Function SA()
Malen = 1
End Function

Function StiftHoch()
Malen = 0
End Function
Function SH()
Malen = 0
End Function

Function Rechts(Winkel#)
Kurs# = (360 + Kurs + Winkel#) Mod 360
End Function
Function RE(Winkel#)
Kurs# = (360 + Kurs + Winkel#) Mod 360
End Function

Function Links(Winkel#)
Kurs# = (720 + Kurs - Winkel#) Mod 360
End Function
Function LI(Winkel#)
Kurs# = (720 + Kurs - Winkel#) Mod 360
End Function

Function Vorwaerts(Weg#)
AltXPos = XPos#
AltYPos = YPos#
XPos# = XPos# + Cos(Kurs# - 90) * Weg#
YPos# = YPos# + Sin(Kurs# - 90) * Weg#
End Function
Function VW(Weg#)
AltXPos = XPos#
AltYPos = YPos#
XPos# = XPos# + Cos(Kurs# - 90) * Weg#
YPos# = YPos# + Sin(Kurs# - 90) * Weg#
End Function

Function Rueckwaerts(Weg#)
AltXPos = XPos#
AltYPos = YPos#
XPos# = XPos# + Cos(Kurs# - 90) * -Weg#
YPos# = YPos# + Sin(Kurs# - 90) * -Weg#
End Function
Function RW(Weg#)
AltXPos = XPos#
AltYPos = YPos#
XPos# = XPos# + Cos(Kurs# - 90) * -Weg#
YPos# = YPos# + Sin(Kurs# - 90) * -Weg#
End Function

Function AufX(x)
XPos = x
End Function

Function AufY(y)
YPos = y
End Function

Function AufXY(x,y)
XPos = x
YPos = y
End Function

Function Farbe(R,G,B)
If R < 0 Then R = 0
If R > 255 Then R = 255
If G < 0 Then G = 0
If G > 255 Then G = 255
If B < 0 Then B = 0
If B > 255 Then B = 255
IgelFarbe = R * $10000 + G * $100 + B
End Function

Function Bild()
Cls
SH
AufXY GraphicsWidth()/2,GraphicsHeight()/2
AltXPos = GraphicsWidth()/2
AltYPos = GraphicsHeight()/2
MaleIgel
SA
End Function

;*****************************************************************************************************

Function MaleIgel()
If Malen = 1 Then
R = (IgelFarbe And $FF0000) / $10000
G = (IgelFarbe And $FF00) / $100
B = IgelFarbe And $FF
Color R,G,B
Line AltXPos,AltYPos,XPos#,YPos#
EndIf
If Sichtbar = 0 Then
x1 = XPos# + Cos(Kurs# - 90) * 10
y1 = YPos# + Sin(Kurs# - 90) * 10
x2 = XPos# + Cos(Kurs# - 90 + 90) * 15
y2 = YPos# + Sin(Kurs# - 90 + 90) * 15
x3 = XPos# + Cos(Kurs# - 90 - 90) * 15
y3 = YPos# + Sin(Kurs# - 90 - 90) * 15
Negativlinie(x1,y1,x2,y2)
Negativlinie(x1,y1,x3,y3)
Negativlinie(x2,y2,x3,y3)
Sichtbar = 1
EndIf
End Function

Function LoescheIgel()
If Sichtbar = 1 Then
x1 = XPos# + Cos(Kurs - 90) * 10
y1 = YPos# + Sin(Kurs - 90) * 10
x2 = XPos# + Cos(Kurs - 90 + 90) * 15
y2 = YPos# + Sin(Kurs - 90 + 90) * 15
x3 = XPos# + Cos(Kurs - 90 - 90) * 15
y3 = YPos# + Sin(Kurs - 90 - 90) * 15
Negativlinie(x1,y1,x2,y2)
Negativlinie(x1,y1,x3,y3)
Negativlinie(x2,y2,x3,y3)
Sichtbar = 0
EndIf
End Function

Function Negativlinie(x1,y1,x2,y2)
If Sgn(x2-x1+y2-y1) Then
LockBuffer
tx = x1
ty = y1
If Abs(x2 - x1) > Abs(y2 - y1) Then
deltax = Abs(x2 - x1)
dirx = Sgn(x2 - x1)
speed# = (Float#(y1 - y2) / Float#(x1 - x2)) * dirx
For x = 0 To deltax
tx = x1 + x * dirx
ty = y1 + speed# * x
If (tx > 0) And (ty > 0) And (tx < GraphicsWidth()) And (ty < GraphicsHeight()) Then
rgb = ReadPixelFast(tx,ty)
rgb = (255 - ((rgb And $FF0000) / $10000)) * $10000 + (255 - ((rgb And $FF00) / $100)) * $100 + (255 - (rgb And $FF))
WritePixelFast tx, ty, rgb
EndIf
Next
Else
deltay = Abs(y2 - y1)
diry = Sgn(y2 - y1)
speed# = (Float#(x2 - x1) / Float#(y2 - y1)) * diry
For y = 0 To deltay
tx = x1 + speed# * y
ty = y1 + y * diry
If (tx > 0) And (ty > 0) And (tx < GraphicsWidth()) And (ty < GraphicsHeight()) Then
rgb = ReadPixelFast(tx,ty)
rgb = (255 - ((rgb And $FF0000) / $10000)) * $10000 + (255 - ((rgb And $FF00) / $100)) * $100 + (255 - (rgb And $FF))
WritePixelFast tx, ty, rgb
EndIf
Next
EndIf
UnlockBuffer
EndIf
End Function[/code:1:b87b8d3e5f]

Die Funktion "BILD" funktioniert irgendwie nicht richtig, der Rest geht aber. Auch ist noch kein Eingabefeld eingebaut, man kann den Igel im Moment nur mit den Pfeiltasten steuern...
===
von ???
Habe es nicht probiert aber LOGO kenne ich noch von den alten 8086 Zeiten :)

Mach aber mal eine kleine Erklärung für die die nicht so alt sind wie ich
hin, dass man weiss wie das geht, bzw wie man da steuert...
===
von ???
Gute Idee.

Also, die Befehle sind alle aus der Version kopiert, die wir im Informatikunterricht benutzt haben:

VW x / Vorwärts x = Gehe x Pixel nach vorne
RW x / Rückwärts x = Gehe x Pixel zurück
RE x / Rechts x = Drehe dich um x Grad nach rechts
LI x / Links x = Drehe dich um x Grad nach links
Farbe R, G, B = Ändere die Farbe auf R,G,B
SH / Stifthoch = Male nicht bei Bewegung
SA / Stiftab = Male bei Bewegung
Bild = Lösche den Bildschirm und setze den Igel auf Bilschirmmitte

Mehr Befehle habe ich glaube ich noch nicht eingebaut.
Ich denke, diese Befehle erklären sich von selbst... Alle hinter dem Schrägstrich stehenden Befehle sind Alternativbefehle, die die gleiche Wirkung bezwecken wie der davor stehende Befehl.
(Wow, 5 mal das Wort Befehl geschrieben! :D)
===
von ???
Achtung Achtung: Neues Programmierbeispiel! :D
Um mal die Funktionalität zu demonstrieren, habe ich ein früher von mir in LOGO geschriebenes Programm in "mein" Logo übersetzt. Rausgekommen ist dabei das:

[code:1:f96ff64903]Const TRechts = 205
Const TLinks = 203
Const TUnten = 208
Const TOben = 200

AppTitle("BLITZBASIC LOGO")
Graphics 800,600,32,0
SetBuffer FrontBuffer()
SeedRnd MilliSecs()

Global XPos#=400,YPos#=300,Kurs#,Sichtbar,Malen=1,altXPos=400,altYPos=300,IgelFarbe,MaxX=GraphicsWidth(),MaxY=GraphicsHeight()
Global r1,g1,b1,rp=1,gp=1,bp=1

ClsColor 255,255,255
Cls
Color 0,0,0

MaleIgel

While Not KeyDown(1)
LoescheIgel
If r1 > 250 Then rp = -1
If r1 < 5 Then rp = 1
If g1 > 250 Then gp = -1
If g1 < 5 Then gp = 1
If b1 > 250 Then bp = -1
If b1 < 5 Then bp = 1
r1 = r1 + Rnd(5) * rp
g1 = g1 + Rnd(5) * gp
b1 = b1 + Rnd(5) * bp
Farbe r1,g1,b1
Rechts Rnd(-5,5)
s = 0
If XPos < 0 Then s = 1
If XPos > MaxX Then s = 1
If YPos < 0 Then s = 1
If YPos > MaxY Then s = 1
If s Then Rechts 180
vw 2
MaleIgel
VWait()
Wend
End

;*****************************************************************************************************

Function StiftAb()
Malen = 1
End Function
Function SA()
Malen = 1
End Function

Function StiftHoch()
Malen = 0
End Function
Function SH()
Malen = 0
End Function

Function Rechts(Winkel#)
Kurs# = (360 + Kurs + Winkel#) Mod 360
End Function
Function RE(Winkel#)
Kurs# = (360 + Kurs + Winkel#) Mod 360
End Function

Function Links(Winkel#)
Kurs# = (720 + Kurs - Winkel#) Mod 360
End Function
Function LI(Winkel#)
Kurs# = (720 + Kurs - Winkel#) Mod 360
End Function

Function Vorwaerts(Weg#)
AltXPos = XPos#
AltYPos = YPos#
XPos# = XPos# + Cos(Kurs# - 90) * Weg#
YPos# = YPos# + Sin(Kurs# - 90) * Weg#
End Function
Function VW(Weg#)
AltXPos = XPos#
AltYPos = YPos#
XPos# = XPos# + Cos(Kurs# - 90) * Weg#
YPos# = YPos# + Sin(Kurs# - 90) * Weg#
End Function

Function Rueckwaerts(Weg#)
AltXPos = XPos#
AltYPos = YPos#
XPos# = XPos# + Cos(Kurs# - 90) * -Weg#
YPos# = YPos# + Sin(Kurs# - 90) * -Weg#
End Function
Function RW(Weg#)
AltXPos = XPos#
AltYPos = YPos#
XPos# = XPos# + Cos(Kurs# - 90) * -Weg#
YPos# = YPos# + Sin(Kurs# - 90) * -Weg#
End Function

Function AufX(x)
XPos = x
End Function

Function AufY(y)
YPos = y
End Function

Function AufXY(x,y)
XPos = x
YPos = y
End Function

Function AufKurs(k)
Kurs = k
End Function
Function AK(k)
Kurs = k
End Function

Function Farbe(R,G,B)
If R < 0 Then R = 0
If R > 255 Then R = 255
If G < 0 Then G = 0
If G > 255 Then G = 255
If B < 0 Then B = 0
If B > 255 Then B = 255
IgelFarbe = R * $10000 + G * $100 + B
End Function

Function Bild()
Cls
SH
AufXY GraphicsWidth()/2,GraphicsHeight()/2
AltXPos = GraphicsWidth()/2
AltYPos = GraphicsHeight()/2
MaleIgel
SA
End Function

;*****************************************************************************************************

Function HandMalen()
R = KeyDown(TRechts)
L = KeyDown(TLinks)
O = KeyDown(TOben)
U = KeyDown(TUnten)
Aktion = Sgn(R + L + O + U)
If Aktion Then
LoescheIgel
If R Then Rechts(1)
If L Then Links(1)
If O Then Vorwaerts(1)
If U Then Rueckwaerts(1)
MaleIgel
VWait()
EndIf
End Function

Function MaleIgel()
If Malen = 1 Then
R = (IgelFarbe And $FF0000) / $10000
G = (IgelFarbe And $FF00) / $100
B = IgelFarbe And $FF
Color R,G,B
Line AltXPos,AltYPos,XPos#,YPos#
EndIf
If Sichtbar = 0 Then
x1 = XPos# + Cos(Kurs# - 90) * 10
y1 = YPos# + Sin(Kurs# - 90) * 10
x2 = XPos# + Cos(Kurs# - 90 + 90) * 15
y2 = YPos# + Sin(Kurs# - 90 + 90) * 15
x3 = XPos# + Cos(Kurs# - 90 - 90) * 15
y3 = YPos# + Sin(Kurs# - 90 - 90) * 15
Negativlinie(x1,y1,x2,y2)
Negativlinie(x1,y1,x3,y3)
Negativlinie(x2,y2,x3,y3)
Sichtbar = 1
EndIf
End Function

Function LoescheIgel()
If Sichtbar = 1 Then
x1 = XPos# + Cos(Kurs - 90) * 10
y1 = YPos# + Sin(Kurs - 90) * 10
x2 = XPos# + Cos(Kurs - 90 + 90) * 15
y2 = YPos# + Sin(Kurs - 90 + 90) * 15
x3 = XPos# + Cos(Kurs - 90 - 90) * 15
y3 = YPos# + Sin(Kurs - 90 - 90) * 15
Negativlinie(x1,y1,x2,y2)
Negativlinie(x1,y1,x3,y3)
Negativlinie(x2,y2,x3,y3)
Sichtbar = 0
EndIf
End Function

Function Negativlinie(x1,y1,x2,y2)
If Sgn(x2-x1+y2-y1) Then
LockBuffer
tx = x1
ty = y1
If Abs(x2 - x1) > Abs(y2 - y1) Then
deltax = Abs(x2 - x1)
dirx = Sgn(x2 - x1)
speed# = (Float#(y1 - y2) / Float#(x1 - x2)) * dirx
For x = 0 To deltax
tx = x1 + x * dirx
ty = y1 + speed# * x
If (tx > 0) And (ty > 0) And (tx < GraphicsWidth()) And (ty < GraphicsHeight()) Then
rgb = ReadPixelFast(tx,ty)
rgb = (255 - ((rgb And $FF0000) / $10000)) * $10000 + (255 - ((rgb And $FF00) / $100)) * $100 + (255 - (rgb And $FF)); + IgelFarbe
If rgb > $FFFFFF Then rgb = $FFFFFF
WritePixelFast tx, ty, rgb
EndIf
Next
Else
deltay = Abs(y2 - y1)
diry = Sgn(y2 - y1)
speed# = (Float#(x2 - x1) / Float#(y2 - y1)) * diry
For y = 0 To deltay
tx = x1 + speed# * y
ty = y1 + y * diry
If (tx > 0) And (ty > 0) And (tx < GraphicsWidth()) And (ty < GraphicsHeight()) Then
rgb = ReadPixelFast(tx,ty)
rgb = (255 - ((rgb And $FF0000) / $10000)) * $10000 + (255 - ((rgb And $FF00) / $100)) * $100 + (255 - (rgb And $FF)); + IgelFarbe
If rgb > $FFFFFF Then rgb = $FFFFFF
WritePixelFast tx, ty, rgb
EndIf
Next
EndIf
UnlockBuffer
EndIf
End Function[/code:1:f96ff64903]

Es sieht übrigens 1:1 zum Original-LOGO-Resultat aus...

PS: Ein paar neue Funktionen sind implementiert, BILD funktioniert noch immer nicht.
===
von ???
Schaut genial aus, aber was ist genau LOGO?
===
von ???
LOGO ist eine Programmiersprache die noch einfacher als Basic ist (zB dt. Befehle) also extra für Grundschüler oder Kinder.(arg und ich mußte es in der 7. Klasse lernen, mit 13 Jahren).
Man kann mit einigen Befehlen eine Schildkröte oder einen Igel über den Bildschirm bewegen.Das Tier hinterläßts eine Spur und so kann man auch einige hübsche Sachen malen.Damit können die Kinder dann spielend lernen wenn sie irgendetwas malen.
Wenn ich mich recht erinnere gabs sogar Bedingungen und Schleifen.

BTW:Mußte auch mal einen LOGO(würgh)-Interpreter schreiben und zwar in Pascal(doppelwürgh)
===
von ???
*hehe* freiwillig?
Na ja, deine Erklärung bezüglich LOGO stimmt nicht ganz.
Es ist auch keine Kindergartenprogrammiersprache. Wir haben sie in der 8ten gelernt, also mit 14 Jahren. Ist zwar wirklich Kinderkram, aber trotzdem keine Kleinkindersprache.
LOGO soll denjenigen, die keine Ahnung von Programmieren haben, zeigen, wie der Computer einen eingegebenen Programmablauf abarbeitet. Dass man damit malen kann, ist eigentlich nur Nebensache. Der angehende Programmierer soll verstehen, wie er mit dem PC umgehen muss, damit dieser die Befehle sinngemäß ausführt. Dabei geht es insbesondere um die Struktur des Programms.
Übrigens, Logo kann nicht nur Schleifen und Bedingungen, es kann auch Variablen, DLL-Steuerung, Prozedurdefinitionen, Tonausgabe, Rechenausdrücke, Zeichenkettenverarbeitung, Dateiverwaltung etc.

Okay, ich bin auch kein besonderer Fan von LOGO, aber ist mal ganz lustig, sowas selbst zu programmieren. Außerdem ist die Idee, die hinter LOGO steckt, gar nicht mal so übel :D ...
===
von ???
Hach ja .. Super-Logo war meine erste Programmier-Sprache *zurückerinner*. Da kam es schon ganz gut das die Befehle in deutsch sind weil ich da gerade erst angefangen hab in der Schule Englisch zu lernen :D



Suche:
(unterstützt mySQL Wildcards ala %)
Titel:
Text:
Autor: