' 
' Written by Paul Grunewald (aka Stormy)
' Date: 07.28.2006
' Mail: Paul.Grunewald@gmail.com
'
#include "inc/2d_opengl.bi"

' Festlegung der Konstanten, die für den Bildschirm wichtig sind
const scrnX = 640
const scrnY = 480
const depth = 32
const fullscreen = &h0           ' Vollbildmodus ( &h0 = aus, &h1 = an )
' Tiles
const tile_width = 32	' Breite
const tile_height = 32	' Höhe

DIM AS GFXType texture

' Initialisiere den Schirm
Init_ogl2D(scrnX, scrnY, depth, fullscreen)

glEnable GL_TEXTURE_2D						' Texturen erlauben.
load_texture ("resources/examples/tilemap.tga", texture)	' Lade eine Textur

WindowTitle "[ Tilemap ]"

' Karte festlegen

DIM MyMap( 1 to 8, 1 to 8 ) as integer => _
    { { 0, 0, 0, 0, 0, 0, 0, 0 }, _
      { 0, 0, 0, 0, 0, 0, 7, 0 }, _
      {41,42,42,42,42,45, 0, 0 }, _
      {49,50,50,50,50,53, 0, 0 }, _
      {49,54,55,63,50,53, 0, 4 }, _
      {57,62,59,60,58,61, 5, 3 }, _
      { 0, 0, 0, 0, 0, 0, 0, 0 }, _
      { 2, 2, 0, 0, 0,12,13, 0 } }

DIM AS INTEGER x, y    

do
  glCls  
  glColor3f 1,1,1
   FOR y = 1 TO 8
    FOR x = 1 TO 8
    IF MyMap(y, x) <> 0 THEN
     PutTile (texture,_
              MyMap(y, x),_
	      tile_width,_
	      tile_height,_
	      (x*tile_width),_
	      (y*tile_height),_
	      0)
     END IF     
    NEXT x
   NEXT y
  glFlush 
  flip 
  screensync
loop until multikey(SC_ESCAPE) ' Verlasse die Schleife sobald Escape gedrückt wird
