Iso-Karte, wie anfangen?

Übersicht BlitzBasic Beginners-Corner

Neue Antwort erstellen

pile

Betreff: Iso-Karte, wie anfangen?

BeitragSo, Mai 30, 2010 12:42
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallo, ich würde gerne ein (strategie) Spiel in guter alter Iso-Perspektive erstellen. Leider finde ich in der SuFu nur scheinbar nützliches zu BMax und das was ich über BB finde, hilft mir nicht so ganz weiter. Kann mir jemand helfen, wie ich da anfangen kann? Scheint ja echt ein schwieriger Bereich zu sein, aber ich wollte keine Vogelperspektive machen, das würde heutzutage eh keiner mehr spielen.
MfG. Pile
Aktuelles Projekt: Irgendwas in den BlitzEditor eintippen und sehen ob was dabei rauskommt. Fortschritt: ca. 3.141592653589793238%

BladeRunner

Moderator

BeitragSo, Mai 30, 2010 12:51
Antworten mit Zitat
Benutzer-Profile anzeigen
Das einzeichnen der Karte läuft im Wesentlichen analog zu top-down, nur das Berechnen der sichtbaren Tiles gestaltet sich wegen der Iso-'Diamanten' ein wenig komplexer, aber da gibt es einen wundervollen Code von HolzChopf zu.

Genauere Hilfe würde genauere Fragestellungen erfordern.

Ach ja, ich spiele gern Topdown.
Zu Diensten, Bürger.
Intel T2300, 2.5GB DDR 533, Mobility Radeon X1600 Win XP Home SP3
Intel T8400, 4GB DDR3, Nvidia GF9700M GTS Win 7/64
B3D BMax MaxGUI

Stolzer Gewinner des BAC#48, #52 & #92
 

Macintosh

BeitragSo, Mai 30, 2010 15:42
Antworten mit Zitat
Benutzer-Profile anzeigen
Hier.. ein tut. von mir. Ob das hilft weis ich nicht, aber ich hoffe ;D
https://www.blitzforum.de/foru...hp?t=33499
Ist aber BlitzMax!

das wurgel

BeitragSo, Mai 30, 2010 16:18
Antworten mit Zitat
Benutzer-Profile anzeigen
Das habe wollte ich auch mal machen, hab dann aber keine Lust mehr gehabt. Hier die Codeleiche:
Code: [AUSKLAPPEN]
Const gfx_w=800
Const gfx_h=600
Const tile_size=256
Const vcur_speed#=0.627329
Const vborder_speed#=0.012583234
Const view_ch_border=90
Const mouse_point_size=24
Const map_height_steps=16

AppTitle "Battlefight Combat"
Graphics gfx_w, gfx_h, 16, 2
Local timer=CreateTimer(60)
SeedRnd MilliSecs()
ClsColor 0, 0, 0
TFormFilter False
ShowPointer


Global map_u=5
Global map_v=4
Global view_x#=tile_size/4*(map_u+map_v)
Global view_y#=tile_size/8*(map_u+map_v)
Global mouse_
Global mouse_x
Global mouse_y
Global mouse_u
Global mouse_v
Global mouse_face_u
Global mouse_face_v
Global mouse_point_u
Global mouse_point_v
Global mouse_point_dist
Global selected_face_u
Global selected_face_v
Global selected_point_u
Global selected_point_v
Global mlhit
Global key_esc
Global speed

Dim Map_height(map_u-1, map_v-1,1,1)

Local ms=MilliSecs()
Local u, v, i

SetBuffer BackBuffer()
Repeat
   
   mlhit=MouseDown(1)
   key_esc=KeyHit(1)
   
   mouse_x=MouseX()
   mouse_y=MouseY()
   mouse_u = Get_U(mouse_x, mouse_y)
   mouse_v = Get_V(mouse_x, mouse_y)
   
   
   speed=MilliSecs()-ms
   ms=MilliSecs()
   
   UpdateView()
   
   Cls
   
   DrawCheckMap()
   If KeyDown(59) Then
      Text 10, 10, mouse_u/tile_size + "x" + mouse_v/tile_size
      Text 10, 30, "mouse_x="+mouse_x
      Text 10, 50, "mouse_y="+mouse_y
      Text 10, 70, "mouse_u="+mouse_u
      Text 10, 90, "mouse_v="+mouse_v
      Text 10, 110, "mouse_face_u="+mouse_face_u
      Text 10, 130, "mouse_face_v="+mouse_face_v
      Text 10, 150, "mouse_point_u="+mouse_point_u
      Text 10, 170, "mouse_point_v="+mouse_point_v
      Text 10, 190, "mouse_point_dist="+mouse_point_dist
   EndIf
   
   Flip 0
   
   WaitTimer timer
