Archived

This topic is now archived and is closed to further replies.

Zombie

Big problem in tile engine

Recommended Posts

I think that you might have to explain exactly what this code is meant to do.

I had a look at it but really couldn't make heads nor tails of when actions it was ment to perform.

Just explain when each function does and what called it.

[This message has been edited by Gromit (edited December 13, 1999).]

Share this post


Link to post
Share on other sites
I changed David Brebner's (thanks David) tile-based VB example so that it now works in my
game too. But. Could someone say what's the problem when this happens:
When I blit tiles to screen with this code, it doesn't work well. Look at the "picture":

....@..... this is 100*100 tile map, shrinked "@" is tile 2, and "." is tile 1
...@...... when I draw a tile to 50,0 , look what happens.
..@....... The code draws same tile to 40,10 , 30, 20 and so on... of course it
.@........ happens to every tile.
@.........
..........
..........
..........
..........
..........

here is the code I use. If the problem isn't here, I can post more code if you need

code:

Public map(100, 100)
Public NumOfRows As Integer


NumOfRows = 16
'this opens the map to map editor
Open App.Path & "\map.dat" For Random As #1
For xx% = 0 To 100
For yy% = 0 To 100
Get #1, 1 + yy% + xx% * 14, map(xx%, yy%)
Next
Next
Close

'these two Longs get tile from miniature pic of tiles (real size of tiles are 64*60)
Sub drawpens()
u& = BitBlt(hDC, 20, 30, 32, 30, Picture2.hDC, (pen(0) \ NumOfRows) * 32, (pen(0)Mod NumOfRows) * 30, SRCCOPY)
u& = BitBlt(hDC, 120, 30, 32, 30, Picture2.hDC, (pen(1) \ NumOfRows) * 32, (pen(1) Mod NumOfRows) * 30, SRCCOPY)
End Sub

Private Sub Form_Unload(Cancel As Integer)
'this saves the map when quitting map editor
Open App.Path & "\map.dat" For Random As #1
For xx% = 0 To 100
For yy% = 0 To 100
Put #1, 1 + yy% + xx% * 15, map(xx%, yy%)
Next
Next
Close
End Sub

'this procedure blits tiles to picture box
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
If dwn% Then
xx% = X \ 32
yy% = Y \ 30
If Button = 1 Then map(xx% + HScroll1.Value, yy% + VScroll1.Value) = pen(0) Else map(xx% + HScroll1.Value, yy% + VScroll1.Value) = pen(1)
u& = BitBlt(Picture1.hDC, xx% * 32, yy% * 30, 32, 30, Picture2.hDC, (map(xx% + HScroll1.Value, yy% + VScroll1.Value) \ NumOfRows) * 32, (map(xx% + HScroll1.Value, yy% + VScroll1.Value) Mod NumOfRows) * 30, SRCCOPY)
End If
End Sub

'now the game starts
Open App.Path & "\map.dat" For Random As #1
For xxM = 0 To 100
For yyM = 0 To 100
Get #1, 1 + yyM + xxM * 14, map(xxM, yyM)
Next
Next
Close


Share this post


Link to post
Share on other sites