Attribute VB_Name = "modMapaGeneral"
Option Explicit



Type TPosicionRCYPic
    c As Integer
    r As Integer
    NamePic As String
End Type
'Type TPosicionRC
'    c As Integer
'    r As Integer
'End Type

Type TGameChRun
    numescena As Integer
    ArrRenColLineaBi() As TPosicionRCYPic
End Type

Type TPosIcono
    x As Integer
    y As Integer
End Type

Type TMapa
    ArrIconoRenCol() As TPosIcono 'arreglo doble
    NumRenMapa As Integer
    NumColMapa As Integer
    objPics As TPicsGame
    DimensionPantalla As TPantalla
End Type

Public MGameChRun As TGameChRun


Public mObjMapa As TMapa

Public Sub IniciarRutaPicGame()
Dim i As Integer
Dim strtmp As String

    strtmp = App.Path & "\sprites\"
    mObjEscenasVarias.objPics.rutaDir = strtmp
    ReDim mObjEscenasVarias.objPics.ArrPics(0)
    mObjEscenasVarias.objPics.ArrPics(0) = "000.bmp"
End Sub




Public Function BuscarPosicionGameRC(px As Single, py As Single) As TPosicionRC
Dim resp As TPosicionRC
Dim maxX As Integer
Dim maxy As Integer
    
    maxX = mObjEscenasVarias.objPantalla.Ancho
    maxy = mObjEscenasVarias.objPantalla.Alto
    
    
    resp.r = BuscarPosicionGame(py, maxy)
    resp.c = BuscarPosicionGame(px, maxX)
    BuscarPosicionGameRC = resp
    
End Function


Public Function BuscarPosicionGame(pos As Single, ptam As Integer) As Integer
Dim i As Integer
Dim k As Integer
Dim A As Integer
Dim tam As Integer
Dim paso As Single


k = 1
    paso = 32
    
    tam = ptam
    
    For i = 0 To tam Step paso
        If i >= pos Then
            If i + 32 <= pos Then
                A = k - 1
                i = tam
            Else
                A = k - 2
                i = tam
            End If
        Else
            'fue el ultimo elemento
            A = k - 1
        End If
        k = k + 1
    Next
    
    BuscarPosicionGame = A
End Function