Until key_esc
End

Function Get_U(x,y)
   Return 2*(y-(gfx_h/2-view_y))+(x-(map_v*tile_size/2+gfx_w/2-view_x))
End Function
Function Get_V(x,y)
   Return 2*(y-(gfx_h/2-view_y))-(x-(map_v*tile_size/2+gfx_w/2-view_x))
End Function
Function Get_x(u,v)
   Return (u-v+map_v*tile_size)/2+gfx_w/2-view_x
End Function
Function Get_y(u,v)
   Return (u+v)/4+gfx_h/2-view_y
End Function

Function DrawCheckMap()
   Local u, v, i, j, h
   Local first_point=True
   
   For u=0 To map_u
      For v=0 To map_v
         
         If u<map_u And v<map_v Then
            Local x1=Get_x(u*tile_size, v*tile_size)
            Local y1=Get_y(u*tile_size, v*tile_size)-Map_height(u,v, 0,0)*tile_size/map_height_steps
            Local x2=Get_x((u+1)*tile_size, v*tile_size)
            Local y2=Get_y((u+1)*tile_size, v*tile_size)-Map_height(u,v, 1,0)*tile_size/map_height_steps
            Local x3=Get_x((u+1)*tile_size, (v+1)*tile_size)
            Local y3=Get_y((u+1)*tile_size, (v+1)*tile_size)-Map_height(u,v, 1,1)*tile_size/map_height_steps
            Local x4=Get_x(u*tile_size, (v+1)*tile_size)
            Local y4=Get_y(u*tile_size, (v+1)*tile_size)-Map_height(u,v, 0,1)*tile_size/map_height_steps
            
            If PointInQuad(mouse_x, mouse_y, x1, y1, x2, y2, x3, y3, x4, y4) Then
               Local dist
               For i = 0 To 1
                  For j = 0 To 1
                     dist=Pythagoras(mouse_x, mouse_y, Get_x((u+i)*tile_size, (v+j)*tile_size), Get_y((u+i)*tile_size, (v+j)*tile_size)-Map_height(u,v, i,j)*tile_size/map_height_steps)
                     If dist<mouse_point_dist Or first_point Then
                        mouse_point_dist=dist
                        mouse_face_u=u
                        mouse_face_v=v
                        mouse_point_u=i
                        mouse_point_v=j
                        first_point=False
                     EndIf
                  Next
               Next
            EndIf
            
            Color 0, 128, 0
            FilledQuadangle(x1, y1, x2, y2, x3, y3, x4, y4)
            
            Color 255, 255, 255
            Line x1, y1, x2, y2
            Line x2, y2, x3, y3
            Line x3, y3, x4, y4
            Line x4, y4, x1, y1
         EndIf
         
         Color 255, 255, 255
         Local f_exist, p_exist=False
         Local min_h, max_h
         
         If u<map_u And v<map_v Then
            min_h = Map_height(u,v,0,0)*tile_size/map_height_steps
            f_exist=True
         Else
            f_exist=False
         EndIf
         For i = 0 To 1
            For j = 0 To 1
               If i+j>0 Then
                  If u-i>=0 And v-j>=0 And u-i<map_u And v-j<map_v Then
                     h=Map_height(u-i,v-j, i,j)*tile_size/map_height_steps
                     If h>max_h Or (i=0 And j=1)Then max_h=h
                     If f_exist=False Then
                        If Not p_exist Then
                           p_exist=True
                           min_h=h
                        ElseIf h<min_h
                           min_h=h
                        EndIf
                     EndIf
                  EndIf
               EndIf
            Next
         Next
         If min_h<>max_h And (p_exist Or f_exist) Then
            Rect Get_x(u*tile_size, v*tile_size), Get_y(u*tile_size, v*tile_size)-max_h, 1, max_h-min_h
         EndIf
      Next
   Next
   If mlhit Then
      selected_face_u=mouse_face_u
      selected_face_v=mouse_face_v
      selected_point_u=mouse_point_u
      selected_point_v=mouse_point_v
   EndIf
   Map_height(selected_face_u, selected_face_v, selected_point_u, selected_point_v)=Map_height(selected_face_u, selected_face_v, selected_point_u, selected_point_v)+MouseZSpeed()
   
   Color 255, 255, 0
   Oval Get_x((mouse_face_u+mouse_point_u)*tile_size, (mouse_face_v+mouse_point_v)*tile_size)-mouse_point_size/2, Get_y((mouse_face_u+mouse_point_u)*tile_size, (mouse_face_v+mouse_point_v)*tile_size)-mouse_point_size/4-Map_height(mouse_face_u, mouse_face_v, mouse_point_u,mouse_point_v)*tile_size/map_height_steps, mouse_point_size, mouse_point_size/2, 0
   x1=Get_x((mouse_face_u+mouse_point_u)*tile_size, (mouse_face_v+mouse_point_v)*tile_size)
   y1=Get_y((mouse_face_u+mouse_point_u)*tile_size, (mouse_face_v+mouse_point_v)*tile_size)-Map_height(mouse_face_u, mouse_face_v, mouse_point_u,mouse_point_v)*tile_size/map_height_steps
   x2=Get_x((mouse_face_u+mouse_point_u)*tile_size+(1-mouse_point_u*2)*tile_size/8, (mouse_face_v+mouse_point_v)*tile_size+(1-mouse_point_v*2)*tile_size/8)
   y2=Get_y((mouse_face_u+mouse_point_u)*tile_size+(1-mouse_point_u*2)*tile_size/4, (mouse_face_v+mouse_point_v)*tile_size+(1-mouse_point_v*2)*tile_size/4)-Map_height(mouse_face_u, mouse_face_v, mouse_point_u,mouse_point_v)*tile_size/map_height_steps
   Line x1, y1, x2, y2
   
   Color 255, 0, 0
   Oval Get_x((selected_face_u+selected_point_u)*tile_size, (selected_face_v+selected_point_v)*tile_size)-mouse_point_size/2, Get_y((selected_face_u+selected_point_u)*tile_size, (selected_face_v+selected_point_v)*tile_size)-mouse_point_size/4-Map_height(selected_face_u, selected_face_v, selected_point_u,selected_point_v)*tile_size/map_height_steps, mouse_point_size, mouse_point_size/2, 0
   x1=Get_x((selected_face_u+selected_point_u)*tile_size, (selected_face_v+selected_point_v)*tile_size)
   y1=Get_y((selected_face_u+selected_point_u)*tile_size, (selected_face_v+selected_point_v)*tile_size)-Map_height(selected_face_u, selected_face_v, selected_point_u,selected_point_v)*tile_size/map_height_steps
   x2=Get_x((selected_face_u+selected_point_u)*tile_size+(1-selected_point_u*2)*tile_size/8, (selected_face_v+selected_point_v)*tile_size+(1-selected_point_v*2)*tile_size/8)
   y2=Get_y((selected_face_u+selected_point_u)*tile_size+(1-selected_point_u*2)*tile_size/4, (selected_face_v+selected_point_v)*tile_size+(1-selected_point_v*2)*tile_size/4)-Map_height(selected_face_u, selected_face_v, selected_point_u,selected_point_v)*tile_size/map_height_steps
   Line x1, y1, x2, y2
   
