|
-
Mar 10th, 2000, 04:35 AM
#1
Thread Starter
Addicted Member
How is it that like in starcraft map files which are
a bunch of letters be used by the game?
-
Mar 10th, 2000, 11:49 PM
#2
Member
I could be wrong on this, having never played starcraft, or taken a look at their map files, but, what you're seeing when you open a map file could be an array of information regarding what's where on the map, and its attributtes, that has been saved randomly (as opposed to sequentially). That tends to produce a somewhat less legible, but smaller data file.
-
Mar 11th, 2000, 01:20 AM
#3
Thread Starter
Addicted Member
My questioin is that I was looking at Warcraft files and I know how they did that but then how could I Take that Data and use it like lets say i Had a 64 X 64 grid. Now I want that to be used like in warcraft with diffrent textures for each square which WILL BE "BIT BLITED", Now how would my Progrtam remember all that data without it slowing it DOWN?
Some prograMS i HAVE DONW ARE WHERE i make it Get a square in a STATEMENT
//EXAMPLE
Public Sub GETTILE(X AS INTeger,Y AS INTEGER)
if x = 1 and y = 5 then
GROUND=5
BLOCK=False
end if
end sub
// This works but it is to intensive because I have to Write Everything. But is there a way to import code into a program While it is runing??
-
Mar 11th, 2000, 01:37 AM
#4
Member
Okay, well,
The map is basically an array, either 2d or 3d, etc...
so you set it up :
private Grid(1 to 100,1 to 100)
theres a 100x100 grid
each element is given a number, either manually ie:
Grid(1,1)=1
or you can write an editor program, which is a little long to copy here
Each number represents a tile. ex 1 = grass
Then its just a matter of checking each element to find out what number it is and draw it appropriatly.
I'm working on a game (as a learning experience) which uses a similar setup.
I read/write the grid to a txt file , using a straight forward loop:
For x= 1 to 100
for y= 1 to 100
[Input/Write]#1,grid(x,y)
next y
next x
then I've got functions which compare grid(x,y) to where the player is (for terrain dependant events)
and where the players going (for impassable areas,etc)
If you want to see the whole code email me - [email protected]
the game as it is, i've got at www6.50megs.com/seanm,
I hope that helps a little...
-
Mar 11th, 2000, 02:56 AM
#5
PowerPoster
Uhm,
I just wanted to say that if u use a 1D array that you can resize it without losing data. And it's not much harder to handle.
You can download a demo project from my website: http://derzirkel.tsx.org
-
Mar 11th, 2000, 03:55 AM
#6
Hyperactive Member
I'd go for 2d arrays; easier to use
And I don't usually bother resizing arrays neway
buzzwords are the language of fools
-
Mar 11th, 2000, 04:15 AM
#7
Member
I have come across a neat little trick in converting from 1d to 2d arrays...
The editor i use to make maps is based on a control array of some large number of image boxes...1600, which are arrayed in a grid as in:
123
456
789
the images are set to whatever terrain tile i choose, etc...
but... I was trying to set the x,y coords of objects in the game and had to figure out how to convert the index of the long 1d array to the x,y index of the 2d array, came up with this:
x = (index + 1) Mod width
y = (((index + 1) - ((index + 1) Mod width)) / width) + 1
where width is the width of the 2d array
x is the desired x coord
y is the desired y coord
index is the index of the 1d array where the object is to be placed.
NB it doesn't always work, there are some cases, along the top and sides that screw up, but given a map with a map of two squares, it works.
If anyone knows a simpler way, pray tell.
-
Mar 11th, 2000, 05:08 AM
#8
PowerPoster
Yes, I do... or I just think so 
Look at my code, its an optimized function to draw a map to the screen, you should be able to know what the vars are...
Code:
Public Sub DrawMap()
On Error Resume Next
Dim A As Long
Dim B As Long
Dim Index As Long
Dim Temp As Long
Dim TempX As Single
Dim TempY As Single
TempX = (Camera.X / TileW)
TempY = (Camera.Y / TileH)
'Draw floor tiles
Index = Int(TempY) * MapW + Int(TempX)
For B = 0 To TilesY
For A = 0 To TilesX
'Draw floor
Temp = Map(Index).Floor
BitBlt BackDC, (A - (TempX - Int(TempX))) * TileW, (B - (TempY - Int(TempY))) * TileH, TileW, TileH, Tile(Temp).Picture.DC, 0, 0, vbSrcCopy
Index = Index + 1
Next
Index = Index + MapW - TilesX - 1
Next
End Sub
And it works in every case, also on very top and sides...
-
Mar 11th, 2000, 05:39 AM
#9
Thread Starter
Addicted Member
Heres MY CODE THAT Makes a 640 X 480 map with 32
X 32 Bitmaps or 20 Bitmaps BY 15 bitmaps
/NOTE This uses RENDEROBJECTCOPY which is another sub I Made to us in many DIffrent programs.
//////////////////////
Public GAEGRID(-4 TO 64,-4 TO 64) AS ITEGER
Public Viewx as integer
Public Viewy as integer
Public Sub RENDER_ALL()
QX = 1 ' Current X Row
QY = 1 ' Current Y Col
QT = GRID NUMBER
Do While QY <> 16
QT = GAMEGRID(QX + VIEWX, QY + VIEWY)
RENDEROBJECTCOPY QT, ((QX) * 32) - 32, ((QY) * 32)
QX = QX + 1
If QX = 21 Then
QX = 1
QY = QY + 1
End If
Loop
Form1.Refresh
End Sub
/////////////////
-
Mar 11th, 2000, 05:41 AM
#10
Thread Starter
Addicted Member
I HAD A TYPO
Public GAmEGRID(-4 TO 64,-4 TO 64) AS ITEGER
-
Mar 11th, 2000, 06:14 AM
#11
Thread Starter
Addicted Member
My Map Editor Is Muck Easier With only a few drawbacks.
How it works.
0.MY VIEW AREA is a 640X480 WINDOW scale is set to PIXEL
1.Click on the tile wanted to use
2.click where to place it.
3.The block of land is set.
4.updates view area
/EXAMPLE
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbKeyLButton Then
MOUSECLICKER Int((X) / 32) + 1 + VIEWX, Int((((Y) - 480) * -1) / 32) + 1 + VIEWY
end sub
/////
/EXAMPLE
Public Sub MOUSECLICKER(X As Integer, Y As Integer)
GAMEGRID(X, Y) = CURT
'MsgBox GAMEGRID(X, Y)
Form1.Refresh
RENDER_ALL
End Sub
/////
whenever it updates this is the sub used to copy images from form2 and put them on the main form.
/Note I wanted the Y to Flip so i put Y = (Y - 480) * -1
in it
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Public Sub RENDEROBJECTAND(OBJECTNUMBER As Integer, X As Long, Y As Long)
Y = (Y - 480) * -1
BitBlt Form1.hDC, X, Y, Form2!IMG(OBJECTNUMBER).ScaleWidth, Form2!IMG(OBJECTNUMBER).ScaleHeight, Form2!IMG(OBJECTNUMBER).hDC, 0, 0, vbSrcAnd
End Sub
'Heres my Load/Save Level Stuff
Option Explicit
Declare Function GetPrivateProfileString Lib "Kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, lpKeyName As Any, ByVal lpDefault As String, ByVal lpRetunedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Declare Function WritePrivateProfileString Lib "Kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lplFileName As String) As Long
Global r%
Global entry$
Global iniPath$
Dim HOLDSTRING As String
Dim TX As Integer
Dim TY As Integer
Function GetFromINI(AppName$, KeyName$, FileName$) As String
Dim RetStr As String
RetStr = String(255, Chr(0))
GetFromINI = Left(RetStr, GetPrivateProfileString(AppName$, ByVal KeyName$, "", RetStr, Len(RetStr), FileName$))
End Function
' entry$ = SCENESTUFF(CURS2)
' HJK = Format(CURS2)
' r% = WritePrivateProfileString("SCENE STUFF", HJK, entry$, iniPath$)
Public Sub LOAD_LEVEL_64()
TX = 1
TY = 0
Form3.Show
iniPath$ = App.Path + "\TEST.MAP"
Do While TY <> 65
Form3.P1.Value = TX
Form3.P2.Value = TY
HOLDSTRING = "TILE" + Format(TX) + "X" + Format(TY)
GAMEGRID(TX, TY) = GetFromINI("MAP", HOLDSTRING, iniPath$)
TX = TX + 1
If TX = 65 Then
TX = 1
TY = TY + 1
End If
DoEvents
Loop
RENDER_ALL
Unload Form3
End Sub
Public Sub WRITE_LEVEL_64()
iniPath$ = App.Path + "\TEST.MAP"
TX = 1
TY = 0
Form3.Show
Do While TY <> 65
Form3.P1.Value = TX
Form3.P2.Value = TY
entry$ = GAMEGRID(TX, TY)
HOLDSTRING = "TILE" + Format(TX) + "X" + Format(TY)
r% = WritePrivateProfileString("MAP", HOLDSTRING, entry$, iniPath$)
TX = TX + 1
If TX = 65 Then
TX = 1
TY = TY + 1
End If
DoEvents
Loop
Unload Form3
End Sub
-
Mar 11th, 2000, 08:44 AM
#12
-
Mar 11th, 2000, 11:00 AM
#13
Thread Starter
Addicted Member
IF Anyone wants a demo file I made that is a map Maker
Please e-mail me [email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|