I want to make levels of about 300x300 tiles and store them later on load in-game or in the editor - what is best for this? i want speed and small filesizes with out compression if possible - what advices would you give me for this?
I think it sohuld be fast enough with a text file like this:
Code: Select all
0.0.0.1.1.1.1
0.0.0.1.1.1.1
0.2.2.0.0.1.1
0.2.2.1.1.1.1
0.0.0.3.3.3.3
0.0.0.1.1.1.1
Where the number is the tile-number at that position.
And use code like this to load it:
Code: Select all
For Y=0 To Map\Height
String = ReadString(#Map)
For X=0 To Map\Width
Map(X,Y) = Val(StringField(String,X+1,"."))
Next
Next
And something like this to draw it:
Code: Select all
For X=0 To Map\Width
For Y=0 To Map\Height
XX = X*16-ViewX
YY = Y*16-ViewY
If XX > -16 And XX < #ScreenWidth And YY > -16 And YY < #ScreenHeight
DisplaySprite3D(Tiles(Map(X,Y)),XX,YY)
EndIf
Next
Next
Where Tiles() is a array holding all the sprite ID's, maybe loaded like this:
Code: Select all
If ExamineDirectory(0,Path,"")
While NextDirectoryEntry(0)
If DirectoryEntryType(0) = #PB_DirectoryEntry_File
ReDim Tiles(i)
Tiles(i) = CreateSprite3D(#PB_Any,LoadSprite(#PB_Any,Path+"\"+DirectoryEntryName(0),#PB_Sprite_Texture))
i + 1
EndIf
Wend
FinishDirectory(0)
EndIf
This is almost what i'm doing in a project now.
But I just started and might change it to a bether method.
But just experiment on your own, trying different ways of doing it until you got something that work for you.
I found out that using Sprite3d really speeds things up, so try to use it!
And you could do something like this in the map drawing to only browse trough the necessary parts in the array: (but carefully, or else you'll get array out of bounds)
Code: Select all
For X=(Player\X-328)/16 To (Player\X+312)/16
For Y=(Player\Y-248)/16 To (Player\Y+232)/16
And then you can loose the:
Code: Select all
If XX > -16 And XX < #ScreenWidth And YY > -16 And YY < #ScreenHeight
If it's to slow having the file as text you could try to save it as bytecode, shouldn't be so hard, and it will take less kb's.
But anyway, good luck to you!