End Function

Function UpdateView()
   view_x=view_x+(KeyDown(205)-KeyDown(203))*vcur_speed*speed+(mouse_x>gfx_w-view_ch_border)*(view_ch_border-gfx_w+mouse_x)*vborder_speed*speed-(mouse_x<view_ch_border)*(view_ch_border-mouse_x)*vborder_speed*speed
   view_y=view_y+(KeyDown(208)-KeyDown(200))*vcur_speed*speed+(mouse_y>gfx_h-view_ch_border)*(view_ch_border-gfx_h+mouse_y)*vborder_speed*speed-(mouse_y<view_ch_border)*(view_ch_border-mouse_y)*vborder_speed*speed
End Function

Function Pythagoras#(x1#,y1#,x2#,y2#)
   Return Sqr(Abs(x1-x2)^2+Abs(y1-y2)^2)
End Function

Function FilledTriangle(x1, y1, x2, y2, x3, y3)
   Local tmp
   Local q1y
   Local q2y
   Local px
   If x1 > x2 Then
      tmp=x2 : x2=x1 : x1=tmp
      tmp=y2 : y2=y1 : y1=tmp
   EndIf
   If x1 > x3 Then
      tmp=x3 : x3=x1 : x1=tmp
      tmp=y3 : y3=y1 : y1=tmp
   EndIf
   If x2 > x3 Then
      tmp=x3 : x3=x2 : x2=tmp
      tmp=y3 : y3=y2 : y2=tmp
   EndIf
   For px = x1 To x3
      q1y=y1+(px-x1) * (y3-y1) / (x3-x1+(x3-x1=0))
      If px<x2 Then
         q2y=y1+(px-x1) * (y2-y1) / (x2-x1+(x2-x1=0))
      ElseIf px>x2 Then
         q2y=y2+(px-x2) * (y3-y2) / (x3-x2+(x3-x2=0))
      ElseIf px=x2 Then
         q2y=y2
      EndIf
      If q1y>q2y Then
         tmp=q1y
         q1y=q2y
         q2y=tmp
      EndIf
      Rect px, q1y, 1, q2y-q1y
   Next
