trying to make a "free hand" map editor =P

Blitz3D Forums/Blitz3D Beginners Area/trying to make a "free hand" map editor =P

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

With as little alteration to your code as possible...

Editor
Graphics 400,400

Type tile
Field ent
Field x
Field y
End Type 

tile=CreateImage(20,20,1)

SetBuffer ImageBuffer(tile)
Color 0,0,100
Rect 0,0,20,20,1
Color 200,200,200
Rect 0,0,20,20,0

SetBuffer BackBuffer()

While Not KeyHit(1)

If MouseHit(1) Then
ob=ob+1
t.tile=New tile
t\ent=CopyImage(tile) 
DrawImage t\ent,MouseX(),MouseY(),0
t\x=MouseX()
t\y=MouseY()
EndIf

If KeyHit(57)
fileout=WriteFile("test3.dat")
WriteInt(fileout,ob)
For t.tile= Each tile
WriteInt(fileout,t\x)
WriteInt(fileout,t\y)
Next 
CloseFile(fileout)
EndIf

Flip
Wend


Loader
Graphics 400,400

Type tile
Field ent
Field x
Field y
End Type

tile=CreateImage(20,20,1)

SetBuffer ImageBuffer(tile)
Color 0,0,100
Rect 0,0,20,20,1
Color 200,200,200
Rect 0,0,20,20,0

SetBuffer BackBuffer()

While Not KeyHit(1)

filein=ReadFile("test3.dat")
ob=ReadInt(filein)
If ob>0
For tt=1 To ob 
t.tile=New tile 
t\ent=CopyImage(tile)
t\x=ReadInt(filein)
t\y=ReadInt(filein)
DrawImage t\ent,t\x,t\y,0

Next
EndIf

Flip
Wend