Computer Science Canada

Tile based engine

Author:  VB_User [ Sun Apr 20, 2003 8:42 pm ]
Post subject:  Tile based engine

Hey ive been working on trying to make a tile based game the past few days and cant seem to get the map loading from a text file working. I wanted to have the text file made up of numbers which represent different tiles. I was going to store each value in a 2 dimensional array since a map is 2 dimension (lxw). If anyone can show me some code to do this i would be greatful because i cant seem to get it working.

thanks

Author:  Martin [ Sun Apr 20, 2003 10:01 pm ]
Post subject: 

code:

var m : int := 10 %the width
var n : int := 16 %the height
var grid : array 1..m, 1..n of int

var mapFile : int
open : mapFile, "awjgajw.awgjaiwe", read
read:mapFile, grid
close : mapFile

Author:  Martin [ Sun Apr 20, 2003 10:04 pm ]
Post subject: 

The above is with binary files...otherwise:
code:

var grid : array 1..x, 1..y of int %X and Y defined beforehand

var ifstream : int
open : ifstream, "awgh.awegaw", get
for a:1..x
 for b:1..y
  get : ifstream, grid(a,b)
 end for
end for

Windows.Crash ()

Author:  VB_User [ Sun Apr 20, 2003 10:27 pm ]
Post subject: 

hmm does this code work for u?

Author:  Dan [ Sun Apr 20, 2003 11:16 pm ]
Post subject: 

well you do have to chage the file name and i dont know whats going on with that "Windows.Crash" stuff, i think drankness is having some fun there Twisted Evil .

this just loads the data in to the progame you need to read it and then deside what title to draw.

and of cores you need to have x and y set to the diments (per title) and have a file that maches this.


: