Canvas gadget hide button gadget.
Posted: Wed Apr 08, 2020 7:31 pm
I have the following problem.
I make a windows, make a canvas gadget in it. And over that the buttongadet.
The que to make this is important. Because the button must be last made it, to design over the canvas.
In this code canvas is 0 and button is 1
When i designed it with the form designer of PB it is showing it on the right way. When i make my own code its not working the buttons are behind the Canvas.
This is the test code:
The images is not important here. So you can use anything you like.
When the program is running there are two things that is notice on me:
1. The little maze created is flikkering
2. The buttons are behind the canvas
What is wrong in the code or is this a bug af PB.
I did created a code with the Form designer but the result is the same.
I make a windows, make a canvas gadget in it. And over that the buttongadet.
The que to make this is important. Because the button must be last made it, to design over the canvas.
Code: Select all
CanvasGadget(0,0,0,640,480)
Buttongadget(1,20,480,80,20,"")
When i designed it with the form designer of PB it is showing it on the right way. When i make my own code its not working the buttons are behind the Canvas.
This is the test code:
Code: Select all
; Dungeon Master Take Off
; By Lee Page, redesigned by Bart Fernhout
; TeraBit Software
;First get the desktop demensions
Global DesktopID.i = ExamineDesktops()
Global xps = (DesktopWidth(0)-640)/2
Global yps = (DesktopHeight(0)-480)/2
Global Event.i
Global color.i
InitSprite()
InitMouse()
InitKeyboard()
InitSound()
UsePNGImageDecoder()
OpenWindow(0,xps,yps,640,500,"Dungeon Novice",#PB_Window_SystemMenu) ;The window
CanvasGadget(0,0,0,640,480) ;The canvas
ButtonGadget(1,20,480,80,20,"Turn Left") ;first button
ButtonGadget(2,540,480,80,20,"Turn Right") ; etc...
ButtonGadget(3,280,480,80,20,"Forward")
Global posx,posy
Global Dim Maps(20,20)
Global Dim hold(1000)
For y=1 To 20
Read.s a$
For t=1 To 20
If Mid(a$,t,1)="*"
Maps(t,y)=1
EndIf
Next
Next
posx.i = 4
posy.i = 5
Global Mask.i = RGB(255,0,255)
Global Floor1.i = LoadImage(#PB_Any,"Floor1.png")
Global Floor2.i = LoadImage(#PB_Any,"Floor2.png")
Global L1.i = LoadImage(#PB_Any,"0.png")
Global R1.i = LoadImage(#PB_Any,"1.png")
Global L2.i = LoadImage(#PB_Any,"2.png")
Global M2.i = LoadImage(#PB_Any,"3.png")
Global R2.i = LoadImage(#PB_Any,"4.png")
Global L3.i = LoadImage(#PB_Any,"6.png")
Global M3.i = LoadImage(#PB_Any,"7.png")
Global R3.i = LoadImage(#PB_Any,"8.png")
Global LL4.i = LoadImage(#PB_Any,"10.png")
Global L4.i = LoadImage(#PB_Any,"11.png")
Global M4 = LoadImage(#PB_Any,"12.png")
Global R4 = LoadImage(#PB_Any,"13.png")
Global RR4 = LoadImage(#PB_Any,"14.png")
Global LL3 = LoadImage(#PB_Any,"5.png")
Global RR3 = LoadImage(#PB_Any,"9.png")
direction =1
Procedure minimap()
StartDrawing(CanvasOutput(0))
For y=3 To 18
For x=3 To 18
Color = RGB(255*Maps(x,y),255*Maps(x,y),255*Maps(x,y))
If x=posx And y = posy
Color = RGB(0,255,0)
Box(x*5+484,y*5,5,5,color)
EndIf
If Maps(x,y)<>0
Box(x*5+484,y*5,5,5,color)
EndIf
Next
Next
StopDrawing()
EndProcedure
Repeat
;Do event on move
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
End
Case #PB_Event_Gadget
Select EventGadget()
Case 1
cnt=0
For dw = 1 To 20
For ac = 1 To 20
hold(cnt)=Maps(ac,dw)
cnt=cnt+1
Next
Next
cnt=0
For ac = 1 To 20
For dw = 1 To 20
Maps(21-ac,dw)=hold(cnt)
cnt=cnt+1
Next
Next
temp=posx
posx=21-posy
posy=temp
blk = blk ! 1
Case 2
cnt=0
For dw = 1 To 20
For ac = 1 To 20
hold(cnt)=Maps(ac,dw)
cnt=cnt+1
Next
Next
cnt=0
For ac = 1 To 20
For dw = 1 To 20
Maps(ac,21-dw)=hold(cnt)
cnt=cnt+1
Next
Next
blk = blk ! 1
temp=21-posx
posx=posy
posy=temp
Case 3
If Maps(posx,posy-1)<>1
posy=posy-1
Else
blk = blk ! 1
EndIf
EndSelect
EndSelect
StartDrawing(CanvasOutput(0))
DrawingMode(#PB_2DDrawing_AlphaBlend)
If blk = 0
DrawImage(ImageID(floor1),0,0)
Else
DrawImage(ImageID(floor2),0,0)
EndIf
If Maps(posx-2,posy-3)=1
DrawImage(ImageID(LL4),0,92)
EndIf
If Maps(posx+2,posy-3)=1
DrawImage(ImageID(RR4),559,92)
EndIf
If Maps(posx-1,posy-3)=1
DrawImage(ImageID(L4),17,92)
EndIf
If Maps(posx+1,posy-3)=1
DrawImage(ImageID(R4),400,92)
EndIf
If Maps(posx,posy-3)=1
DrawImage(ImageID(M4),219,92)
EndIf
If Maps(posx+2,posy-2)=1
DrawImage(ImageID(RR3),618,88)
EndIf
If Maps(posx-2,posy-2)=1
DrawImage(ImageID(LL3),0,87)
EndIf
If Maps(posx+1,posy-2)=1
DrawImage(ImageID(R3),420,62)
EndIf
If Maps(posx-1,posy-2)=1
DrawImage(ImageID(L3),0,62)
EndIf
If Maps(posx,posy-2)=1
DrawImage(ImageID(M3),188,62)
EndIf
If Maps(posx+1,posy-1)=1
DrawImage(ImageID(r2),452,6)
EndIf
If Maps(posx-1,posy-1)=1
DrawImage(ImageID(L2),1,7)
EndIf
If Maps(posx-1,posy)=1
DrawImage(ImageID(L1),2,0)
EndIf
If Maps(posx+1,posy)=1
DrawImage(ImageID(R1),515,-2)
EndIf
If Maps(posx,posy-1)=1
DrawImage(ImageID(m2),121,7)
EndIf
StopDrawing()
minimap()
ForEver
DataSection
Data.s "********************"
Data.s "********************"
Data.s "********************"
Data.s "*** * ***"
Data.s "*** **** ******* ***"
Data.s "*** * * ***"
Data.s "*** ** *** *********"
Data.s "*** * * * ***"
Data.s "*** ******* **** ***"
Data.s "*** * ***"
Data.s "*** * ****** *** ***"
Data.s "*** * * * * ***"
Data.s "*** ** *********"
Data.s "*** ****** * * ***"
Data.s "*** * * ***"
Data.s "*** ************ ***"
Data.s "*** ***"
Data.s "********************"
Data.s "********************"
Data.s "********************"
EndDataSection
When the program is running there are two things that is notice on me:
1. The little maze created is flikkering
2. The buttons are behind the canvas
What is wrong in the code or is this a bug af PB.
I did created a code with the Form designer but the result is the same.