2d editor umrechenproblem
Übersicht

![]() |
kreismanBetreff: 2d editor umrechenproblem |
![]() Antworten mit Zitat ![]() |
---|---|---|
Tach Leute ich hab mir einen Editor(mit tut ^^) geschrieben und wollte dort scrolling einbauen, aber ich schaff es net die Maus koordinaten umzurechen. Hier ist der Code:
Code: [AUSKLAPPEN] Graphics 800,600,16,1 SetBuffer BackBuffer() Global ende Global mx,my Global c=2 Global datei Dim grafik(4) For x=1 To 4 grafik(x)=LoadImage("tile"+Str$(x)+".bmp") Next Dim map(40,40) For y=0 To 39 For x=0 To 39 map(x,y)=1;Map einlesen und auf 1 setzten für Gras Next Next While ende=0 Cls If KeyHit(1)Then ;speichern der Map datei=WriteFile("map.dat");Pfad For y=0 To 39 For x=0 To 39 WriteLine datei,map(x,y) Next Next CloseFile datei ende=1 End If ;mit den Tasten 1-4 wählt man eine Geländeart(Wasser,Wiese,...) If KeyHit(2)Then c=1 If KeyHit(3)Then c=2 If KeyHit(4)Then c=3 If KeyHit(5)Then c=4 If MouseHit(2)Then c=c+1;Mit maus durchschalten If c=5 Then c=1;Wenn c=5 ist, muss es wider 1 sein, weil wir keine Geländeart 5 haben End If ;zeigerkoordinaten mx=(MouseX()/30)-(scrollx) ;So hab ichs versucht /30 weil meine tiles 30 my=(MouseY()/30)-(scrolly) ; pixel groß sind If MouseDown(1) Then map(mx,my)=c ;Gelände setzten End If If MouseX() < 1 Then scrollx=scrollx-30 EndIf If MouseX() > 789 Then scrollx=scrollx+30 EndIf If MouseY() < 1 Then scrolly=scrolly-30 EndIf If MouseY() >589 Then scrolly=scrolly+30 EndIf For y=0 To 39 For x=0 To 39 DrawBlock grafik(map(x,y)),x*30,y*30 ; Map malen! Next Next DrawBlock grafik(c),mx*30,my*30 Color 255,0,0 Rect mx*30,my*30,30,30,0;Ein Rotes, lehres Rechteck wird um den Corsor gemalt Flip Wend End Danke schon mal im voraus |
||
![]() |
Hubsi |
![]() Antworten mit Zitat ![]() |
---|---|---|
Code: [AUSKLAPPEN] mx=MouseX()/30 ;So hab ichs versucht /30 weil meine tiles 30
Denke mal so sollte es funzen.
my=MouseY()/30 ; pixel groß sind If MouseDown(1) Then map(mx+scrollx/30,my+scrolly/30)=c ;Gelände setzten End If |
||
Den ganzen Doag im Bett umanandflagga und iaz daherkema und meine Hendl`n fressn... |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group