isometric map editor (images added)
Posted: Fri Feb 26, 2010 7:28 pm
I am still having issues with my the isometric version of my map editor. How do you translate a square array to isometric view?
Tilt it?
{{EDIT}}
You can use these images but have to change the filenames in program for the ground tile... I think the CURSOR is the same
http://www.bluemesapc.com/image/grass0003.BMP
http://www.bluemesapc.com/image/CURSOR0.BMP
DemiVec has helped me INCREDIBLY with the code!
Tilt it?
Code: Select all
; TILE MAP EDITOR
; Ralph Dunn
; many modifications by Jared {DEMIVEC}
;
; ********************************* TO DO
; * Integrate Jareds ZOOM feature
; * Integrate a screenshot feature for current map screen
; * Integrate OPEN MAP feature (for editing)
; * Integrate(?) ISO/HEX maps!
; * Other stuff yet to be named...
; *********************************
;
;- ENUMERATION
Enumeration
#Window_0
EndEnumeration
Enumeration
#CheckBox_HEX
#CheckBox_ISO
#Text_20
#Text_19
#String_YOFFSET
#String_XOFFSET
#Text_CTILE
#Image_CURRENTTILE
#Button_ADDTILE
#Button_REMOVETILE
#Button_SAVE
#Button_OpenTileMap
#String_SAVE
#ListIcon_SPRITES
#Button_MAKENEW
#Text_SPRY
#Text_SPRX
#Text_HIGH
#Text_WIDE
#Text_TID
#Text_CDIT
#Text_TRC
#Text_AY
#Text_LY
#Text_AX
#Text_LX
#Text_MY
#Text_YY
#Text_MX
#Text_XX
#Text_LA
#Text_LASTACTION
#Text_MAP
#String_SPRITEY
#String_SPRITEX
#String_HIGH
#String_WIDE
#ListIcon_TILE
#ScrollBar_1
#ScrollBar_0
#MAPFILE
#MAPIMAGE
#BLANK
EndEnumeration
; *****************************************************
; current imagewindow offset:
; 227,68,770,578
; *****************************************************
#LeftOffset = 227 ; these are used for the mouse cursor
#TopOffset = 68
#ScreenW = 728 ; 770 - cursor width
#ScreenH = 570 ; 578 --- was 530
#ZERO = 0
#Mouse = 1025
#MPoint = 1026
Structure VisualDesignerGadgets
Gadget.l
EventFunction.l
EndStructure
Structure Tile
tid.l
x.f
y.f
ax.f
ay.f
EndStructure
Global NewList Tile.Tile()
;- VARIABLES
Global NewList EventProcedures.VisualDesignerGadgets()
Global Dim LAYER(20,20) ; temp array to hold prites... will be resizable
Global Dim SPR(1024)
Global XWIDE ; x wide of map
Global YHIGH ; y wide of map
Global XW = 12
Global YH = 9
Global SPX ; x wide of sprite
Global SPY ; y wide of sprite
Global ScrollX
Global ScrollY ; variables for scrollbars
Global OffX ; offset X of array to assit in locating TILE in array
Global OffY ; ditto
Global sx.l = 0,sy.l = 0 ;index of top left tile to display from map [Demivec]
Global picoftile ; picture ID of current tile to show!
Global spritenumber ; used to ID spritte in our list of sprites
Global SPID = 1 ; starting number of spriteID
XWIDE = 19 ; map tiles wide and tall
YHIGH = 19
SPX = 256
SPY = 128
sx = 0
sy = 0
InitSprite()
InitMouse()
InitKeyboard()
DataSection
Image0:
IncludeBinary "Point1.bmp"
Image1:
IncludeBinary "floor0a.bmp" ;"Cursor0.bmp"
Image2:
IncludeBinary "floor005.bmp"
Image3:
IncludeBinary "floor002.bmp"
;Image4:
; IncludeBinary "BLANKISO.bmp"
;Image5:
; IncludeBinary "BLANKHEX.bmp"
EndDataSection
;-
Procedure DisplayMap(OffX,OffY)
; set the new values
OFX$ = Str(OffX)
OFY$ = Str(OffY)
Debug "RCVD:: "+OFX$+" / "+OFY$
SetGadgetText(#Text_AX, OFX$)
SetGadgetText(#Text_AY, OFY$)
ResetList(Tile())
For y = 0 To YHIGH
For x = 0 To XWIDE
AddElement(Tile())
Tile()\tid = Val(GetGadgetItemText(#ListIcon_SPRITES, Layer(OffX,OffY)-1, 2))
Tile()\x = XXX
Tile()\y = YYY
Tile()\ax = xray
Tile()\ay = yray
xray = xray + 1
XXX = XXX + SPX
If xray > XWIDE
xray = 0
XXX = 0
EndIf
Next
yray = yray + 1
YYY = YYY + SPY
Next
ForEach Tile()
If Tile()\ax < OffX
DeleteElement(Tile())
EndIf
If Tile()\ax > OffX + 14
DeleteElement(Tile())
EndIf
If Tile()\ay < OffY
DeleteElement(Tile())
EndIf
If Tile()\ay > OffY+ 11
DeleteElement(Tile())
EndIf
Next
; list keeps growing... does not CAP
Debug "LIST HAS "+Str(ListSize(Tile()))
EndProcedure
Procedure OpenTileMap(filename$)
op = 1
If OpenPreferences(filename$) ; if the file could be read, we continue...
PreferenceGroup("VERSION")
Mapstyle$ = ReadPreferenceString("X1", "")
PreferenceGroup("DATA")
Layout$ = ReadPreferenceString("X1", "")
XWIDE = ReadPreferenceLong("X2", 10)
YHIGH = ReadPreferenceLong("X3", 10)
SPX = ReadPreferenceLong("X4", 256)
SPY = ReadPreferenceLong("X5", 128)
PreferenceGroup("LEVEL")
LNUM = ReadPreferenceLong("X1",0)
LVL$ = ReadPreferenceString("X2","")
longis = Len(LVL$) ; is it reporting 0 as 1?
For X = 0 To XWIDE - 1 ; remember arrays start a 0 not 1
For Y = 0 To YWIDE - 1
tnum$ = Mid(LVL$,op,1)
num$ = Str(Asc(tnum$))
numb = Val(num$)
numb = numb - 33
Layer(X,Y) = numb
op = op + 1
Next
Next
ClosePreferences() ; close the previously opened file
Else
MessageRequester("Information","Couldn't open the file: "+filename$ + "!!!")
EndIf
SetGadgetText(#String_SPRITEX, Str(SPX))
SetGadgetText(#String_SPRITEY, Str(SPY))
SetGadgetText(#String_HIGH, Str(XWIDE))
SetGadgetText(#String_WIDE, Str(YWIDE))
EndProcedure
Procedure NewTileMap()
; get the vaues and whang it...
; since PB4.41 has a MAP procedure I had to change the name
; clean all old crap
SetGadgetState(#Scrollbar_0, #PB_ScrollBar_Minimum)
SetGadgetState(#Scrollbar_1, #PB_ScrollBar_Minimum)
XV$ = GetGadgetText(#String_WIDE)
If XV$ = ""
XV$ = "20"
EndIf
XVAL = Val(XV$)
If XVAL < 11
XVAL = 11
EndIf
YV$ = GetGadgetText(#String_HIGH)
If YV$ = ""
YV$ = "20"
EndIf
YVAL = Val(YV$)
If YVAL < 8
YVAL = 8
EndIf
SetGadgetText(#String_WIDE, Str(XVAL))
SetGadgetText(#String_HIGH, Str(YVAL))
Global Dim LAYER(XVal,YVal) ; remakes LAYER()
XWIDE = XVAL
YHIGH = YVAL
For X = 0 To XVal ; Fill with tile 0
For Y = 0 To YVal
LAYER(X,Y) = 0
Next
Next
SPX$ = GetGadgetText(#String_SPRITEX)
If SPX$ = ""
SPX$ = "256"
SetGadgetText(#String_SPRITEX, SPX$)
EndIf
SPX = Val(SPX$)
SPY$ = GetGadgetText(#String_SPRITEY)
If SPY$ = ""
SPY$ = "128"
SetGadgetText(#String_SPRITEY, SPY$)
EndIf
SPY = Val(SPY$)
pw = XW-2
py = YH- 2
SetGadgetAttribute(#Scrollbar_0, #PB_ScrollBar_Maximum, XWIDE - pw)
SetGadgetAttribute(#Scrollbar_1, #PB_ScrollBar_Maximum, YHIGH - py)
SetGadgetState(#Scrollbar_0, 0)
SetGadgetState(#Scrollbar_1, 0)
spritenumber = 1 ; reset sprite number
; clean tiles
; clean sprites
EndProcedure
Procedure ReadLayer(startx,starty,endx,endy)
; startx and starty are controlled by scroolbars
; probably need to reset all X and Y locs in the list to 0 first
For X = startx To endx
For Y = starty To endy
piece = LAYER(X,Y)
; plop tiles into TILE list so we can show them
Tile()\x = xloc
Tile()\y = yloc
Tile()\ax = X
Tile()\ay = Y
yloc = yloc + SPY ; add sprite Y width for redo
Next
xloc = xloc + SPX ; add sprite X wide
Next
EndProcedure
Procedure DoScreenDisplay(inscreen)
;
; Display your screen stuff
If inscreen ; manage mouse events only if mouse is inside screen
ClearScreen(0)
WindowEvent()
ExamineMouse()
MausX$ = Str(MouseX())
MausY$ = Str(MouseY())
SetGadgetText(#Text_MX, MausX$)
SetGadgetText(#Text_MY, MausY$)
EndIf
EndProcedure
;-
Procedure Image_CURRENTTILE_Event(Window, Event, Gadget, Type)
Debug "#Image_CurrentTILE"
; open tile requester
EndProcedure
;-
Procedure CheckBox_HEX_Event(Window, Event, Gadget, Type)
Debug "#CheckBox_HEX"
EndProcedure
Procedure CheckBox_ISO_Event(Window, Event, Gadget, Type)
Debug "#CheckBox_ISO"
EndProcedure
;- *******************************
Procedure Button_SAVE_Event(Window, Event, Gadget, Type)
Debug "#Button_SAVE"
; dump Level() Array to output file with image IDs constructed for easy entry into PB
StandardFile$ = "MAP-0.rwd" ; set initial file+path to display
Pattern$ = "Ralph Map File (*.rwd)|*.rwd|All files (*.*)|*.*"
Pattern = 0 ; use the first of the three possible patterns as standard
File$ = SaveFileRequester("Please choose file to save", StandardFile$, Pattern$, Pattern)
If File$
fie$ = GetFilePart(File$)
If Right(fie$,4) = ".rwd"
TRUBIE = 1
Else
fie$ = fie$ +".rwd"
EndIf
foo = Len(fie$)
foo = foo - 4
gfile$ = Left(Fie$, foo)
; make the tilemap
Result = CountGadgetItems(#ListIcon_SPRITES) + 2
totsprites = spritenumber
; Result = CountGadgetItems(#ListIcon_SPRITES)
Base = Round(Sqr(Result), #PB_Round_Up)
IntBase = Int( Base )
Base2 = IntBase
If Base2 < Base
IntBase +1
EndIf
wide = IntBase * SPX
high = IntBase * SPY
CreateImage(#MAPIMAGE, wide, high , 24)
SPnum = 0
Result = CountGadgetItems(#ListIcon_SPRITES)
Debug "SPRITE LIST HAS: "+Str(Result)
StartDrawing(ImageOutput(#MAPIMAGE))
For IY = 0 To IntBase ; DX Step 128 ; ***** I would love to figure out how to make these variable STEPS!
For IX = 0 To IntBase - 1 ;DY Step 128 ; *****
Debug "tile: "+Str(SPNUM)+" -- LOCATION: "+Str(X)+ " / "+Str(Y)
DrawImage(SPR(SPnum), X,Y)
SPnum + 1 ; = SPnum + 1
X + SPX
If X > wide - SPX ; this wraps it down
X = 0
EndIf
Next
Y + SPY
Next
StopDrawing()
SaveImage(#MAPIMAGE, gfile$+".bmp")
; OK now do the work
CreatePreferences(File$)
PreferenceGroup("VERSION")
WritePreferenceString("X1", "Ralph Map Editor 1.0")
PreferenceGroup("DATA")
WritePreferenceString("X1", "GRID")
WritePreferenceLong("X2", XWIDE)
WritePreferenceLong("X3", YHIGH)
WritePreferenceLong("X4", SPX)
WritePreferenceLong("X5", SPY)
PreferenceGroup("LAYER")
WritePreferenceLong("X1",0)
For X = 0 To XWIDE ; - 1 ; remember arrays start a 0 not 1
For Y = 0 To YHIGH ; - 1
lev = LAYER(X,Y)
lev = lev + 35
num$ = Chr(lev)
layer$ = layer$ + num$
Next
Next
WritePreferenceString("X2",layer$)
PreferenceGroup("MAPDATA")
WritePreferenceString("X1", gfile$+".bmp")
WritePreferenceLong("X2", IntBase)
WritePreferenceLong("X3", totsprites)
ClosePreferences() ; close the previously opened file
Else
MessageRequester("Information", "The requester was canceled.", 0)
EndIf
EndProcedure
Procedure Button_REMOVETILE_Event(Window, Event, Gadget, Type)
; Debug "#Button_REMOVETILE"
EndProcedure
Procedure Button_ADDTILE_Event(Window, Event, Gadget, Type)
Debug "#Button_ADDTILE"
StandardFile$ = "*.bmp" ; set initial file+path to display
Pattern$ = "Bitmap (*.bmp|*.bmp|JPeG(*.jpg)|*.jpg ; *.jpeg|PNGraphics (*.png)|*.png|All files (*.*)|*.*"
Pattern = 0 ; use the first of the three possible patterns as standard
File$ = OpenFileRequester("Please choose Tile to load", StandardFile$, Pattern$, Pattern)
If File$
; load the image
Resultimage = LoadImage(#PB_Any, File$)
SPR(SPID) = ImageID(ResultImage)
SPID = SPID + 1
; ************************************************** does this NOT store the image ID?
Resultsprite = LoadSprite(spritenumber, File$)
; get image id
spriteisid$ = Str(Resultsprite)
imageisid$ = Str(ResultImage)
Filename$ = GetFilePart(File$)
AddGadgetItem(#ListIcon_TILE, -1, filename$, ImageID(ResultImage))
addit$ = ""+Str(spritenumber)+Chr(10)+filename$+Chr(10)+spriteisid$+Chr(10)+imageisid$
AddGadgetItem(#ListIcon_SPRITES, -1, addit$)
SetGadgetState(#Image_CURRENTTILE, ImageID(Resultimage))
SetGadgetText(#Text_LASTACTION, "TILE: "+ filename$+ " -- ADDED")
spritenumber = spritenumber + 1
Else
MessageRequester("Information", "The requester was canceled.", 0)
EndIf
EndProcedure
Procedure Button_MAKENEW_Event(Window, Event, Gadget, Type)
Debug "#Button_MAKENEW"
NewTileMap()
EndProcedure
Procedure Button_OpenTileMap_Event(Window, Event, Gadget, Type)
Debug "#Button_OpenTileMap"
Path$ = GetCurrentDirectory()
Pattern$ = "MAP FILE (*.rwd)|*.rwd|All files (*.*)|*.*"
Pattern = 0 ; use the first of the three possible patterns as standard
filename$ = OpenFileRequester("Please choose file to load", Path$, Pattern$, Pattern)
If Filename$
SetGadgetText(#String_SAVE, filename$)
OpenTileMap(filename$)
Else
MessageRequester("Information", "The requester was canceled.", 0)
EndIf
EndProcedure
;- *******************************
Procedure String_SAVE_Event(Window, Event, Gadget, Type)
;
EndProcedure
Procedure String_SPRITEY_Event(Window, Event, Gadget, Type)
Debug "#String_SPRITEY"
EndProcedure
Procedure String_SPRITEX_Event(Window, Event, Gadget, Type)
Debug "#String_SPRITEX"
EndProcedure
Procedure String_HIGH_Event(Window, Event, Gadget, Type)
Debug "#String_HIGH"
EndProcedure
Procedure String_WIDE_Event(Window, Event, Gadget, Type)
Debug "#String_WIDE"
EndProcedure
;-
Procedure ListIcon_TILE_Event(Window, Event, Gadget, Type)
Debug "#ListIcon_TILE"
; list of possible tiles
plucked = GetGadgetState(#ListIcon_TILE)
Debug "TILE PICKED: "+Str(plucked)
SetGadgetText(#Text_TID, Str(plucked))
RImage$ = GetGadgetItemText(#ListIcon_SPRITES, plucked, 3)
Resultimage = Val(RImage$)
SetGadgetState(#Image_CURRENTTILE, ImageID(Resultimage))
EndProcedure
Procedure ListIcon_SPRITES_Event(Window, Event, Gadget, Type)
; Debug "#ListIcon_SPRITES"
EndProcedure
;-
Procedure ScrollBar_1_Event(Window, event, Gadget, Type) ; VERTICAL SHOULD BE ABLE TO GO TO 17
Debug "#ScrollBar_1"
OffY = GetGadgetState(#ScrollBar_1)
SetGadgetText(#Text_AY, Str(OffY))
sy = OffY ;update offset into LAYER() [Demivec]
EndProcedure
Procedure ScrollBar_0_Event(Window, event, Gadget, Type)
Debug "#ScrollBar_0"
OffX = GetGadgetState(#ScrollBar_0)
SetGadgetText(#Text_AX, Str(OffX))
sx = OffX ;update offset into LAYER() [Demivec]
EndProcedure
;-
Procedure RegisterGadgetEvent(Gadget, *Function)
If IsGadget(Gadget)
AddElement(EventProcedures())
EventProcedures()\Gadget = Gadget
EventProcedures()\EventFunction = *Function
EndIf
EndProcedure
Procedure CallEventFunction(Window, Event, Gadget, Type)
ForEach EventProcedures()
If EventProcedures()\Gadget = Gadget
CallFunctionFast(EventProcedures()\EventFunction, Window, Event, Gadget, Type)
LastElement(EventProcedures())
EndIf
Next
EndProcedure
;-
Procedure Open_Window_MAIN()
If OpenWindow(#Window_0, 0, 0, 1024, 768, "eD1t0r 1.0", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_TitleBar )
;If CreateGadgetList(WindowID(#Window_0))
ScrollBarGadget(#ScrollBar_0, 200, 650, 800, 20,0,XWIDE - XH , 1) ; XH + 1
RegisterGadgetEvent(#ScrollBar_0, @ScrollBar_0_Event())
ScrollBarGadget(#ScrollBar_1, 1000, 50, 20, 600, 0, YHIGH - YW, 1, #PB_ScrollBar_Vertical) ; YW + 1
RegisterGadgetEvent(#ScrollBar_1, @ScrollBar_1_Event())
ListIconGadget(#ListIcon_TILE, 5, 290, 185, 420, "TILES", 160, #PB_ListIcon_GridLines)
RegisterGadgetEvent(#ListIcon_TILE, @ListIcon_TILE_Event())
ListIconGadget(#ListIcon_SPRITES, 640, 675, 355, 80, "S#", 30, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
AddGadgetColumn(#ListIcon_SPRITES, 1, "SPRITE NAME", 150)
AddGadgetColumn(#ListIcon_SPRITES, 2, "SPRITE ID", 80)
AddGadgetColumn(#ListIcon_SPRITES, 3, "", 1) ; image ID
RegisterGadgetEvent(#ListIcon_SPRITES, @ListIcon_SPRITES_Event())
StringGadget(#String_WIDE, 5, 10, 75, 20, "")
StringGadget(#String_HIGH, 85, 10, 70, 20, "")
StringGadget(#String_SPRITEX, 5, 45, 40, 20, "")
StringGadget(#String_SPRITEY, 65, 45, 40, 20, "")
StringGadget(#String_SAVE, 370, 675, 260, 20, "")
StringGadget(#String_XOFFSET, 5, 85, 40, 20, "")
StringGadget(#String_YOFFSET, 65, 85, 40, 20, "")
ButtonGadget(#Button_MAKENEW, 205, 680, 150, 45, "CREATE NEW MAP", #PB_Button_MultiLine)
RegisterGadgetEvent(#Button_MAKENEW, @Button_MAKENEW_Event())
ButtonGadget(#Button_SAVE, 530, 700, 100, 25, "SAVE")
RegisterGadgetEvent(#Button_SAVE, @Button_SAVE_Event())
ButtonGadget(#Button_ADDTILE, 105, 720, 85, 35, "ADD A TILE")
ButtonGadget(#Button_REMOVETILE, 10, 720, 85, 35, "REMOVE A TILE", #PB_Button_MultiLine)
RegisterGadgetEvent(#Button_REMOVETILE, @Button_REMOVETILE_Event())
RegisterGadgetEvent(#Button_ADDTILE, @Button_ADDTILE_Event())
ButtonGadget(#Button_OpenTileMap, 370, 700, 110, 25, "OPEN")
RegisterGadgetEvent(#Button_OpenTileMap, @Button_OpenTileMap_Event())
ImageGadget(#Image_CURRENTTILE, 5, 150, 180, 130, #PB_Image_Border)
RegisterGadgetEvent(#Image_CURRENTTILE, @Image_CURRENTTILE_Event())
TextGadget(#Text_WIDE, 5, 30, 30, 15, "WIDE")
TextGadget(#Text_HIGH, 85, 30, 35, 15, "HIGH")
TextGadget(#Text_SPRX, 5, 65, 40, 15, "SPR X")
TextGadget(#Text_SPRY, 65, 65, 40, 15, "SPR Y")
TextGadget(#Text_CTILE, 5, 130, 90, 15,"CURRENT TILE")
TextGadget(#Text_MAP, 205, 5, 105, 15, "MOUSE LOCATION")
TextGadget(#Text_XX, 205, 25, 10, 15, "X:")
TextGadget(#Text_YY, 260, 25, 10, 15, "Y:")
TextGadget(#Text_LX, 330, 25, 50, 15, "LAYER X:")
TextGadget(#Text_LY, 435, 25, 50, 15, "LAYER Y:")
TextGadget(#Text_TRC, 330, 5, 205, 15, "TOP RIGHT CORNER of LAYER")
TextGadget(#Text_CDIT, 550, 5, 95, 15, "CURRENT TILE ID")
TextGadget(#Text_LA, 665, 5, 85, 15, "LAST ACTIVITY")
TextGadget(#Text_19, 5, 105, 45, 15, "X Offset")
TextGadget(#Text_20, 65, 105, 40, 15, "Y Offset")
TextGadget(#Text_MX, 220, 25, 35, 15, "", #PB_Text_Center | #PB_Text_Border)
TextGadget(#Text_MY, 275, 25, 40, 15, "", #PB_Text_Center | #PB_Text_Border)
TextGadget(#Text_AX, 380, 25, 50, 15, "", #PB_Text_Center | #PB_Text_Border)
TextGadget(#Text_AY, 485, 25, 55, 15, "", #PB_Text_Center | #PB_Text_Border)
TextGadget(#Text_TID,550, 25, 100, 15, "", #PB_Text_Center | #PB_Text_Border)
TextGadget(#Text_LASTACTION, 665, 20, 330, 20, "", #PB_Text_Center | #PB_Text_Border)
CheckBoxGadget(#CheckBox_ISO, 205, 735, 65, 15, "ISO Map")
RegisterGadgetEvent(#CheckBox_ISO, @CheckBox_ISO_Event())
CheckBoxGadget(#CheckBox_HEX, 280, 735, 70, 15, "HEX MAP")
RegisterGadgetEvent(#CheckBox_HEX, @CheckBox_HEX_Event())
; EndIf
EndIf
EndProcedure
Open_Window_MAIN()
;ChangeListIconGadgetDisplay(#ListIcon_TILE, 0) ; image tiles -- OLD WAY 4.0 -
SetGadgetAttribute(#ListIcon_TILE, #PB_ListIcon_DisplayMode, #PB_ListIcon_LargeIcon) ; NEW WAY 4.4+
SetGadgetText(#Text_AX, "0")
SetGadgetText(#Text_AY, "0") ; we always start at 0,0
SetGadgetText(#Text_TID, "0") ; and with tile ZERO
OpenWindowedScreen(WindowID(#Window_0),227,68,770,578,0,0,0)
CatchSprite(#MPoint, ?Image0,#PB_Sprite_Memory)
CatchSprite(#Mouse, ?Image1,#PB_Sprite_Memory)
CatchSprite(#ZERO, ?Image2,0)
CatchImage(#ZERO, ?Image2) ; ***** This is CHEATING!!!
CatchImage(#BLANK,?Image3)
;CatchImage(#ZISO, ?Image4)
;CatchImage(#ZHEX, ?Image5)
SetGadgetState(#Image_CURRENTTILE, ImageID(#ZERO))
AddGadgetItem(#ListIcon_TILE, -1,"BLANK" , ImageID(#ZERO))
; make sure #ZERO is first...
SpriteID = SpriteID(#ZERO)
sprE$ = Str(SpriteID)
AddGadgetItem(#ListIcon_SPRITES, -1, "0"+Chr(10)+"#ZERO"+Chr(10)+sprE$+Chr(10)+"0")
Resu = ImageID(#BLANK) ; ********************************* thi sworks... whole image is BLACK
Debug "IMAGEID: "+Str(Resu)
For X = 0 To 1024
SPR(X) = #BLANK
Next
For x = 0 To XWIDE
For y = 0 To YHIGH
LAYER(x,y) = 0
Next
Next
spritenumber = 1 ; starting ID number for our next sprite as 0 has been taken
NewTileMap()
Repeat
Event = WaitWindowEvent(8)
If inscreen
If MouseX()>#ScreenW-2 Or MouseY()>#ScreenH-2 Or MouseX()<1 Or MouseY()<1
ReleaseMouse(1)
inscreen = #False
EndIf
Else
Gadget = EventGadget()
Type = EventType()
Window = EventWindow()
Select Event
Case #PB_Event_Gadget
CallEventFunction(Window, Event, Gadget, Type)
EndSelect
mx = WindowMouseX(0):my = WindowMouseY(0)
If mx < #ScreenW+#LeftOffset And mx > #LeftOffset And my > #TopOffset And my < #TopOffset+#ScreenH
ReleaseMouse(0)
MouseLocate(mx-#LeftOffset,my-#TopOffset)
inscreen = #True
EndIf
EndIf
DoScreenDisplay(inscreen) ; I have moved this... *** eventually it slows BADLY
If MouseButton(#PB_MouseButton_Left)
; set new tile number into array
ax = (MouseX() + 127) / SPX + OffX ;these show coordinates of tile in map
ay = (MouseY() + 63) / SPY + OffY
goober$ = GetGadgetText(#Text_TID)
tid = Val(goober$)
LAYER(ax,ay) = tid
SetGadgetText(#Text_LASTACTION, "SET TILE: "+ Str(tid) + " / Location: " + Str(ax) + " / "+Str(ay))
EndIf
If MouseButton(#PB_MouseButton_Middle)
;new tile map checking with data directtly from LAYER() [Demivec]
ax = (MouseX() + 127) / SPX + OffX ;these show coordinates of tile in map
ay = (MouseY() + 63) / SPY + OffY
tid = LAYER(ax,ay)
SetGadgetText(#Text_LASTACTION, "TILE: "+ Str(tid) + " / Location: " + Str(ax) + " / "+Str(ay))
EndIf
If MouseButton(#PB_MouseButton_Right)
;new tile map checking with data directtly from LAYER() [Demivec]
tid = LAYER(ax,ay)
ax = (MouseX() + 127) / SPX + OffX ;these show coordinates of tile in map
ay = (MouseY() + 67) / SPY + OffY
LAYER(ax,ay) = 0
SetGadgetText(#Text_LASTACTION, "TILE: "+ Str(tid) + " / Location: " + Str(ax) + " / "+Str(ay) + "* DELETED! *")
EndIf
; DisplayMap(offx,offy) ; is supposed to build only the display portion fo the map
;new map display directly from LAYER() [Demivec]
YYY = 0
For y = sy To sy + YH - 1
XXX = 0
For x = sx To sx + XW - 1
DisplaySprite(LAYER(x,y),XXX , YYY)
XXX + 256 ;SPX
Next
YYY + 128 ;SPY
Next
DisplayTransparentSprite(#Mouse,MouseX(),MouseY())
DisplayTransparentSprite(#MPoint,MouseX()+127,MouseY()+63)
FlipBuffers()
Until Event = #PB_Event_CloseWindow
End
You can use these images but have to change the filenames in program for the ground tile... I think the CURSOR is the same
http://www.bluemesapc.com/image/grass0003.BMP
http://www.bluemesapc.com/image/CURSOR0.BMP
DemiVec has helped me INCREDIBLY with the code!