End Function

Function PointInTri(px, py, x1, y1, x2, y2, x3, y3)
   Local tmp
   Local q1y
   Local q2y
   If x1 > x2 Then
      tmp=x2 : x2=x1 : x1=tmp
      tmp=y2 : y2=y1 : y1=tmp
   EndIf
   If x1 > x3 Then
      tmp=x3 : x3=x1 : x1=tmp
      tmp=y3 : y3=y1 : y1=tmp
   EndIf
   If x2 > x3 Then
      tmp=x3 : x3=x2 : x2=tmp
      tmp=y3 : y3=y2 : y2=tmp
   EndIf
   If px<x1 Or px>x3 Then Return False
   q1y=y1+(px-x1) * (y3-y1) / (x3-x1+(x3-x1=0))
   If px<x2 Then
      q2y=y1+(px-x1) * (y2-y1) / (x2-x1+(x2-x1=0))
   ElseIf px>x2 Then
      q2y=y2+(px-x2) * (y3-y2) / (x3-x2+(x3-x2=0))
   ElseIf px=x2 Then
      q2y=y2
   EndIf
   If (py<q1y And py>q2y) Or (py>q1y And py<q2y) Then Return True
End Function

Function PointInQuad(px, py, x1, y1, x2, y2, x3, y3, x4, y4)
   Local tmp
   If x1>x3 Then
      tmp=x1 : x1=x3 : x3=tmp
      tmp=y1 : y1=y3 : y3=tmp
   EndIf
   If x2>x4 Then
      tmp=x2 : x2=x4 : x4=tmp
      tmp=y2 : y2=y4 : y4=tmp
   EndIf
   If y1>y2 Then
      tmp=x1 : x1=x2 : x2=tmp
      tmp=y1 : y1=y2 : y2=tmp
   EndIf
   If y3>y4 Then
      tmp=x3 : x3=x4 : x4=tmp
      tmp=y3 : y3=y4 : y4=tmp
   EndIf
   Return PointInTri(px, py, x1, y1, x2, y2, x3, y3) Or PointInTri(px, py, x2, y2, x3, y3, x4, y4)
End Function

Function FilledQuadangle(x1, y1, x2, y2, x3, y3, x4, y4)
   FilledTriangle(x1, y1, x3, y3, x2, y2)
   FilledTriangle(x1, y1, x3, y3, x4, y4)
End Function



Vielleicht hilfts dir ja. Die Umrechungsfunktion (die, die mit Get_ anfangen) könnten auf jeden Fall nützlich sein.
Steuerung: Per Mausklick Punkt anwählen, mit Scrollrad Höhe verändern
1 ist ungefähr 3

pile

