Im doing this for a game engine Im doing, and this will be used to make the Matrixes on, (Once I have a Save Matrix Function)...
It allows you to Add shapes on the Matrix with the Mouse And to use the Mouse to change tile Textures...
The Tools are Listed in the 'Right Click Menu', and they all work...
` Matrix Editor
`
` By Michael Mihalyfi
` MSon648@Hotmail.com
Set Display Mode 800,600,32
` ---------------------------------------------------------------
Perform CheckList For Display Modes
v = CheckList Quantity()
Global MenuForeColor : MenuForeColor = RGB(255,255,255)
Global MenuBackColor : MenuBackColor = RGB(0 ,20 ,0 )
Global Dim Menu$(50)
For n = 1 To v
Menu$(n) = CheckList String$(n)
Next n : Repeat
n = UpdateMenu(0,v,0,0,1)
Until n <> 0
Set Display Mode CheckList Value A(n),CheckList Value B(n),CheckList Value C(n)
Empty CheckList
UnDim Menu$()
` ---------------------------------------------------------------
Disable EscapeKey
Sync On
Sync Rate 0
AutoCam Off
Position Camera 50,10,0
Position Light 0,100,100,100
Make Matrix 1,100,100,50,50
Load Image "C:TileSheet.bmp",1
Prepare Matrix Texture 1,1,2,1
Selector = 6657
Make Object Sphere Selector,2
Hide Object Selector
` Setup Menu
Global MenuForeColor : MenuForeColor = RGB(255,255,255)
Global MenuBackColor : MenuBackColor = RGB(0 ,20 ,0 )
Global Dim Menu$(22)
Menu$(1) = " Raise Matrix Point "
Menu$(2) = " Raise Matrix Area "
Menu$(3) = " Mould Raise Matrix Area "
Menu$(4) = " Set Matrix Tiles With Mouse "
Menu$(5) = " Make Pyramid On Matrix "
Menu$(6) = " Make Random Hill 1 On Matrix "
Menu$(7) = " Make Random Hill 2 On Matrix "
Menu$(8) = "--------------------------------------------"
Menu$(9) = " Set Matrix WireFrame Mode "
Menu$(10) = " Set Matrix Ghost Mode "
Menu$(11) = "--------------------------------------------"
Menu$(12) = " Exit "
Menu$(13) = "-----------------"
Menu$(14) = " On "
Menu$(15) = " Off "
Menu$(16) = "-----------------"
Menu$(17) = "- Are You Sure? -"
Menu$(18) = " Yes "
Menu$(19) = " No "
Menu$(20) = "------------------------"
Menu$(21) = " File "
Menu$(22) = " Matrix Commands "
Do : Click = MouseClick()
Key$ = Inkey$()
xTile = GetMatrixMouseX(1,100,100,50,50)
yTile = GetMatrixMouseY(1,100,100,50,50)
If xTile => 0 And yTile => 0
Position Object Selector,2 * xTile,Get Matrix Height(1,xTile,yTile),2 * yTile
Show Object Selector
Else
Hide Object Selector
EndIf
` Right Click Menu
If Click = 2 : n = UpdateMenu(21,22,MouseX() + 10,MouseY() - 10,1) : ` Main Menu
If n = 21 Then n = UpdateMenu(12,12,MouseX() + 10,MouseY() - 10,1) : ` File Menu
If n = 22 Then n = UpdateMenu( 1,10,MouseX() + 10,MouseY() - 10,1) : ` Matrix Menu
GoSub MenuControls : EndIf
Ink -1,0
Text 10,10,"Mouse Over Matrix xTile: " + Str$(xTile)
Text 10,20,"Mouse Over Matrix yTile: " + Str$(yTile)
Text 10,40,"Right Click for the Menu..."
Text 10,60,"Active Tool: " + Menu$(Tool)
If Tool = 1 Then RaiseMatrixPointWithMouse(1,100,100,50,50)
If Tool = 2 Then RaiseMatrixWithMouse(1,100,100,50,50)
If Tool = 3 Then MouldRaiseMatrixWithMouse(1,100,100,50,50)
If Tool = 4 Then SetMatrixTileWithMouse(1,100,100,50,50)
If Tool = 5 Then TriangleMatrixWithMouse(1,100,100,50,50)
If Tool = 6 Then RandomHill1MatrixWithMouse(1,100,100,50,50)
If Tool = 7 Then RandomHill2MatrixWithMouse(1,100,100,50,50)
Control Camera Using ArrowKeys 0,5,5
FastSync
Loop
Function RaiseMatrixPointWithMouse(Mn,Width#,Lenth#,xSeg,ySeg)
x = GetMatrixMouseX(Mn,Width#,Lenth#,xSeg,ySeg)
y = GetMatrixMouseY(Mn,Width#,Lenth#,xSeg,ySeg)
If x > -1 And y > -1
Set Matrix Height Mn,x,y,Get Matrix Height(Mn,x,y) + (MouseMoveZ() / 100)
Update Matrix Mn
ExitFunction 1
EndIf
EndFunction 0
Function SetMatrixTileWithMouse(Mn,Width#,Lenth#,xSeg,ySeg)
` Returns a Value of 0 If NOT Activated
` Returns a Value of -1 If Used, but invalid Coordinates Specified
` Else Returns 1 if Used
`
` Instructions:
` 1: Hold the Left Click Button on Your Mouse when over a TilePoint
` 2: While Left Clicked move the Mouse Over the TilePoint to go to
` 3: Release the Left Mouse Button
` 4: Use Mouse Z To Inc/Dec Height in the Selected Area
` 5: Right Click to Exit Function
`
` By Michael Mihalyfi
` MSon648@Hotmail.Com
If MouseClick() <> 1 Then ExitFunction 0
xa = GetMatrixMouseX(Mn,Width#,Lenth#,xSeg,ySeg)
ya = GetMatrixMouseY(Mn,Width#,Lenth#,xSeg,ySeg)
Repeat
xb = GetMatrixMouseX(Mn,Width#,Lenth#,xSeg,ySeg)
yb = GetMatrixMouseY(Mn,Width#,Lenth#,xSeg,ySeg)
Until MouseClick() = 0
If xa = -1 Then ExitFunction -1
If ya = -1 Then ExitFunction -1
If xb = -1 Then ExitFunction -1
If yb = -1 Then ExitFunction -1
x1 = Smallest(xa,xb)
y1 = Smallest(ya,yb)
x2 = Largest(xa,xb)
y2 = Largest(ya,yb)
Tile = 1
Repeat
If MouseClick() = 1 Then Inc Tile,1 : WaitForMouseClickValue(0)
If Tile > Matrix Tile Count(Mn) Then Tile = 1
For y = y1 To y2
For x = x1 To x2
Set Matrix Tile Mn,x,y,Tile
Next x : Next y
Update Matrix Mn : Sync
Until MouseClick() = 2
WaitForMouseClickValue(0)
EndFunction 1
Function RaiseMatrixWithMouse(Mn,Width#,Lenth#,xSeg,ySeg)
` Returns a Value of 0 If NOT Activated
` Returns a Value of -1 If Used, but invalid Coordinates Specified
` Else Returns 1 if Used
`
` Instructions:
` 1: Hold the Left Click Button on Your Mouse when over a TilePoint
` 2: While Left Clicked move the Mouse Over the TilePoint to go to
` 3: Release the Left Mouse Button
` 4: Use Mouse Z To Inc/Dec Height in the Selected Area
` 5: Right Click to Exit Function
`
` By Michael Mihalyfi
` MSon648@Hotmail.Com
If MouseClick() <> 1 Then ExitFunction 0
xa = GetMatrixMouseX(Mn,Width#,Lenth#,xSeg,ySeg)
ya = GetMatrixMouseY(Mn,Width#,Lenth#,xSeg,ySeg)
Repeat
xb = GetMatrixMouseX(Mn,Width#,Lenth#,xSeg,ySeg)
yb = GetMatrixMouseY(Mn,Width#,Lenth#,xSeg,ySeg)
Until MouseClick() = 0
If xa = -1 Then ExitFunction -1
If ya = -1 Then ExitFunction -1
If xb = -1 Then ExitFunction -1
If yb = -1 Then ExitFunction -1
x1 = Smallest(xa,xb)
y1 = Smallest(ya,yb)
x2 = Largest(xa,xb)
y2 = Largest(ya,yb)
Repeat
Height# = Get Matrix Height(Mn,x1,y1) + (MouseMoveZ() / 100)
For y = y1 To y2
For x = x1 To x2
Set Matrix Height Mn,x,y,Height#
Next x : Next y
Update Matrix Mn : Sync
Until MouseClick() = 2
WaitForMouseClickValue(0)
EndFunction 1
Function MouldRaiseMatrixWithMouse(Mn,Width#,Lenth#,xSeg,ySeg)
` Returns a Value of 0 If NOT Activated
` Returns a Value of -1 If Used, but invalid Coordinates Specified
` Else Returns 1 if Used
`
` Instructions:
` 1: Hold the Left Click Button on Your Mouse when over a TilePoint
` 2: While Left Clicked move the Mouse Over the TilePoint to go to
` 3: Release the Left Mouse Button
` 4: Use Mouse Z To Inc/Dec Height in the Selected Area
` 5: Right Click to Exit Function
`
` By Michael Mihalyfi
` MSon648@Hotmail.Com
If MouseClick() <> 1 Then ExitFunction 0
xa = GetMatrixMouseX(Mn,Width#,Lenth#,xSeg,ySeg)
ya = GetMatrixMouseY(Mn,Width#,Lenth#,xSeg,ySeg)
Repeat
xb = GetMatrixMouseX(Mn,Width#,Lenth#,xSeg,ySeg)
yb = GetMatrixMouseY(Mn,Width#,Lenth#,xSeg,ySeg)
Until MouseClick() = 0
If xa = -1 Then ExitFunction -1
If ya = -1 Then ExitFunction -1
If xb = -1 Then ExitFunction -1
If yb = -1 Then ExitFunction -1
x1 = Smallest(xa,xb)
y1 = Smallest(ya,yb)
x2 = Largest(xa,xb)
y2 = Largest(ya,yb)
Repeat
Height# = (MouseMoveZ() / 100)
For y = y1 To y2
For x = x1 To x2
Set Matrix Height Mn,x,y,Get Matrix Height(Mn,x,y) + Height#
Next x : Next y
Update Matrix Mn : Sync
Until MouseClick() = 2
WaitForMouseClickValue(0)
EndFunction 1
Function TriangleMatrixWithMouse(Mn,Width#,Lenth#,xSeg,ySeg)
` Returns a Value of 0 If NOT Activated
` Returns a Value of -1 If Used, but invalid Coordinates Specified
` Else Returns 1 if Used
`
` Instructions:
` 1: Hold the Left Click Button on Your Mouse when over a TilePoint
` 2: While Left Clicked move the Mouse Over the TilePoint to go to
` 3: Release the Left Mouse Button
` 4: Use Mouse Z To Inc/Dec Height in the Selected Area
` 5: Right Click to Exit Function
`
` By Michael Mihalyfi
` MSon648@Hotmail.Com
If MouseClick() <> 1 Then ExitFunction 0
xa = GetMatrixMouseX(Mn,Width#,Lenth#,xSeg,ySeg)
ya = GetMatrixMouseY(Mn,Width#,Lenth#,xSeg,ySeg)
Repeat
xb = GetMatrixMouseX(Mn,Width#,Lenth#,xSeg,ySeg)
yb = GetMatrixMouseY(Mn,Width#,Lenth#,xSeg,ySeg)
Until MouseClick() = 0
If xa = -1 Then ExitFunction -1
If ya = -1 Then ExitFunction -1
If xb = -1 Then ExitFunction -1
If yb = -1 Then ExitFunction -1
Repeat
zValue# = zValue# + MouseMoveZ() / 100
Height# = Get Matrix Height(Mn,x1,y1)
xa = x1
xb = x2
ya = y1
yb = y2
Repeat
Inc Height#,zValue#
Inc xa,1
Inc ya,1
Dec xb,1
Dec yb,1
For y = ya To yb
For x = xa To xb
Set Matrix Height Mn,x,y,Height#
Next x : Next y
Until xa => xb Or ya => yb
Update Matrix Mn : Sync
Until MouseClick() = 2
WaitForMouseClickValue(0)
EndFunction 1
Function RandomHill1MatrixWithMouse(Mn,Width#,Lenth#,xSeg,ySeg)
` Returns a Value of 0 If NOT Activated
` Returns a Value of -1 If Used, but invalid Coordinates Specified
` Else Returns 1 if Used
`
` Instructions:
` 1: Hold the Left Click Button on Your Mouse when over a TilePoint
` 2: While Left Clicked move the Mouse Over the TilePoint to go to
` 3: Release the Left Mouse Button
` 4: Use Mouse Z To Inc/Dec Height in the Selected Area
` 5: Right Click to Exit Function
`
` By Michael Mihalyfi
` MSon648@Hotmail.Com
If MouseClick() <> 1 Then ExitFunction 0
xa = GetMatrixMouseX(Mn,Width#,Lenth#,xSeg,ySeg)
ya = GetMatrixMouseY(Mn,Width#,Lenth#,xSeg,ySeg)
Repeat
xb = GetMatrixMouseX(Mn,Width#,Lenth#,xSeg,ySeg)
yb = GetMatrixMouseY(Mn,Width#,Lenth#,xSeg,ySeg)
Until MouseClick() = 0
If xa = -1 Then ExitFunction -1
If ya = -1 Then ExitFunction -1
If xb = -1 Then ExitFunction -1
If yb = -1 Then ExitFunction -1
x1 = Smallest(xa,xb)
y1 = Smallest(ya,yb)
x2 = Largest(xa,xb)
y2 = Largest(ya,yb)
Repeat
zValue# = zValue# + MouseMoveZ() / 100
Height# = Get Matrix Height(Mn,x1,y1)
xa = x1
xb = x2
ya = y1
yb = y2
Repeat
Inc xa,1
Inc ya,1
Dec xb,1
Dec yb,1
Inc Height#,Rnd(zValue#)
For y = ya To yb
For x = xa To xb
Set Matrix Height Mn,x,y,Height#
Next x : Next y
Until xa => xb Or ya => yb
Update Matrix Mn : Sync
Until MouseClick() = 2
WaitForMouseClickValue(0)
EndFunction 1
Function RandomHill2MatrixWithMouse(Mn,Width#,Lenth#,xSeg,ySeg)
` Returns a Value of 0 If NOT Activated
` Returns a Value of -1 If Used, but invalid Coordinates Specified
` Else Returns 1 if Used
`
` Instructions:
` 1: Hold the Left Click Button on Your Mouse when over a TilePoint
` 2: While Left Clicked move the Mouse Over the TilePoint to go to
` 3: Release the Left Mouse Button
` 4: Use Mouse Z To Inc/Dec Height in the Selected Area
` 5: Right Click to Exit Function
`
` By Michael Mihalyfi
` MSon648@Hotmail.Com
If MouseClick() <> 1 Then ExitFunction 0
xa = GetMatrixMouseX(Mn,Width#,Lenth#,xSeg,ySeg)
ya = GetMatrixMouseY(Mn,Width#,Lenth#,xSeg,ySeg)
Repeat
xb = GetMatrixMouseX(Mn,Width#,Lenth#,xSeg,ySeg)
yb = GetMatrixMouseY(Mn,Width#,Lenth#,xSeg,ySeg)
Until MouseClick() = 0
If xa = -1 Then ExitFunction -1
If ya = -1 Then ExitFunction -1
If xb = -1 Then ExitFunction -1
If yb = -1 Then ExitFunction -1
x1 = Smallest(xa,xb)
y1 = Smallest(ya,yb)
x2 = Largest(xa,xb)
y2 = Largest(ya,yb)
Repeat
zValue# = zValue# + MouseMoveZ() / 100
Height# = Get Matrix Height(Mn,x1,y1)
xa = x1
xb = x2
ya = y1
yb = y2
Repeat
Inc xa,1
Inc ya,1
Dec xb,1
Dec yb,1
For y = ya To yb
For x = xa To xb
Inc Height#,Rnd(zValue#) / xSeg
Set Matrix Height Mn,x,y,Height#
Next x : Next y
Until xa => xb Or ya => yb
Update Matrix Mn : Sync
Until MouseClick() = 2
WaitForMouseClickValue(0)
EndFunction 1
Function GetMatrixMouseX(Mn,Width#,Lenth#,xSeg,ySeg)
` Returns the Matrix xTile That The Mouse is Over
` Return The xTile That the Mouse Is Over
` Else Returns -1 if NOT Over a Matrix Tile
`
` By Michael Mihalyfi
` MSon648@Hotmail.Com
` Selector Object
On = 999
Make Object Sphere On,2
Hide Object On
` Get Required Values
xSegSize# = Width# / xSeg
ySegSize# = Lenth# / ySeg
xMatrix# = Matrix Position X(Mn)
zMatrix# = Matrix Position Z(Mn)
SelectorHalfWidth = 10
` Loop For All Tiles
For y = 0 To ySeg
For x = 0 To xSeg
` Position the Object At Matrix Tile Point
Position Object On,x * xSegSize# + xMatrix#,Get Matrix Height(Mn,x,y),y * ySegSize# + zMatrix#
` Is the Mouse Over the Matrix Tile?
Mx = MouseX()
Ox = Object Screen X(On)
If Ox > Mx - SelectorHalfWidth And Ox < Mx + SelectorHalfWidth
My = MouseY()
Oy = Object Screen Y(On)
If Oy > My - SelectorHalfWidth And Oy < My + SelectorHalfWidth
` Update Now
Delete Object On
ExitFunction x
EndIf : EndIf
Next x : Next y
` CleanUp is Not Over Any Tile
Delete Object On
EndFunction -1
Function GetMatrixMouseY(Mn,Width#,Lenth#,xSeg,ySeg)
` Returns the Matrix yTile That The Mouse is Over
` Return The yTile That the Mouse Is Over
` Else Returns -1 if NOT Over a Matrix Tile
`
` By Michael Mihalyfi
` MSon648@Hotmail.Com
` Selector Object
On = 999
Make Object Sphere On,2
Hide Object On
` Get Required Values
xSegSize# = Width# / xSeg
ySegSize# = Lenth# / ySeg
xMatrix# = Matrix Position X(Mn)
zMatrix# = Matrix Position Z(Mn)
SelectorHalfWidth = 10
` Loop For All Tiles
For y = 0 To ySeg
For x = 0 To xSeg
` Position the Object At Matrix Tile Point
Position Object On,x * xSegSize# + xMatrix#,Get Matrix Height(Mn,x,y),y * ySegSize# + zMatrix#
` Is the Mouse Over the Matrix Tile?
Mx = MouseX()
Ox = Object Screen X(On)
If Ox > Mx - SelectorHalfWidth And Ox < Mx + SelectorHalfWidth
My = MouseY()
Oy = Object Screen Y(On)
If Oy > My - SelectorHalfWidth And Oy < My + SelectorHalfWidth
` Update Now
Delete Object On
ExitFunction y
EndIf : EndIf
Next x : Next y
` CleanUp is Not Over Any Tile
Delete Object On
EndFunction -1
Function Smallest(Value1#,Value2#)
If Value1# < Value2# Then ExitFunction Value1#
EndFunction Value2#
Function Largest(Value1#,Value2#)
If Value1# > Value2# Then ExitFunction Value1#
EndFunction Value2#
Function ClickText(x,y,String$,c1,c2)
If MouseX() > x
If MouseY() > y
If MouseX() < x + Text Width(String$)
If MouseY() < y + Text Height(String$)
Rv = 1 : EndIf : EndIf : EndIf : EndIf
If Rv = 0 Then Ink c2,0 Else Ink c1,0
Box x,y,x + Text Width(String$),y + Text Height(String$)
If Rv = 0 Then Ink c1,0 Else Ink c2,0
Text x,y,String$
EndFunction Rv
Function MenuWidth(ItemStart,ItemEnd)
` Get the Width of the Menu
For n = ItemStart To ItemEnd
If Text Width(Menu$(n)) > Width Then Width = Text Width(Menu$(n))
Next n
EndFunction Width
Function MenuHeight(ItemStart,ItemEnd)
` Get the Height of the Menu
Height = ItemEnd - ItemStart * Text Height("Test")
EndFunction Height
Function UpdateMenu(ItemStart,ItemEnd,x,y,LoopValue)
Width = MenuWidth(ItemStart,ItemEnd)
Height = MenuHeight(ItemStart,ItemEnd)
` Wrap Menu to the Screen
If x < 0 Then x = 0
If y < 0 Then y = 0
If x + Width > Screen Width() Then x = Screen Width() - Width
If y + Height > Screen Height() Then y = Screen Height() - Height
yBackup = y
Do:y = yBackup
For n = ItemStart To ItemEnd
Rv = 0
String$ = Menu$(n)
Height = Text Height(String$)
Click = MouseClick()
` Spacer
If Mid$(String$,1) = "-" Then Skip = 1 : Click = 0 : Else Skip = 0
` Selected or Over?
If MouseX() > x And MouseY() > y And MouseX() < x + Width And MouseY() < y + Height
If Click = 1 Then WaitForMouseClickValue(0) : ExitFunction n
Rv = 1
If Skip = 1 Then Rv = 0
EndIf
If Rv = 0 Then Ink MenuBackColor,0 Else Ink MenuForeColor,0
Box x,y,x + Width,y + Height
If Rv = 0 Then Ink MenuForeColor,0 Else Ink MenuBackColor,0
Text x,y,String$
Inc y,Height
Next n
If Click = 1 Then WaitForMouseClickValue(0) : ExitFunction 0
If LoopValue = 0 Then ExitFunction 0
Sync : Loop
EndFunction -1
Function WaitForMouseClickValue(n)
Repeat
Until MouseClick() = n
EndFunction
MenuControls: If n => 1 And n <= 7 Then Tool = n
If n = 9
n = UpdateMenu(13,16,MouseX() + 10,MouseY() + 10,1)
If n = 14 Then Set Matrix WireFrame On 1
If n = 15 Then Set Matrix WireFrame Off 1
EndIf
If n = 10
n = UpdateMenu(13,16,MouseX() + 10,MouseY() + 10,1)
If n = 14 Then Ghost Matrix On 1
If n = 15 Then Ghost Matrix Off 1
EndIf
If n = 12
n = UpdateMenu(17,20,MouseX() + 10,MouseY() + 10,1)
If n = 18 Then End
EndIf : Return
Edit:
Matrix Shaping Commands...
Use left click to select the Area, and then MouseZ to raise or lower, then right click to exit tool
Matrix Tile Commands
Use left click to select area and then left click to go to the next tile number, and right click to exit tool