fb:porticula NoPaste
TilemappingProblem
| Uploader: |  MB Interactive Labs | 
| Datum/Zeit: | 06.06.2010 17:58:47 | 
'*********************************************************************************
'* Title Mapping: Funktion ist es aus eine Grafikdatei, die Bilder für meine Land
'*                  schaft zu finden und Anzeigen zu können.
'*********************************************************************************
'* Copyright by: MB Interactive Labs. 2010.
'*********************************************************************************
#Include Once "Inc\MyGrafik.bi"     'Datei die für das Laden der 2D BMP Datein verantwortlich ist
'Größe des Tile angeben (32*32) = 256*256 = ein Bild.
Const tile_Breite = 32
Const tile_hoehe = 32
Dim Shared Zielimg AS ANY PTR
Declare Sub Init_Tile(ByVal myBMPTile As tBMP, ByVal myTile As String)
Declare Sub PutTile(ByVal myBMPTile As tBMP, ByVal index as integer, ByVal w as integer, ByVal h as integer, ByVal x as integer, ByVal y as integer, ByVal z as integer = 0)
Declare Sub Close_Tile(ByVal myBMPTile As tBMP)
Sub Init_Tile(ByVal myBMPTile As tBMP, ByVal myTile As String)
    'Bild für Tilemapping init
    Init_BMP(myBMPTile)
    'Bild in den Speicher laden
    Load_BMP(myBMPTile,myTile)
    'Speicher anlegen
    Zielimg = IMAGECREATE(32,32)
End Sub
Sub PutTile(ByVal myBMPTile As tBMP, ByVal index as integer, ByVal w as integer, ByVal h as integer, ByVal x as integer, ByVal y as integer, ByVal z as integer = 0)
    'Berechnen der Koordinaten
    Dim as double cx, cy, rw, rh, horiz, vert
    index = index - 1
    horiz = fix(myBMPTile.xsize/w)  '' Anzahl der horizontalen Tiles bei 256 = 8 Tile
    vert = fix(myBMPTile.ysize/h)       '' Anzahl der vertikalen Tiles bei 256 = 8 Tile
    cx = (index mod horiz)/horiz        '' X-Position unseres Tiles
    cy = (index\vert)/vert              '' Y-Position unseres Tiles
    rw = 1/horiz            '' Breite eines Tiles (in Texturkoordinatenform)
    rh = 1/vert
    'Mit Get den Bild aus den Bildspeicher laden
    Get myBMPTile.img,(cx,cy)-(cx+32,cy+32),Zielimg
    'Bild anzeigen
    Put (x,y),Zielimg,Alpha,RGB(100,100,100)
End Sub
Sub Close_Tile(ByVal myBMPTile As tBMP)
    Close_BMP(myBMPTile)
    'BildLöschen
    ImageDestroy Zielimg
End Sub
	
 Wer ist online?
 Wer ist online? Buchempfehlung
 Buchempfehlung
 FreeBASIC-Chat
 FreeBASIC-Chat
 FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!
			FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!


