Isometrie und die Maus...

Übersicht BlitzMax, BlitzMax NG Beginners-Corner

Neue Antwort erstellen

Farbfinsternis

Betreff: Isometrie und die Maus...

BeitragMi, Aug 01, 2007 17:02
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich hätte da gerne mal ein Problem ...

Iso ohne Scrolling etc. darstellen bekomme ich ja noch hin, dann aber noch Mauskoordinaten auf der Map zu berechnen ist mir zu hoch. Ich habe es zunächst mit ImagesCollide() probiert, was auch augenscheinlich funktionert, aber einen bösen Nebeneffekt hat: Es werden oft mehr Tiles affektiert als geplant ist:

Code: [AUSKLAPPEN]

SuperStrict

Framework brl.max2d

Import brl.glmax2d
Import brl.bmploader

Graphics(800,600,32)
SetBlend ALPHABLEND

Const TILE_WIDTH:Int   = 64
Const TILE_HEIGHT:Int   = 80

Local tile:TImage         = LoadAnimImage("it.bmp", TILE_WIDTH, TILE_HEIGHT, 0, 2)
Local maus:TImage         = LoadImage("m.bmp")

Global map_w:Int         = 20
Global map_h:Int         = 20
Global map:Int[,]       = New Int[map_w, map_h]

Local fx:Int               = 400
Local fy:Int               = 0

Local off_x:Int            = 32
Local off_y:Int            = 16

Local s:Int                = 0
Local z:Int                = 0

Init()

Repeat
   Cls
   
   Local mx:Int = MouseX()
   Local my:Int = MouseY()
   
   s                     = 0
   z                     = 0
   Local sx:Int   = fx
   Local sy:Int   = fy
   Local x:Int      = sx
   Local y:Int      = sy
   Repeat      
      DrawImage(tile, x, y, map[s, z])
      
      If ImagesCollide(maus, mx, my, 0, tile, x, y, map[s, z])         
         If MouseDown(1) Then map[s, z] = 1
         If MouseDown(2) Then map[s, z] = 0
         SetAlpha 0.5
         DrawImage(tile, x, y, 1)
         SetAlpha 1.0
      End If
      
      x:-off_x
      y:+off_y
      s:+1
      If s = map_w
         s = 0
         
         sx:+off_x
         sy:+off_y
         
         x = sx
         y = sy
         
         z:+1
         
      End If
   Until z = map_h

   DrawImage(maus, mx, my)
   
   Flip
Until KeyHit(KEY_ESCAPE)

End

Function Init()
   Local s:Int                = 0
   Local z:Int                = 0
   Repeat
      map[s, z] = 0

      s:+1
      If s = map_w
         s = 0; z:+1
      End If
   Until z = map_h
End Function


Hier noch die Mediadaten:
Das "Tileset" und hier noch der Mauszeigerpunkt

Hat vielleicht jemand eine Idee wie ich das besser lösen kann?

Danke schonmal für jeden sachdienlichen Hinweis!
Very Happy
Farbfinsternis.tv

hectic

Sieger des IS Talentwettbewerb 2006

BeitragMi, Aug 01, 2007 17:16
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich hab grade sowas mal gemacht. Ist zwar nicht BlitzMax, es wird aber auf direkten Wege die Iso-Map-X/Y-Position berechnet, ohne Tileskollision oder sonstiges. Siehe dazu mein letzten Beitrag unter https://www.blitzforum.de/foru...ht=#260903

Das einzige, was man auf eigene Projekte anpassen muß, ist das X/Y -Offset, was aber kein Problem sein sollte.^^

edit1: Mapbewegung kannst du 'faken' indem zu einfach zu den Mauskoordinaten die Mapposition hinzuaddierst. In meinem Beispiel wäre es dann mx=mx+MapXPos#

Farbfinsternis

BeitragDo, Aug 02, 2007 16:59
Antworten mit Zitat
Benutzer-Profile anzeigen
Danke für die Hilfe hectic, aber ich habe es nun doch mit einem ColorLayer gelöst Smile

Isotest (ca. 58kb)

user posted image
Farbfinsternis.tv

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group