BeitragSo, Mai 30, 2010 21:04
Antworten mit Zitat
Benutzer-Profile anzeigen
BladeRunner hat Folgendes geschrieben:


Ach ja, ich spiele gern Topdown.

Naja Sympathiepunkte haste jetzt schonmal Smile

Zitat:
aber da gibt es einen wundervollen Code von HolzChopf zu

Hab den hier gefunden:
https://www.blitzforum.de/foru...961#317961

da muss ich aber erstmal durchsteigen...

Macintosh hat Folgendes geschrieben:


Hier.. ein tut. von mir. Ob das hilft weis ich nicht, aber ich hoffe ;D
https://www.blitzforum.de/forum...hp?t=33499
Ist aber BlitzMax!

Ja das Tutorial fand ich ja supi, ist aber wirklich warscheinlich blos für BMax

Code: [AUSKLAPPEN]
 Das habe wollte ich auch mal machen, hab dann aber keine Lust mehr gehabt. Hier die Codeleiche:
Code: [AUSKLAPPEN] [EINKLAPPEN]
Const gfx_w=800
Const gfx_h=600
Const tile_size=256
Const vcur_speed#=0.627329
Const vborder_speed#=0.012583234
Const view_ch_border=90
Const mouse_point_size=24
Const map_height_steps=16

AppTitle "Battlefight Combat"
Graphics gfx_w, gfx_h, 16, 2
Local timer=CreateTimer(60)
SeedRnd MilliSecs()
ClsColor 0, 0, 0
TFormFilter False
ShowPointer


Global map_u=5
Global map_v=4
Global view_x#=tile_size/4*(map_u+map_v)
Global view_y#=tile_size/8*(map_u+map_v)
Global mouse_
Global mouse_x
Global mouse_y
Global mouse_u
Global mouse_v
Global mouse_face_u
Global mouse_face_v
Global mouse_point_u
Global mouse_point_v
Global mouse_point_dist
Global selected_face_u
Global selected_face_v
Global selected_point_u
Global selected_point_v
Global mlhit
Global key_esc
Global speed

Dim Map_height(map_u-1, map_v-1,1,1)

Local ms=MilliSecs()
Local u, v, i

SetBuffer BackBuffer()
Repeat
   
   mlhit=MouseDown(1)
   key_esc=KeyHit(1)
   
   mouse_x=MouseX()
   mouse_y=MouseY()
   mouse_u = Get_U(mouse_x, mouse_y)
   mouse_v = Get_V(mouse_x, mouse_y)
   
   
   speed=MilliSecs()-ms
   ms=MilliSecs()
   
   UpdateView()
   
   Cls
   
   DrawCheckMap()
   If KeyDown(59) Then
      Text 10, 10, mouse_u/tile_size + "x" + mouse_v/tile_size
      Text 10, 30, "mouse_x="+mouse_x
      Text 10, 50, "mouse_y="+mouse_y
      Text 10, 70, "mouse_u="+mouse_u
      Text 10, 90, "mouse_v="+mouse_v
      Text 10, 110, "mouse_face_u="+mouse_face_u
      Text 10, 130, "mouse_face_v="+mouse_face_v
      Text 10, 150, "mouse_point_u="+mouse_point_u
      Text 10, 170, "mouse_point_v="+mouse_point_v
      Text 10, 190, "mouse_point_dist="+mouse_point_dist
   EndIf
   
   Flip 0
   
   WaitTimer timer
Until key_esc
End

Function Get_U(x,y)
   Return 2*(y-(gfx_h/2-view_y))+(x-(map_v*tile_size/2+gfx_w/2-view_x))
End Function
Function Get_V(x,y)
   Return 2*(y-(gfx_h/2-view_y))-(x-(map_v*tile_size/2+gfx_w/2-view_x))
End Function
Function Get_x(u,v)
   Return (u-v+map_v*tile_size)/2+gfx_w/2-view_x
End Function
Function Get_y(u,v)
   Return (u+v)/4+gfx_h/2-view_y
End Function

