GameGrid

Previous topic - Next topic

johngood

Hi Again,

Prior to purchasing GLBasic I used 'FBA The Creator' a free compiler for Pocket PC/Smart Phone
and Windows.

Some of the very usefull commands are as follows:

CreatGrid/DrawGrid
Description
Create a grid. A grid is a 2d matrix usually used to create
tiled worlds. A grid is composed by several cells, each cell
is called "tile". With this command FBA allocates memory for
storing a world of [cols x rows] tiles.

Grids are widely used by platform games to draw big maps.

After you create a grid, you can specify which tile index
you want to draw inside each cell; then you should call
drawgrid to render full grid on the screen.
By default FBA fills entire grid with tiles of index -1. (no tile)

Images used by grids, are simple images files which has one or
more tiles inside them placed horizontally.

For example if your grid's cells are 30x30 pixel and you want to use
an image with 5 tiles, this picture should be 150x30 pixels.

Can something like this be implemented in GLBasic as it is? =D

Thanks.
JohnGood.
Dell Dimension 9200: Core 2 Duo 2.40GHz, 2GB Ram, ATI Radeon X1300Pro, Windows XP Pro SP3
Intel Mac SnowLeopard 10.6.4 Core 2 Duo 2.4GHz 2GB Ram
iPod Touch 2G 4.0 16 GB, iPod Touch 4G 4.1 32 GB

Kitty Hello

#1
Code (glbasic) Select
DIM grid%[30][30]
LOADANIM "image.png", 1000, 32,32 // load "tiles"

FOR x=0 TO BOUNDS(grid%[], 0)-1
   FOR y=0 TO BOUNDS(grid%[], 1)-1
      DRAWANIM 1000, grid[x][y], x*gridsize, y*gridsize
   NEXT
NEXT
SHOWSCREEN
MOUSEWAIT


Moru

Just to clarify, what you are looking for is called arrays in most basic dialects.

DIM world[width][height] // This declares a world that is in two dimensions, width and height units big.
However this command fills the array with 0, not -1.

As you see in Kittys post above you can use this to draw the world yourself.

johngood


Thanks to both of you for a quick soloution  :good:

Regards,
JohnGood.
Dell Dimension 9200: Core 2 Duo 2.40GHz, 2GB Ram, ATI Radeon X1300Pro, Windows XP Pro SP3
Intel Mac SnowLeopard 10.6.4 Core 2 Duo 2.4GHz 2GB Ram
iPod Touch 2G 4.0 16 GB, iPod Touch 4G 4.1 32 GB