ISO
Übersicht

![]() |
N0XBetreff: ISO |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hey!
Bin grad dabei ein ISO-Spiel zu entwickeln, jedoch habe ich bei meinem Map-Editor Probleme. Wie kann ich auf der angeklickten Stelle das Tile ändern? Code: [AUSKLAPPEN] Global mapBreite = 40
Global mapHoehe = 40 Global offsetX = 0 Global offsetY = 0 Global x,y,mx,my,tile = 1,mapx,mapy Dim Karte$(mapBreite-1,mapHoehe-1) ;----------------------------------------; Graphics 1024,768,32,2 SetBuffer BackBuffer() Global tileset = LoadAnimImage("tileset.png",32,16,0,2):MaskImage tileset,255,0,255 While Not KeyHit(1) Cls scrolling() cX = xMax / 2 + offsetX cY = 0 + offsetY For Zeile = 0 To mapHoehe - 1 aktuelleTileX = cX aktuelleTileY = cY For Spalte = 0 To mapBreite - 1 DrawImage tileset,aktuelleTileX - 32, aktuelleTileY,Karte$(mapBreite-1,mapHoehe-1) aktuelleTileX = aktuelleTileX + 16 aktuelleTileY = aktuelleTileY + 8 Next cX = cX - 16 cY = cY + 8 Next If KeyHit(78) Then tile = tile + 1 If KeyHit(74) Then tile = tile - 1 mx = MouseX() my = MouseY() If MouseDown(1) Then calc() Karte$(mapx,mapy) = tile End If If MouseDown(2) Then calc() Karte$(mapx,mapy) = 0 End If Text 0,0,"Ausgewähltes Tile: "+tile Flip 0 Wend End Function calc() mapx = (mx)*cX mapy = (my)*cY End Function Function scrolling() If KeyDown(203) And offsetX < (mapBreite * 64) * 0.6 Then offsetX = offsetX + 8 ;LEFT ElseIf KeyDown(205) And offsetX > -(mapBreite * 64) * 0.6 Then offsetX = offsetX - 8 ;RIGHT EndIf If KeyDown(200) And offsetY < 228 Then offsetY = offsetY + 8 ;UP ElseIf KeyDown(208) And offsetY > -(mapHoehe * 64) * 0.4 Then offsetY = offsetY - 8 ;DOWN EndIf End Function Mfg, N0X (Das Problem bezieht sich auf das Ausrechnen, in der calc()-Funktion) |
||
Projekte: |Tibario| http://www.blitzforum.de/worklogs/325/ | 5% |
![]() |
HolzchopfMeisterpacker |
![]() Antworten mit Zitat ![]() |
---|---|---|
Zu diesem Problem sollte die Such-Funktion ausreichend Lösungen finden...
Schau mal, ob du mit diesem Thread was anfangen kannst. 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 |
![]() |
N0X |
![]() Antworten mit Zitat ![]() |
---|---|---|
Cool, danke!
Ich hab aber irgendwas falsch gemacht, wenn ich "PickedTileX" und auch "PickedTileY" ausgebe, ist diese immer "00". Was habe ich da falsch gemacht? Code: [AUSKLAPPEN] Global mapBreite = 40,mapHoehe = 40
Global offsetX = 0,offsetY = 0 Global mx,my,tile = 1,mapx,mapy Dim Karte$(mapBreite-1,mapHoehe-1) ;-------------------------------------------------------------------------------------| Graphics 1024,768,32,2 SetBuffer BackBuffer() timer = CreateTimer(60) Global tileset = LoadAnimImage("tileset.png",32,16,0,2):MaskImage tileset,255,0,255 While Not KeyHit(1) Cls WaitTimer(timer) scrolling() cX = xMax / 2 + offsetX cY = 0 + offsetY For Zeile = 0 To mapHoehe - 1 aktuelleTileX = cX aktuelleTileY = cY For Spalte = 0 To mapBreite - 1 DrawImage tileset,aktuelleTileX - 32, aktuelleTileY,Karte$(mapBreite-1,mapHoehe-1) aktuelleTileX = aktuelleTileX + 16 aktuelleTileY = aktuelleTileY + 8 Next cX = cX - 16 cY = cY + 8 Next If KeyHit(78) Then tile = tile + 1 If KeyHit(74) Then tile = tile - 1 mx = MouseX() my = MouseY() If MouseDown(1) Then PickTile(mx,my) Karte$(PickedTileX,PickedTileY)= tile Text 0,12,PickedTileX+""+PickedTileY End If If MouseDown(2) Then PickTile(mx,my) Karte$(PickedTileX,PickedTileY) = 0 End If Text 0,0,"Ausgewähltes Tile: "+tile Flip 0 Wend End Function PickTile(px,py) Local tg#, x, y, tx, ty ; Koordinaten transformieren x = Floor(( px +(py -8)*2 ) /32.0) ; 23 = Tilehöhe /2, 92 = Tilebreite y = Floor(( py -(px -16)*0.5 ) /16.0) ; 46 = Tilebreite /2, 46 = Tilehöhe ; Indizes transformieren tx = Floor((x-y)/2) ty = y +x ; Gepickte Koordinaten zuweisen PickedTileX = tx PickedTileY = ty End Function Function scrolling() If KeyDown(203) And offsetX < (mapBreite * 64) * 0.6 Then offsetX = offsetX + 8 ;LEFT ElseIf KeyDown(205) And offsetX > -(mapBreite * 64) * 0.6 Then offsetX = offsetX - 8 ;RIGHT EndIf If KeyDown(200) And offsetY < 228 Then offsetY = offsetY + 8 ;UP ElseIf KeyDown(208) And offsetY > -(mapHoehe * 64) * 0.4 Then offsetY = offsetY - 8 ;DOWN EndIf End Function Mfg, N0X |
||
Projekte: |Tibario| http://www.blitzforum.de/worklogs/325/ | 5% |
![]() |
Midimaster |
![]() Antworten mit Zitat ![]() |
---|---|---|
vergessen sie GLOBAL zu definieren? | ||
![]() |
N0X |
![]() Antworten mit Zitat ![]() |
---|---|---|
Oh, ja! ![]() Blöde Sache, danke Midimaster und Holzchopf! ![]() Mfg, N0X //EDIT: Jetzt weiß ich nicht welche Variable ich von den Picked-Variablen abziehen muss (für das Scrolling), welche sind das? ![]() |
||
Projekte: |Tibario| http://www.blitzforum.de/worklogs/325/ | 5% |
![]() |
Nicdel |
![]() Antworten mit Zitat ![]() |
---|---|---|
OffsetX und OffsetY. Nicht kopieren, verstehen! | ||
Desktop: Intel Pentium 4 2650 Mhz, 2 GB RAM, ATI Radeon HD 3850 512 MB, Windows XP
Notebook: Intel Core i7 720 QM 1.6 Ghz, 4 GB DDR3 RAM, nVidia 230M GT, Windows 7 |
![]() |
XeresModerator |
![]() Antworten mit Zitat ![]() |
---|---|---|
Wenn du zum entwickeln eine IDE benutzt, die undefinierte Variablen hervorhebt (z.B. IDEal), kannst du solche Fehler ausschließen. | ||
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus THERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld) |
![]() |
N0X |
![]() Antworten mit Zitat ![]() |
---|---|---|
IDEal hab ich mir grad geholt.
Klappt eben nicht mit "offsetX" und "offsetY". Code: [AUSKLAPPEN] Global mapBreite = 40,PickedTileX,PickedTileY
Global mapHoehe = 40 Global offsetX = 0 Global offsetY = 0 Global mx,my,tile = 1,mapx,mapy Dim Karte$(mapBreite-1,mapHoehe-1) ;----------------------------------------; Graphics 1024,768,32,2 SetBuffer BackBuffer() timer = CreateTimer(60) Global tileset = LoadAnimImage("tileset.png",32,16,0,2):MaskImage tileset,255,0,255 While Not KeyHit(1) Cls WaitTimer(timer) scrolling() cX = xMax / 2 + offsetX cY = 0 + offsetY For Zeile = 0 To mapHoehe - 1 aktuelleTileX = cX aktuelleTileY = cY For Spalte = 0 To mapBreite - 1 DrawImage tileset,aktuelleTileX - 32, aktuelleTileY,Karte$(mapBreite-1,mapHoehe-1) aktuelleTileX = aktuelleTileX + 16 aktuelleTileY = aktuelleTileY + 8 Next cX = cX - 16 cY = cY + 8 Next If KeyHit(78) Then tile = tile + 1 If KeyHit(74) Then tile = tile - 1 mx = MouseX() my = MouseY() If MouseDown(1) Then PickTile(mx-offsetX,my-offsetY) Karte$(PickedTileX,PickedTileY) = tile Text 0,12,PickedTileX+""+PickedTileY End If If MouseDown(2) Then PickTile(mx-offsetX,my-offsetY) Karte$(PickedTileX,PickedTileY) = 0 End If Text 0,0,"Ausgewähltes Tile: "+tile Flip 0 Wend End Function PickTile(px,py) Local tg#, x, y, tx, ty ; Koordinaten transformieren x = Floor(( px +(py -8)*2 ) /32.0) ; 23 = Tilehöhe /2, 92 = Tilebreite y = Floor(( py -(px -16)*0.5 ) /16.0) ; 46 = Tilebreite /2, 46 = Tilehöhe ; Indizes transformieren tx = Floor((x-y)/2) ty = y +x ; Gepickte Koordinaten zuweisen PickedTileX = tx PickedTileY = ty End Function Function scrolling() If KeyDown(203) And offsetX < (mapBreite * 64) * 0.6 Then offsetX = offsetX + 8 ;LEFT ElseIf KeyDown(205) And offsetX > -(mapBreite * 64) * 0.6 Then offsetX = offsetX - 8 ;RIGHT EndIf If KeyDown(200) And offsetY < 228 Then offsetY = offsetY + 8 ;UP ElseIf KeyDown(208) And offsetY > -(mapHoehe * 64) * 0.4 Then offsetY = offsetY - 8 ;DOWN EndIf End Function Mfg, N0X |
||
Projekte: |Tibario| http://www.blitzforum.de/worklogs/325/ | 5% |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group