Function DrawCheckMap()
   Local u, v, i, j, h
   Local first_point=True
   
   For u=0 To map_u
      For v=0 To map_v
         
         If u<map_u And v<map_v Then
            Local x1=Get_x(u*tile_size, v*tile_size)
            Local y1=Get_y(u*tile_size, v*tile_size)-Map_height(u,v, 0,0)*tile_size/map_height_steps
            Local x2=Get_x((u+1)*tile_size, v*tile_size)
            Local y2=Get_y((u+1)*tile_size, v*tile_size)-Map_height(u,v, 1,0)*tile_size/map_height_steps
            Local x3=Get_x((u+1)*tile_size, (v+1)*tile_size)
            Local y3=Get_y((u+1)*tile_size, (v+1)*tile_size)-Map_height(u,v, 1,1)*tile_size/map_height_steps
            Local x4=Get_x(u*tile_size, (v+1)*tile_size)
            Local y4=Get_y(u*tile_size, (v+1)*tile_size)-Map_height(u,v, 0,1)*tile_size/map_height_steps
           
            If PointInQuad(mouse_x, mouse_y, x1, y1, x2, y2, x3, y3, x4, y4) Then
               Local dist
               For i = 0 To 1
                  For j = 0 To 1
                     dist=Pythagoras(mouse_x, mouse_y, Get_x((u+i)*tile_size, (v+j)*tile_size), Get_y((u+i)*tile_size, (v+j)*tile_size)-Map_height(u,v, i,j)*tile_size/map_height_steps)
                     If dist<mouse_point_dist Or first_point Then
                        mouse_point_dist=dist
                        mouse_face_u=u
                        mouse_face_v=v
                        mouse_point_u=i
                        mouse_point_v=j
                        first_point=False
                     EndIf
                  Next
               Next
            EndIf
           
            Color 0, 128, 0
            FilledQuadangle(x1, y1, x2, y2, x3, y3, x4, y4)
           
            Color 255, 255, 255
            Line x1, y1, x2, y2
            Line x2, y2, x3, y3
            Line x3, y3, x4, y4
            Line x4, y4, x1, y1
         EndIf
         
         Color 255, 255, 255
         Local f_exist, p_exist=False
         Local min_h, max_h
         
         If u<map_u And v<map_v Then
            min_h = Map_height(u,v,0,0)*tile_size/map_height_steps
            f_exist=True
         Else
            f_exist=False
         EndIf
         For i = 0 To 1
            For j = 0 To 1
               If i+j>0 Then
                  If u-i>=0 And v-j>=0 And u-i<map_u And v-j<map_v Then
                     h=Map_height(u-i,v-j, i,j)*tile_size/map_height_steps
                     If h>max_h Or (i=0 And j=1)Then max_h=h
                     If f_exist=False Then
                        If Not p_exist Then
                           p_exist=True
                           min_h=h
                        ElseIf h<min_h
                           min_h=h
                        EndIf
                     EndIf
                  EndIf
               EndIf
            Next
         Next
         If min_h<>max_h And (p_exist Or f_exist) Then
            Rect Get_x(u*tile_size, v*tile_size), Get_y(u*tile_size, v*tile_size)-max_h, 1, max_h-min_h
         EndIf
      Next
   Next
   If mlhit Then
      selected_face_u=mouse_face_u
      selected_face_v=mouse_face_v
      selected_point_u=mouse_point_u
      selected_point_v=mouse_point_v
   EndIf
   Map_height(selected_face_u, selected_face_v, selected_point_u, selected_point_v)=Map_height(selected_face_u, selected_face_v, selected_point_u, selected_point_v)+MouseZSpeed()
   
   Color 255, 255, 0
   Oval Get_x((mouse_face_u+mouse_point_u)*tile_size, (mouse_face_v+mouse_point_v)*tile_size)-mouse_point_size/2, Get_y((mouse_face_u+mouse_point_u)*tile_size, (mouse_face_v+mouse_point_v)*tile_size)-mouse_point_size/4-Map_height(mouse_face_u, mouse_face_v, mouse_point_u,mouse_point_v)*tile_size/map_height_steps, mouse_point_size, mouse_point_size/2, 0
   x1=Get_x((mouse_face_u+mouse_point_u)*tile_size, (mouse_face_v+mouse_point_v)*tile_size)
   y1=Get_y((mouse_face_u+mouse_point_u)*tile_size, (mouse_face_v+mouse_point_v)*tile_size)-Map_height(mouse_face_u, mouse_face_v, mouse_point_u,mouse_point_v)*tile_size/map_height_steps
   x2=Get_x((mouse_face_u+mouse_point_u)*tile_size+(1-mouse_point_u*2)*tile_size/8, (mouse_face_v+mouse_point_v)*tile_size+(1-mouse_point_v*2)*tile_size/8)
   y2=Get_y((mouse_face_u+mouse_point_u)*tile_size+(1-mouse_point_u*2)*tile_size/4, (mouse_face_v+mouse_point_v)*tile_size+(1-mouse_point_v*2)*tile_size/4)-Map_height(mouse_face_u, mouse_face_v, mouse_point_u,mouse_point_v)*tile_size/map_height_steps
   Line x1, y1, x2, y2
   
   Color 255, 0, 0
   Oval Get_x((selected_face_u+selected_point_u)*tile_size, (selected_face_v+selected_point_v)*tile_size)-mouse_point_size/2, Get_y((selected_face_u+selected_point_u)*tile_size, (selected_face_v+selected_point_v)*tile_size)-mouse_point_size/4-Map_height(selected_face_u, selected_face_v, selected_point_u,selected_point_v)*tile_size/map_height_steps, mouse_point_size, mouse_point_size/2, 0
   x1=Get_x((selected_face_u+selected_point_u)*tile_size, (selected_face_v+selected_point_v)*tile_size)
   y1=Get_y((selected_face_u+selected_point_u)*tile_size, (selected_face_v+selected_point_v)*tile_size)-Map_height(selected_face_u, selected_face_v, selected_point_u,selected_point_v)*tile_size/map_height_steps
   x2=Get_x((selected_face_u+selected_point_u)*tile_size+(1-selected_point_u*2)*tile_size/8, (selected_face_v+selected_point_v)*tile_size+(1-selected_point_v*2)*tile_size/8)
   y2=Get_y((selected_face_u+selected_point_u)*tile_size+(1-selected_point_u*2)*tile_size/4, (selected_face_v+selected_point_v)*tile_size+(1-selected_point_v*2)*tile_size/4)-Map_height(selected_face_u, selected_face_v, selected_point_u,selected_point_v)*tile_size/map_height_steps
   Line x1, y1, x2, y2
   
