I got my isometric system working but I tryed to change it so that it suports some new stuff and I get a error
Atempt to index array element beyond array length
I know from where this error usualy comes but now I can't seem to solve it
Pls take a look at it and tell me wath the hell is wrong...
Atempt to index array element beyond array length
I know from where this error usualy comes but now I can't seem to solve it
Pls take a look at it and tell me wath the hell is wrong...
SuperStrict Type Ttile '///////The Position in the Array////--- NOT USED YET Field x:Int Field y:Int '///////The actual screen drawing coords///---NOT USED YET Field screenx:Float Field screeny:Float '///////The field that contains the vizibility of the tile////---NOTUSED YET Field visible:Int Field tile:Int '///////The function that creates the tile///// Function Create:Ttile(_x:Int , _y:Int, _tile:Int) Local tile:Ttile = New Ttile tile.x = _x tile.y = _y tile.tile = _tile Return tile End Function End Type Type Tmap '/////The name of the map Field name:String '/////The array that contains the tiles Field maparray:Ttile[,] '/////This list contains every single entity '///// A entity is anything other than the tile '///// Examples: the player, a wall , a item , a buiding, a tree and the other stuff '///// NOT USED YET Field EntityList:Tlist '///// The width and height oh the map measured in tiles Field width:Int , height:Int '///// this is a list that contains the types of terrain witch are to be included 'Field TerrainTypes:Tlist--- TO be used later ''''This controls the tiles that are used Field TILEWIDTH:Float , TILEHEIGHT:Float Field Tile_img:Timage Field NrOfTiles:Int '///// Offset variable to be used later Field Offsetx:Int Field Offsety:Int '///// The function that creates the map Function Create:Tmap(_name:String , _width:Int , _height:Int, _TILEWIDTH:Int , _TILEHEIGHT:Int, _Tile_Img:String , _NrOfTiles:Int) Local map:Tmap = New Tmap map.name = _name map.width = _width map.height = _height map.maparray = New Ttile[_width , _height] map.TILEWIDTH = _TILEWIDTH map.TILEHEIGHT = _TILEHEIGHT map.NrOfTiles = _NrOfTiles map.Tile_img = LoadAnimImage(_Tile_Img,_TILEWIDTH,_TILEHEIGHT,0,_NrOfTiles) For Local x:Float = 0 To _width - 1 For Local y:Float = 0 To _height - 1 map.maparray[x, y] = Ttile.Create(x , y , 1) Next Next map.EntityList = CreateList() 'map.TerrainTypes = CreateList() Return map End Function Method render() Local cx:Int = 0 , cy:Int = 0 Local x:Float,y:Float For y = 0 To height - 1 Local ax:Int = cx Local ay:Int = cy For x = 0 To width - 1 Local actualdrawX:Float = ax - TILEWIDTH/2 + offsetx Local actualdrawY:Float = ay + offsety If Not (actualdrawX < 0 - TILEWIDTH Or actualdrawY < 0 - TILEHEIGHT Or actualdrawX > GraphicsWidth() Or actualdrawY > GraphicsHeight()) DrawImage Tile_img , actualdrawX , actualdrawY, maparray[x,y].tile End If ax = ax + TILEWIDTH/2 ay = ay + TILEHEIGHT/2 Next cx = cx - TILEWIDTH/2 cy = cy + TILEHEIGHT/2 Next End Method End Type Function SetupGraphics() Graphics 800, 600, 32 , 60 SetMaskColor 0, 0, 0 SetClsColor 0, 0, 255 'SetColor 255, 255, 255 'SetBlend ALPHABLEND End Function SetupGraphics() Global map:Tmap map = Tmap.Create("Test Map",3 , 3, 256,128,"grass.bmp",1) Global TempTile:Timage = LoadImage("grass.bmp") While Not KeyHit(key_escape) Cls map.render() If MouseX() > GraphicsWidth() - 20 Then map.offsetx:- 15 If MouseY() > GraphicsHeight() - 20 Then map.offsety:- 15 If MouseX() < 20 Then map.offsetx:+ 15 If MouseY() < 20 Then map.offsety:+ 15 Flip Wend