Isometrie Mousemapping Problem (gelöst)
Übersicht

![]() |
GoodjeeBetreff: Isometrie Mousemapping Problem (gelöst) |
![]() Antworten mit Zitat ![]() |
---|---|---|
Huhu,
im prinzip läuft alles, es muss nur irgendwo ein kleiner fehler drin sein, der bewirkt dass maus manchmal das benachbarte feld selektiert. Kann mir jemand sagen wo der fehler passiert? ich habe mal versucht das prinzip möglichst gut zu dokumentieren, damit es eventuell wer versteht. edit: fehler gefunden...die mittlere vertikale spalte hat einen sonderfall den ich erst nich beachtet habe, der code ist korrigiert...wer ihn gebrauchen kann kann ihn sich nehmen...von miraus kann der thread geschlossen werden Code: [AUSKLAPPEN] SuperStrict
Graphics 640,480,60 HideMouse Global map:Int[8,8] Global tile:TImage=LoadImage("iso1.png",MASKEDIMAGE) Global sx:Int=288 Global sy:Int=104 Repeat Cls SetColor 255,255,255 For Local x:Int=0 To 8 For Local y:Int=0 To 8 Local PositionX:Int = (x-y) * 32 /2 +sx Local PositionY:Int = (x+y) * 16 /2 +sy DrawImage tile,PositionX,PositionY Next Next Local xy:Int[]=mousemap() SetColor 128,128,128 Local PosX:Int = (xy[0]-xy[1]) * 32 /2 +sx Local PosY:Int = (xy[0]+xy[1]) * 16 /2 +sy DrawImage tile,PosX,PosY SetColor 0,0,255 Plot MouseX(),MouseY() Flip Until(KeyHit(1) Or AppTerminate()) Function mousemap:Int[]() Local mx:Int=MouseX()-sx Local my:Int=MouseY()-sy Local pickedx:Int Local pickedy:Int Local groundx:Int 'das erste tile in einer vertikalen spalte Local groundy:Int 'das erste tile in einer vertikalen spalte If(mx>=0) groundx:Int=mx/32*2 '*2:in einer vertikalen spalte sind versetzt 2 tiles nebeneinander groundy:Int=0 Else groundx:Int=0 groundy:Int=((Abs(mx)/32)+1)*2'+1:das tile x:0 gehört in die erste ifbedinung rein EndIf Local screeny:Int=(groundx+groundy) * 16 /2 'ychoordinate auf dem screen des groundtiles Local deltay:Int=(my-screeny)/16 ' der abstand von maus zu screeny in tiles pickedx=deltay+groundx 'ausgewähltes tile pickedy=deltay+groundy 'ausgewähltes tile Local PosX:Int = (pickedx-pickedy) * 32 /2 'screenchords Local PosY:Int = (pickedx+pickedy) * 16 /2 'screenchords Local xmod:Int=mx-posx 'position der maus im tile Local ymod:Int=my-posy 'position der maus im tile If(xmod>15) xmod=32-xmod 'spiegeln in linke obere ecke If(ymod>7) ymod=16-ymod 'spiegeln in linkere obere exke If(ymod<8-(0.5*xmod)) 'wenn maus außerhalb der raute If(mx<posx+16) 'zu weit links groundx=groundx-(groundx>0)*bigger(mx) 'groundx anpassen, unterscheidung ob links oder rechts in der tilemap groundy=groundy-(groundy>0)*bigger(mx) 'groundy anpassen If(groundx=0 And groundy=0) groundy=1 'mittlere spalte hat einen sonderfall Else 'zu weit rechts groundx=groundx+(groundx>0)*bigger(mx) 'groundx anpassen groundy=groundy+(groundy>0)*bigger(mx) 'groundy anpassen If(groundx=0 And groundy=0) groundx=1 'mittlere spalte hat einen sonderfall EndIf screeny=(groundx+groundy) * 16 /2 'neu berecnnung von screeny deltay=(my-screeny)/16 'abstand in tiles maus->screeny pickedx=deltay+groundx 'pickedx neuberechnen pickedy=deltay+groundy 'pickedy neuberechnen EndIf Return [pickedx,pickedy] End Function Function bigger:Int(mx:Int) If(mx<0) Return -1 Return 1 End Function |
||
"Ideen sind keine Coladosen, man kann sie nicht recyclen"-Dr. House
http://deeebian.redio.de/ http://goodjee.redio.de/ |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group