Buchempfehlung
Windows-Programmierung. Das Entwicklerhandbuch zur WIN32-API
Windows-Programmierung. Das Entwicklerhandbuch zur WIN32-API
"Der" Petzold, das über 1000 Seiten starke Standardwerk zum Win32-API - besonders nützlich u. a. bei der GUI-Programmierung in FreeBASIC! [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

Tilemapping mit Standart FB Befehle

Uploader:MitgliedMB Interactive Labs
Datum/Zeit:13.06.2010 12:38:26

'*********************************************************************************
'* 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

Type tCXY
    tCX As Integer
    tCY As Integer
End Type

Declare Sub Init_Tile(myBMPTile As tBMP)
Declare Sub Load_Tile(myBMPTile As tBMP, sBMP As String)
Declare Sub PutTile(myBMPTile As tBMP, index as integer, w as integer, h as integer, x as integer, y as integer, z as integer = 0)
Declare Sub CopyTile(iX As Integer, iY As Integer)
Declare Function FindKoor(index As Integer) As tCXY
Declare Sub Close_Tile(myBMPTile As tBMP)

Sub Init_Tile(myBMPTile As tBMP)
    'Bild für Tilemapping init
    Init_BMP(myBMPTile)

    'Speicher anlegen
    Zielimg = IMAGECREATE(tile_Breite,tile_hoehe)
End Sub

Sub Load_Tile(myBMPTile As tBMP, sBMP As String)
    Load_BMP(myBMPTile,sBMP)
End Sub

Sub PutTile(myBMPTile As tBMP, index as integer, w as integer, h as integer, x as integer, y as integer, z as integer = 0)
    'Berechnen der Koordinaten
    Dim as double cx, cy, rw, rh, horiz, vert
    Dim myKoor As tCXY

    horiz = myBMPTile.xsize/w   '' Anzahl der horizontalen Tiles bei 256 = 8 Tile
    vert = myBMPTile.ysize/h    '' Anzahl der vertikalen Tiles bei 256 = 8 Tile

    'Startpunkt des copybereich finden
    myKoor = FindKoor(index)

    cx = myKoor.tCX      '' X-Position unseres Tiles 'Falsch
    cy = myKoor.tCY    '' Y-Position unseres Tiles 'Falsch

    'Mit Get den Bild aus den Bildspeicher laden
    Get myBMPTile.img,(cx,cy)-(cx+31,cy+31),Zielimg ' Speichert nur den Bildschirmspeicher. Wo ist das Bild was ich vorher geladen hatte hin?

    'Bild anzeigen


End Sub

Sub CopyTile(iX As Integer, iY As Integer)
    'Put (x,y),Zielimg,Alpha,RGB(255,255,255)
    Put (iX,iY),Zielimg,Trans
End Sub

Sub Close_Tile(myBMPTile As tBMP)

    Close_BMP(myBMPTile)

    'BildLöschen
    ImageDestroy Zielimg
End Sub

Function FindKoor(index As Integer) As tCXY
    Dim tempXY As tCXY

    If index = 1 Then
        tempXY.tCX = 0
        tempXY.tCY = 0
    EndIf

    If index = 2 Then
        tempXY.tCX = 32
        tempXY.tCY = 0
    EndIf

    If index = 3 Then
        tempXY.tCX = 64
        tempXY.tCY = 0
    EndIf

    If index = 4 Then
        tempXY.tCX = 96
        tempXY.tCY = 0
    EndIf

    If index = 5 Then
        tempXY.tCX = 128
        tempXY.tCY = 0
    EndIf

    If index = 6 Then
        tempXY.tCX = 160
        tempXY.tCY = 0
    EndIf

    If index = 7 Then
        tempXY.tCX = 192
        tempXY.tCY = 0
    EndIf

    If index = 8 Then
        tempXY.tCX = 224
        tempXY.tCY = 0
    EndIf

    'cy32
    If index = 9 Then
        tempXY.tCX = 0
        tempXY.tCY = 32
    EndIf

    If index = 10 Then
        tempXY.tCX = 32
        tempXY.tCY = 32
    EndIf

    If index = 11 Then
        tempXY.tCX = 64
        tempXY.tCY = 32
    EndIf

    If index = 12 Then
        tempXY.tCX = 96
        tempXY.tCY = 32
    EndIf

    If index = 13 Then
        tempXY.tCX = 128
        tempXY.tCY = 32
    EndIf

    If index = 14 Then
        tempXY.tCX = 160
        tempXY.tCY = 32
    EndIf

    If index = 15 Then
        tempXY.tCX = 192
        tempXY.tCY = 32
    EndIf

    If index = 16 Then
        tempXY.tCX = 224
        tempXY.tCY = 32
    EndIf

    'CY64
    If index = 17 Then
        tempXY.tCX = 0
        tempXY.tCY = 64
    EndIf

    If index = 18 Then
        tempXY.tCX = 32
        tempXY.tCY = 64
    EndIf

    If index = 19 Then
        tempXY.tCX = 64
        tempXY.tCY = 64
    EndIf

    If index = 20 Then
        tempXY.tCX = 96
        tempXY.tCY = 64
    EndIf

    If index = 21 Then
        tempXY.tCX = 128
        tempXY.tCY = 64
    EndIf

    If index = 22 Then
        tempXY.tCX = 160
        tempXY.tCY = 64
    EndIf

    If index = 23 Then
        tempXY.tCX = 192
        tempXY.tCY = 64
    EndIf

    If index = 24 Then
        tempXY.tCX = 224
        tempXY.tCY = 64
    EndIf

    'CY96
    If index = 25 Then
        tempXY.tCX = 0
        tempXY.tCY = 96
    EndIf

    If index = 26 Then
        tempXY.tCX = 32
        tempXY.tCY = 96
    EndIf

    If index = 27 Then
        tempXY.tCX = 64
        tempXY.tCY = 96
    EndIf

    If index = 28 Then
        tempXY.tCX = 96
        tempXY.tCY = 96
    EndIf

    If index = 29 Then
        tempXY.tCX = 128
        tempXY.tCY = 96
    EndIf

    If index = 30 Then
        tempXY.tCX = 160
        tempXY.tCY = 96
    EndIf

    If index = 31 Then
        tempXY.tCX = 192
        tempXY.tCY = 96
    EndIf

    If index = 32 Then
        tempXY.tCX = 224
        tempXY.tCY = 96
    EndIf

    'CY128
    If index = 33 Then
        tempXY.tCX = 0
        tempXY.tCY = 128
    EndIf

    If index = 34 Then
        tempXY.tCX = 32
        tempXY.tCY = 128
    EndIf

    If index = 35 Then
        tempXY.tCX = 64
        tempXY.tCY = 128
    EndIf

    If index = 36 Then
        tempXY.tCX = 96
        tempXY.tCY = 128
    EndIf

    If index = 37 Then
        tempXY.tCX = 128
        tempXY.tCY = 128
    EndIf

    If index = 38 Then
        tempXY.tCX = 160
        tempXY.tCY = 128
    EndIf

    If index = 39 Then
        tempXY.tCX = 192
        tempXY.tCY = 128
    EndIf

    If index = 40 Then
        tempXY.tCX = 224
        tempXY.tCY = 128
    EndIf

    'cy160
    If index = 41 Then
        tempXY.tCX = 0
        tempXY.tCY = 160
    EndIf

    If index = 42 Then
        tempXY.tCX = 32
        tempXY.tCY = 160
    EndIf

    If index = 43 Then
        tempXY.tCX = 64
        tempXY.tCY = 160
    EndIf

    If index = 44 Then
        tempXY.tCX = 96
        tempXY.tCY = 160
    EndIf

    If index = 45 Then
        tempXY.tCX = 128
        tempXY.tCY = 160
    EndIf

    If index = 46 Then
        tempXY.tCX = 160
        tempXY.tCY = 160
    EndIf

    If index = 47 Then
        tempXY.tCX = 192
        tempXY.tCY = 160
    EndIf

    If index = 48 Then
        tempXY.tCX = 224
        tempXY.tCY = 160
    EndIf

    'CY192
    If index = 49 Then
        tempXY.tCX = 0
        tempXY.tCY = 192
    EndIf

    If index = 50 Then
        tempXY.tCX = 32
        tempXY.tCY = 192
    EndIf

    If index = 51 Then
        tempXY.tCX = 64
        tempXY.tCY = 192
    EndIf

    If index = 52 Then
        tempXY.tCX = 96
        tempXY.tCY = 192
    EndIf

    If index = 53 Then
        tempXY.tCX = 128
        tempXY.tCY = 192
    EndIf

    If index = 54 Then
        tempXY.tCX = 160
        tempXY.tCY = 192
    EndIf

    If index = 55 Then
        tempXY.tCX = 192
        tempXY.tCY = 192
    EndIf

    If index = 56 Then
        tempXY.tCX = 224
        tempXY.tCY = 192
    EndIf

    'CY224
    If index = 57 Then
        tempXY.tCX = 0
        tempXY.tCY = 224
    EndIf

    If index = 58 Then
        tempXY.tCX = 32
        tempXY.tCY = 224
    EndIf

    If index = 59 Then
        tempXY.tCX = 64
        tempXY.tCY = 224
    EndIf

    If index = 60 Then
        tempXY.tCX = 96
        tempXY.tCY = 224
    EndIf

    If index = 61 Then
        tempXY.tCX = 128
        tempXY.tCY = 224
    EndIf

    If index = 62 Then
        tempXY.tCX = 160
        tempXY.tCY = 224
    EndIf

    If index = 63 Then
        tempXY.tCX = 192
        tempXY.tCY = 224
    EndIf

    If index = 64 Then
        tempXY.tCX = 224
        tempXY.tCY = 224
    EndIf

    Return tempXY
End Function