End Function

Function UpdateView()
   view_x=view_x+(KeyDown(205)-KeyDown(203))*vcur_speed*speed+(mouse_x>gfx_w-view_ch_border)*(view_ch_border-gfx_w+mouse_x)*vborder_speed*speed-(mouse_x<view_ch_border)*(view_ch_border-mouse_x)*vborder_speed*speed
   view_y=view_y+(KeyDown(208)-KeyDown(200))*vcur_speed*speed+(mouse_y>gfx_h-view_ch_border)*(view_ch_border-gfx_h+mouse_y)*vborder_speed*speed-(mouse_y<view_ch_border)*(view_ch_border-mouse_y)*vborder_speed*speed
End Function

Function Pythagoras#(x1#,y1#,x2#,y2#)
   Return Sqr(Abs(x1-x2)^2+Abs(y1-y2)^2)
End Function

Function FilledTriangle(x1, y1, x2, y2, x3, y3)
   Local tmp
   Local q1y
   Local q2y
   Local px
   If x1 > x2 Then
      tmp=x2 : x2=x1 : x1=tmp
      tmp=y2 : y2=y1 : y1=tmp
   EndIf
   If x1 > x3 Then
      tmp=x3 : x3=x1 : x1=tmp
      tmp=y3 : y3=y1 : y1=tmp
   EndIf
   If x2 > x3 Then
      tmp=x3 : x3=x2 : x2=tmp
      tmp=y3 : y3=y2 : y2=tmp
   EndIf
   For px = x1 To x3
      q1y=y1+(px-x1) * (y3-y1) / (x3-x1+(x3-x1=0))
      If px<x2 Then
         q2y=y1+(px-x1) * (y2-y1) / (x2-x1+(x2-x1=0))
      ElseIf px>x2 Then
         q2y=y2+(px-x2) * (y3-y2) / (x3-x2+(x3-x2=0))
      ElseIf px=x2 Then
         q2y=y2
      EndIf
      If q1y>q2y Then
         tmp=q1y
         q1y=q2y
         q2y=tmp
      EndIf
      Rect px, q1y, 1, q2y-q1y
   Next
