X- und Y-Position vertauscht?? :?
Übersicht

.:_]TRaShBetreff: X- und Y-Position vertauscht?? :? |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Schön' Guten!!
Ich bin grad dabei einen kleinen Leveleditor zu proggen, das klappt soweit auch ganz gut! Ich habe auch kein richtiges Problem, nur ich verstehe etwas nicht aber würde es gerne!! Der Code vom Editor: Code: [AUSKLAPPEN] Graphics 800,600,32,2 SetBuffer BackBuffer() AppTitle "The A-Editor | "+CurrentDate()+" | x-force" Haus1 = LoadImage("gfx\static\Haus5.bmp") Kiste1 = LoadImage("gfx\static\Kiste5.bmp") Kiste2 = LoadImage("gfx\static\Kiste6.bmp") Dim Level(49,37) auswahl = 1 MoveMouse 400,300 While Not KeyDown(1) MX2 = MouseX()/16 MY2 = MouseY()/16 MX = MX2*16 MY = MY2*16 Cls If KeyHit(2) Then auswahl = 1 If KeyHit(3) Then auswahl = 2 If KeyHit(4) Then auswahl = 3 If KeyHit(31) Then Speichern() If MouseHit(1) Then Level(MX2,MY2) = auswahl For X = 0 To 49 For Y = 0 To 37 If Level(X,Y) = 1 Then DrawImage Haus1, X*16,Y*16 If Level(X,Y) = 2 Then DrawImage Kiste1, X*16,Y*16 If Level(X,Y) = 3 Then DrawImage Kiste2, X*16,Y*16 Next Next Text 0,0, "MX: "+ MX + "| MX2: " + MX2 Text 0,15,"MY: "+ MY + "| MY2: " + MY2 Text 0,30,"VERFÜGBARE BILDER: 3 | AKTUELL: "+auswahl If auswahl = 1 Then DrawImage Haus1, MX, MY If auswahl = 2 Then DrawImage Kiste1, MX, MY If auswahl = 3 Then DrawImage Kiste2, MX, MY Flip Wend End Function Speichern() Cls FlushKeys() LName$ = Input("Levelname? ") DasLevel = WriteFile("Levels\"+LName$+".ape") FlushKeys() For X = 0 To 49 For Y = 0 To 37 If Level(X,Y) = 1 Then WriteLine DasLevel, "1" WriteLine DasLevel, X WriteLine DasLevel, Y WriteLine DasLevel, " " ElseIf Level(X,Y) = 2 Then WriteLine DasLevel, "2" WriteLine DasLevel, X WriteLine DasLevel, Y WriteLine DasLevel, " " ElseIf Level(X,Y) = 3 Then WriteLine DasLevel, "3" WriteLine DasLevel, X WriteLine DasLevel, Y WriteLine DasLevel, " " EndIf Next Next Text 400,100,"LEVEL GESPEICHERT!",1,1 Delay 1000 End Function Der Code von dem Programm was die Datei ausliest und die Bilder zeichnet: Code: [AUSKLAPPEN] Graphics 800,600,32,2 SetBuffer BackBuffer() AppTitle "The A-Editor | "+CurrentDate()+" | x-force" Haus1 = LoadImage("gfx\static\Haus5.bmp") Kiste1 = LoadImage("gfx\static\Kiste5.bmp") Kiste2 = LoadImage("gfx\static\Kiste6.bmp") Dim Level(49,37) auswahl = 1 MoveMouse 400,300 While Not KeyDown(1) MX2 = MouseX()/16 MY2 = MouseY()/16 MX = MX2*16 MY = MY2*16 Cls If KeyHit(2) Then auswahl = 1 If KeyHit(3) Then auswahl = 2 If KeyHit(4) Then auswahl = 3 If KeyHit(31) Then Speichern() If MouseHit(1) Then Level(MX2,MY2) = auswahl For X = 0 To 49 For Y = 0 To 37 If Level(X,Y) = 1 Then DrawImage Haus1, X*16,Y*16 If Level(X,Y) = 2 Then DrawImage Kiste1, X*16,Y*16 If Level(X,Y) = 3 Then DrawImage Kiste2, X*16,Y*16 Next Next Text 0,0, "MX: "+ MX + "| MX2: " + MX2 Text 0,15,"MY: "+ MY + "| MY2: " + MY2 Text 0,30,"VERFÜGBARE BILDER: 3 | AKTUELL: "+auswahl If auswahl = 1 Then DrawImage Haus1, MX, MY If auswahl = 2 Then DrawImage Kiste1, MX, MY If auswahl = 3 Then DrawImage Kiste2, MX, MY Flip Wend End Function Speichern() Cls FlushKeys() LName$ = Input("Levelname? ") DasLevel = WriteFile("Levels\"+LName$+".ape") FlushKeys() For X = 0 To 49 For Y = 0 To 37 If Level(X,Y) = 1 Then WriteLine DasLevel, "1" WriteLine DasLevel, X WriteLine DasLevel, Y WriteLine DasLevel, " " ElseIf Level(X,Y) = 2 Then WriteLine DasLevel, "2" WriteLine DasLevel, X WriteLine DasLevel, Y WriteLine DasLevel, " " ElseIf Level(X,Y) = 3 Then WriteLine DasLevel, "3" WriteLine DasLevel, X WriteLine DasLevel, Y WriteLine DasLevel, " " EndIf Next Next Text 400,100,"LEVEL GESPEICHERT!",1,1 Delay 1000 End FunctionGraphics 800,600,32,2 SetBuffer BackBuffer() AppTitle "The A-Project | "+CurrentDate()+" | X-FORCE | X.TENSION SOFTWORX" Haus1 = LoadImage("gfx\static\Haus5.bmp") Kiste1 = LoadImage("gfx\static\Kiste5.bmp") Kiste2 = LoadImage("gfx\static\Kiste6.bmp") ChangeDir "Levels" Lvl$ = Input("Welcher Level soll geladen werden!? ") DasLevel = ReadFile(Lvl+".ape") Dim aktLevel(49,37) Repeat Zeile = ReadLine(DasLevel) If Zeile = 1 Then aktLevel(ReadLine(DasLevel), ReadLine(DasLevel)) = 1 If Zeile = 2 Then aktLevel(ReadLine(DasLevel), ReadLine(DasLevel)) = 2 If Zeile = 3 Then aktLevel(ReadLine(DasLevel), ReadLine(DasLevel)) = 3 Until Eof(DasLevel) = True CloseFile(DasLevel) While Not KeyDown(1) Cls For X = 0 To 49 For Y = 0 To 37 If aktLevel(X,Y) = 1 Then DrawImage Haus1, X*16,Y*16 If aktLevel(X,Y) = 2 Then DrawImage Kiste1, X*16,Y*16 If aktLevel(X,Y) = 3 Then DrawImage Kiste2, X*16,Y*16 Next Next Flip Wend End Wenn ich mit dem Editor ein Level erstelle, wird das so gespeichert: Art der Grafik (1 für Haus, 2 für Kiste, 3 für kl. Kiste) XPosition / 16 YPosition / 16 Wenn ich die Daten dann mit dem 2. Programm auslese, zeichnet er zwar die Bilder und so, aber er vertauscht die X- und Y-Position!! Warum?? ![]() Wenn ich bei If aktLevel(X,Y) = 1 Then DrawImage Haus1, X*16,Y*16 X und Y umdrehe, dann wird es korrekt gezeichnet.. aber warum nicht so? Ich seh nicht so ganz meinen Fehler! ![]() |
||
[20:17] IMurDOOM: hm irgendwie is die mitte des viehs kaputt
[20:17] TRaSh: ein bisschen [20:18] DarkAngel: es tut mir irgend wie leid |
Alu-FolieGast |
![]() Antworten mit Zitat |
|
---|---|---|
Hat sich erledigt... | ||
.:_]TRaSh |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
...kommt schon, ihr seid doch alles solche Superbrains ![]() |
||
[20:17] IMurDOOM: hm irgendwie is die mitte des viehs kaputt
[20:17] TRaSh: ein bisschen [20:18] DarkAngel: es tut mir irgend wie leid |
Alu-FolieGast |
![]() Antworten mit Zitat |
|
---|---|---|
Vertausch doch einfach die For-Next-Schleifen zum ausgeben ![]() |
||
.:_]TRaSh |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
hab ich schon... ändert leider nix | ||
[20:17] IMurDOOM: hm irgendwie is die mitte des viehs kaputt
[20:17] TRaSh: ein bisschen [20:18] DarkAngel: es tut mir irgend wie leid |
Gerhard |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Wahrscheinlich kommst du mit deinen x und y - Werten durcheinander.
Statt: If Mousehit(1) then Level(MX2,MY2) = auswahl (MX2 ist doch MouseX()/16) muss es möglicherweise heissen: If Mousehit(1) then Level(MX,MY) = auswahl MX2 ist doch nicht der glatte 16er Wert, sondern MX. |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group