scrolling im editor geht nicht richtig
Übersicht

cybyBetreff: scrolling im editor geht nicht richtig |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
hi,
ich habe einen einfachen editor programmiert, man kann mit den pfeiltasten die map scrollen, doch wenn man dann wieder ein tile zeichnen will, wir es nicht an richtigen stelle gezeichnet... die bilder mit code gibt es http://home.arcor.de/24web4free/test1.rar Code: [AUSKLAPPEN] Graphics 800,600,16,2
SetBuffer BackBuffer() ;<<<<<<<<<< tiles laden Global tile1 = LoadImage("gfx\tiles\tile1.bmp") Global tile2 = LoadImage("gfx\tiles\tile2.bmp") Global tile3 = LoadImage("gfx\tiles\tile3.bmp") Global tile4 = LoadImage("gfx\tiles\tile4.bmp") Global tilex = 32 Global tiley = 32 Global mapx = 20 Global mapy = 20 Global scrollingx Global scrollingy Global scrolling_speed = 32 Global layer = 1;gibt den layer Dim mapl1(mapx,mapy) Dim mapl2(mapx,mapy) Dim mapl3(mapx,mapy) Global tile = 2;welches tile mal setzten will... For y = 0 To mapy-1 For x = 0 To mapx-1 mapl1(x,y) = 1 mapl2(x,y) = 0 mapl3(x,y) = 0 Next Next Repeat Cls mx = MouseX() my = MouseY() layer1() If MouseDown(1) If mx > 0 And mx < 800 And my > 0 And my < 400 mapl1(mx/tilex,my/tiley) = tile EndIf EndIf Color 255,0,0 Rect 0,410,800,170 info() ;scrolling If KeyDown(205) Then scrollingx = scrollingx + scrolling_speed ;rechts If KeyDown(200) Then scrollingy = scrollingy - scrolling_speed ;hoch If KeyDown(203) Then scrollingx = scrollingx - scrolling_speed ;links If KeyDown(208) Then scrollingy = scrollingy + scrolling_speed ;runter Flip Until KeyHit(1) End ;<<<<<<<<<<<<<<<<<<<<<<<<< info Function info() Color 0,0,255 Text 10,420,"Tile:"+tile ;welches tile ist gerade ? If tile = 1 Then DrawImage tile1,10,440 ;tile zeichnen If tile = 2 Then DrawImage tile2,10,440 Text 10,480,"Layer:"+layer;gibt an welcher layer aktiv ist End Function ;<<<<<<<<<<<<<<<<<<<<<<< layer1 Function layer1() For y = 0 To mapy-1 For x = 0 To mapx-1 Select mapl1(x,y) Case 1 DrawImage tile1,x*tilex+scrollingx,y*tiley+scrollingy Case 2 DrawImage tile2,x*tilex+scrollingx,y*tiley+scrollingy Case 4 DrawImage tile3,x*tiley+scrollingy,y*tiley+scrollingy End Select Next Next End Function THX mfg cyby ![]() |
||
![]() |
HolzchopfMeisterpacker |
![]() Antworten mit Zitat ![]() |
---|---|---|
Code: [AUSKLAPPEN] mapl1((mx-scrollingx)/tilex,(my-scrollingy)/tiley) = tile So muss das heissen ![]() Du musst die Werte zum setzen der Tiles auch um das Gescrollte korrigieren ![]() MfG |
||
Erledige alles Schritt um Schritt - erledige alles. - Holzchopf
CC BY ♫ BinaryBorn - Yogurt ♫ (31.10.2018) Im Kopf da knackt's und knistert's sturm - 's ist kein Gedanke, nur ein Wurm |
cyby |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
hi,
habe den editor jetzte erweitert - 3layer doch wenn man jetzte eine karte speichert und man sie dann ladet ,geht das nicht richtig, denn dann kommt nur ein scharzer bildschirm .... selbe bilder wie vorhin ... edit: hat sich erledigt ... |
||
cyby |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
jetzte will ich noch einbauen, das sobald man unten auf ein tile klickt das es ausgewählt wird, doch es geht nicht, kann mir wer sagen warum nicht ?
Code: [AUSKLAPPEN] Graphics 800,600,16,2
SetBuffer BackBuffer() ;<<<<<<<<<< tiles laden Global tile1 = LoadImage("gfx\tiles\tile1.bmp") Global tile2 = LoadImage("gfx\tiles\tile2.bmp") Global tile3 = LoadImage("gfx\tiles\tile3.bmp") Global tile4 = LoadImage("gfx\tiles\tile4.bmp") Global tilex = 32 Global tiley = 32 Global mapx = 50 Global mapy = 50 Global scrollingx Global scrollingy Global scrolling_speed = 32 Global layer = 1;gibt den layer Dim mapl1(mapx,mapy) Dim mapl2(mapx,mapy) Dim mapl3(mapx,mapy) Global tile = 2;welches tile mal setzten will... For y = 0 To mapy-1 For x = 0 To mapx-1 mapl1(x,y) = 1 mapl2(x,y) = 0 mapl3(x,y) = 0 Next Next Repeat Cls mx = MouseX() my = MouseY() ;save If KeyHit(59) Then Locate 50,300 FlushKeys save(Input("Speichername: ")) FlushKeys End If ;load If KeyHit(60) Then Locate 400,300 FlushKeys load(Input("Ladename: ")) FlushKeys End If layer1() layer2() layer3() ;links maustase If MouseDown(1) If mx > 0 And mx < 800 And my > 0 And my < 400 If layer = 1 Then mapl1((mx-scrollingx)/tilex,(my-scrollingy)/tiley) = tile If layer = 2 Then mapl2((mx-scrollingx)/tilex,(my-scrollingy)/tiley) = tile If layer = 3 Then mapl3((mx-scrollingx)/tilex,(my-scrollingy)/tiley) = tile EndIf EndIf ;rechte maustaste If MouseHit(2) tile = tile +1 If tile > 4 Then tile = 1 EndIf Color 255,0,0 Rect 0,410,800,170 info() ;layer wechseln If KeyHit(2) Then layer = 1 If KeyHit(3) Then layer = 2 If KeyHit(4) Then layer = 3 ;scrolling If KeyDown(205) Then scrollingx = scrollingx - scrolling_speed ;rechts If KeyDown(200) Then scrollingy = scrollingy + scrolling_speed ;hoch If KeyDown(203) Then scrollingx = scrollingx + scrolling_speed ;links If KeyDown(208) Then scrollingy = scrollingy - scrolling_speed ;runter Flip Until KeyHit(1) End ;<<<<<<<<<<<<<<<<<<<<<<<<< info Function info() Color 0,0,255 Text 10,420,"Tile:"+tile ;welches tile ist gerade ? If tile = 1 Then DrawImage tile1,10,440 ;tile zeichnen If tile = 2 Then DrawImage tile2,10,440 If tile = 3 Then DrawImage tile3,10,440 If tile = 4 Then DrawImage tile4,10,440 Text 10,480,"Layer:"+layer;gibt an welcher layer aktiv ist ;auswählen DrawImage tile1,100,420 DrawImage tile2,132,420 DrawImage tile3,164,420 DrawImage tile4,196,420 If ImageRectCollide(tile1,100,420,0,mx,my,5,5) Then End End Function ;<<<<<<<<<<<<<<<<<<<<<<< layer1 Function layer1() For y = 0 To mapy-1 For x = 0 To mapx-1 Select mapl1(x,y) Case 1 DrawImage tile1,x*tilex+scrollingx,y*tiley+scrollingy Case 2 DrawImage tile2,x*tilex+scrollingx,y*tiley+scrollingy Case 3 DrawImage tile3,x*tilex+scrollingx,y*tiley+scrollingy Case 4 DrawImage tile4,x*tilex+scrollingx,y*tiley+scrollingy End Select Next Next End Function ;<<<<<<<<<<<<<<<<<<<< layer2 Function layer2() For y = 0 To mapy-1 For x = 0 To mapx-1 Select mapl2(x,y) Case 1 DrawImage tile1,x*tilex+scrollingx,y*tiley+scrollingy Case 2 DrawImage tile2,x*tilex+scrollingx,y*tiley+scrollingy Case 3 DrawImage tile3,x*tilex+scrollingx,y*tiley+scrollingy Case 4 DrawImage tile4,x*tilex+scrollingx,y*tiley+scrollingy End Select Next Next End Function ;<<<<<<<<<<<<<<<<<< layer3 Function layer3() For y = 0 To mapy-1 For x = 0 To mapx-1 Select mapl3(x,y) Case 1 DrawImage tile1,x*tilex+scrollingx,y*tiley+scrollingy Case 2 DrawImage tile2,x*tilex+scrollingx,y*tiley+scrollingy Case 3 DrawImage tile3,x*tilex+scrollingx,y*tiley+scrollingy Case 4 DrawImage tile4,x*tilex+scrollingx,y*tiley+scrollingy End Select Next Next End Function ;<<<<<<<<<<<<<<<<< save Function save(name_save$) If name_save = "" Then Else datei1 = WriteFile("maps\"+Str(name_save)+".map") WriteInt(datei1,mapx) WriteInt(datei1,mapy) For y = 0 To mapy-1 For x = 0 To mapx-1 WriteInt(datei1,mapl1(x,y)) WriteInt(datei1,mapl2(x,y)) WriteInt(datei1,mapl3(x,y)) Next Next CloseFile(datei1) EndIf End Function ;<<<<<<<<<<<<<<< laden Function load(name_load$) datei = ReadFile("maps/"+name_load+".map") mapx = ReadInt(datei) mapy = ReadInt(datei) Dim mapl1(mapx,mapy) Dim mapl2(mapx,mapy) Dim mapl3(mapx,mapy) For y = 0 To mapy-1 For x = 0 To mapx-1 mapl1(x,y) = ReadInt(datei) mapl2(x,y) = ReadInt(datei) mapl3(x,y) = ReadInt(datei) Next Next CloseFile(datei) End Function THC mfg cyby ![]() |
||
![]() |
Slayer |
![]() Antworten mit Zitat ![]() |
---|---|---|
vieleicht nicht elegand aber funktioniert ![]() Code: [AUSKLAPPEN] Graphics 800,600,16,2 SetBuffer BackBuffer() ;<<<<<<<<<< tiles laden Global tile1 = LoadImage("gfx\tiles\tile1.bmp") Global tile2 = LoadImage("gfx\tiles\tile2.bmp") Global tile3 = LoadImage("gfx\tiles\tile3.bmp") Global tile4 = LoadImage("gfx\tiles\tile4.bmp") Global tilex = 32 Global tiley = 32 Global mapx = 50 Global mapy = 50 Global scrollingx Global scrollingy Global scrolling_speed = 32 Global layer = 1;gibt den layer Dim mapl1(mapx,mapy) Dim mapl2(mapx,mapy) Dim mapl3(mapx,mapy) Global tile = 2;welches tile mal setzten will... For y = 0 To mapy-1 For x = 0 To mapx-1 mapl1(x,y) = 1 mapl2(x,y) = 0 mapl3(x,y) = 0 Next Next Repeat Cls mx = MouseX() my = MouseY() ;save If KeyHit(59) Then Locate 50,300 FlushKeys save(Input("Speichername: ")) FlushKeys End If ;load If KeyHit(60) Then Locate 400,300 FlushKeys load(Input("Ladename: ")) FlushKeys End If layer1() layer2() layer3() ;links maustase If mx > 0 And mx < 800 And my > 0 And my < 400 If MouseDown(1) ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< If layer = 1 Then mapl1((mx-scrollingx)/tilex,(my-scrollingy)/tiley) = tile If layer = 2 Then mapl2((mx-scrollingx)/tilex,(my-scrollingy)/tiley) = tile If layer = 3 Then mapl3((mx-scrollingx)/tilex,(my-scrollingy)/tiley) = tile EndIf EndIf ;rechte maustaste ;If MouseHit(2) ;tile = tile +1 ;If tile > 4 Then tile = 1 ;EndIf Color 255,0,0 Rect 0,410,800,170 info() ;layer wechseln If KeyHit(2) Then layer = 1 If KeyHit(3) Then layer = 2 If KeyHit(4) Then layer = 3 ;scrolling If KeyDown(205) Then scrollingx = scrollingx - scrolling_speed ;rechts If KeyDown(200) Then scrollingy = scrollingy + scrolling_speed ;hoch If KeyDown(203) Then scrollingx = scrollingx + scrolling_speed ;links If KeyDown(208) Then scrollingy = scrollingy - scrolling_speed ;runter ;############################################################## If mx > 100 And mx < 100 + 32 And my > 420 And my < 420 + 32 If MouseHit(1) Then tile = 1 EndIf If mx > 132 And mx < 132 + 32 And my > 420 And my < 420 + 32 If MouseHit(1) Then tile = 2 EndIf If mx > 164 And mx < 164 + 32 And my > 420 And my < 420 + 32 If MouseHit(1) Then tile = 3 EndIf If mx > 196 And mx < 196 + 32 And my > 420 And my < 420 + 32 If MouseHit(1) Then tile = 4 EndIf ;############################################################ Flip Until KeyHit(1) End ;<<<<<<<<<<<<<<<<<<<<<<<<< info Function info() Color 0,0,255 Text 10,420,"Tile:"+tile ;welches tile ist gerade ? If tile = 1 Then DrawImage tile1,10,440 ;tile zeichnen If tile = 2 Then DrawImage tile2,10,440 If tile = 3 Then DrawImage tile3,10,440 If tile = 4 Then DrawImage tile4,10,440 Text 10,480,"Layer:"+layer;gibt an welcher layer aktiv ist ;auswählen ;<<<<<<<<<<<<<< DrawImage tile1,100,420 DrawImage tile2,132,420 DrawImage tile3,164,420 DrawImage tile4,196,420 If ImageRectCollide(tile1,100,420,0,mx,my,5,5) Then End End Function ;<<<<<<<<<<<<<<<<<<<<<<< layer1 Function layer1() For y = 0 To mapy-1 For x = 0 To mapx-1 Select mapl1(x,y) Case 1 DrawImage tile1,x*tilex+scrollingx,y*tiley+scrollingy Case 2 DrawImage tile2,x*tilex+scrollingx,y*tiley+scrollingy Case 3 DrawImage tile3,x*tilex+scrollingx,y*tiley+scrollingy Case 4 DrawImage tile4,x*tilex+scrollingx,y*tiley+scrollingy End Select Next Next End Function ;<<<<<<<<<<<<<<<<<<<< layer2 Function layer2() For y = 0 To mapy-1 For x = 0 To mapx-1 Select mapl2(x,y) Case 1 DrawImage tile1,x*tilex+scrollingx,y*tiley+scrollingy Case 2 DrawImage tile2,x*tilex+scrollingx,y*tiley+scrollingy Case 3 DrawImage tile3,x*tilex+scrollingx,y*tiley+scrollingy Case 4 DrawImage tile4,x*tilex+scrollingx,y*tiley+scrollingy End Select Next Next End Function ;<<<<<<<<<<<<<<<<<< layer3 Function layer3() For y = 0 To mapy-1 For x = 0 To mapx-1 Select mapl3(x,y) Case 1 DrawImage tile1,x*tilex+scrollingx,y*tiley+scrollingy Case 2 DrawImage tile2,x*tilex+scrollingx,y*tiley+scrollingy Case 3 DrawImage tile3,x*tilex+scrollingx,y*tiley+scrollingy Case 4 DrawImage tile4,x*tilex+scrollingx,y*tiley+scrollingy End Select Next Next End Function ;<<<<<<<<<<<<<<<<< save Function save(name_save$) If name_save = "" Then Else datei1 = WriteFile("maps\"+Str(name_save)+".map") WriteInt(datei1,mapx) WriteInt(datei1,mapy) For y = 0 To mapy-1 For x = 0 To mapx-1 WriteInt(datei1,mapl1(x,y)) WriteInt(datei1,mapl2(x,y)) WriteInt(datei1,mapl3(x,y)) Next Next CloseFile(datei1) EndIf End Function ;<<<<<<<<<<<<<<< laden Function load(name_load$) datei = ReadFile("maps/"+name_load+".map") mapx = ReadInt(datei) mapy = ReadInt(datei) Dim mapl1(mapx,mapy) Dim mapl2(mapx,mapy) Dim mapl3(mapx,mapy) For y = 0 To mapy-1 For x = 0 To mapx-1 mapl1(x,y) = ReadInt(datei) mapl2(x,y) = ReadInt(datei) mapl3(x,y) = ReadInt(datei) Next Next CloseFile(datei) End Function |
||
AMD2500XP, SB5.1, DX9, 512MB DDR333,
XPPro SP1a,ATI 9800SE 256bit 128MB,B3B, B+ immer die neue Version |
cyby |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
schön und gut, aber wenn man eine rießen karte erstellt mit so 150*150 tiles, dann dauert es ewig bis das flip druchläuft (ca. 3sec mit 233mhz)
kann man da noch was ändern , damit das flip schneller durchläuft ? bei großen spiele sind es ja rießen karten wie z.b. bei d4o, da dauert es sicher so 30min von einem zum anderen ende der insel ... ! |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group