End Function

Function PointInTri(px, py, x1, y1, x2, y2, x3, y3)
   Local tmp
   Local q1y
   Local q2y
   If x1 > x2 Then
      tmp=x2 : x2=x1 : x1=tmp
      tmp=y2 : y2=y1 : y1=tmp
   EndIf
   If x1 > x3 Then
      tmp=x3 : x3=x1 : x1=tmp
      tmp=y3 : y3=y1 : y1=tmp
   EndIf
   If x2 > x3 Then
      tmp=x3 : x3=x2 : x2=tmp
      tmp=y3 : y3=y2 : y2=tmp
   EndIf
   If px<x1 Or px>x3 Then Return False
   q1y=y1+(px-x1) * (y3-y1) / (x3-x1+(x3-x1=0))
   If px<x2 Then
      q2y=y1+(px-x1) * (y2-y1) / (x2-x1+(x2-x1=0))
   ElseIf px>x2 Then
      q2y=y2+(px-x2) * (y3-y2) / (x3-x2+(x3-x2=0))
   ElseIf px=x2 Then
      q2y=y2
   EndIf
   If (py<q1y And py>q2y) Or (py>q1y And py<q2y) Then Return True
End Function

Function PointInQuad(px, py, x1, y1, x2, y2, x3, y3, x4, y4)
   Local tmp
   If x1>x3 Then
      tmp=x1 : x1=x3 : x3=tmp
      tmp=y1 : y1=y3 : y3=tmp
   EndIf
   If x2>x4 Then
      tmp=x2 : x2=x4 : x4=tmp
      tmp=y2 : y2=y4 : y4=tmp
   EndIf
   If y1>y2 Then
      tmp=x1 : x1=x2 : x2=tmp
      tmp=y1 : y1=y2 : y2=tmp
   EndIf
   If y3>y4 Then
      tmp=x3 : x3=x4 : x4=tmp
      tmp=y3 : y3=y4 : y4=tmp
   EndIf
   Return PointInTri(px, py, x1, y1, x2, y2, x3, y3) Or PointInTri(px, py, x2, y2, x3, y3, x4, y4)
End Function

Function FilledQuadangle(x1, y1, x2, y2, x3, y3, x4, y4)
   FilledTriangle(x1, y1, x3, y3, x2, y2)
   FilledTriangle(x1, y1, x3, y3, x4, y4)
End Function



Vielleicht hilfts dir ja. Die Umrechungsfunktion (die, die mit Get_ anfangen) könnten auf jeden Fall nützlich sein.
Steuerung: Per Mausklick Punkt anwählen, mit Scrollrad Höhe verändern


Danke das schaue ich mir mal genauer an, wenn ich etwas mehr zeit habe.
Schönen Abend noch Smile
MfG. Pile
Aktuelles Projekt: Irgendwas in den BlitzEditor eintippen und sehen ob was dabei rauskommt. Fortschritt: ca. 3.141592653589793238%

pile

BeitragMi, Jun 02, 2010 6:53
Antworten mit Zitat
Benutzer-Profile anzeigen
@das wurgel: Also ich hatte gestern mal ne halbe Stunde zeit mich mit deinem Code zu befassen, auch wenn ich nicht wirklich verstanden haben, was die einzelnen Zeilen machen, hab ich gesehen, dass das vorhandene ziemliches Potential hat, auch wenn ich hoffe, später keine Probleme dadurch zu bekommen, dass es sich dabei um eine "Diamond Map" handelt.

Gehe ich richtig in der Annahme, dass eine Vergrößerung oder Verringerung der Variable "tile_size" das macht, was man in einem Spiel dieser Art als zoomen bezeichnen würde, also könnte man daran auch sämtliche anderen Sachen, wie Objekte die auf der Map stehen und die Kameraposition usw., koppeln?
MfG. Pile
Aktuelles Projekt: Irgendwas in den BlitzEditor eintippen und sehen ob was dabei rauskommt. Fortschritt: ca. 3.141592653589793238%

Neue Antwort erstellen


Übersicht BlitzBasic Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group