Anyway I am using Screen in Window which has been improved greatly by Trand, SRod and Demivac and quite a few others!
Problem is on the edge of the screen... mouse flickers badly. In my game it flickers badly AND decides to move up to the upper RIGHT corner... in this example it just flickers...
not quite the same but close
Code: Select all
; Rook Zimbabwe
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
MessageRequester("Error", "DirectX 7+ Fail!", 0)
End
EndIf
Enumeration
#Window_0
EndEnumeration
Enumeration
#Button_0
#Frame3D_0
EndEnumeration
#TILE = 1
#MOUSETILE = 2
#MOUSE = 0
#LeftOffset = 10
#TopOffset = 15
#MouseScreenW = 128
#MouseScreenH = 128
#ScreenW = 192
#ScreenH = 192
#MaxWIDE = 3
#MaxHIGH = 3
Structure VisualDesignerGadgets
Gadget.l
EventFunction.l
EndStructure
DataSection
Image1:
IncludeBinary "mouse01.bmp"
Image2:
IncludeBinary "tile01.bmp"
Image3:
IncludeBinary "board01.bmp"
EndDataSection
Global NewList EventProcedures.VisualDesignerGadgets()
Global Dim LAYER(2,2) ; a 3X3 array
Global ax ; hold actual mousex in screen
Global ay
Global SPX = 64; size of sprites
Global SPY = 64
Global OLDX ; last position in array of changed tile
Global OLDY
;-
;-
Procedure DoScreenDisplay(inscreen)
; Display your screen stuff
; LAYER(OLDX,OLDY) = #TILE
If inscreen
ExamineMouse()
ax = MouseX() / SPX ;these show coordinates of tile in map
ay = MouseY() / SPY
LAYER(ax,ay) = #MOUSETILE
OLDX = ax
OLDY = ay
EndIf
EndProcedure
Procedure RefillBoard()
For x = 0 To 2
For y = 0 To 2
LAYER(x,y) = #TILE ; set LAYER to background tiles image
Next
Next
EndProcedure
;-
Procedure Button_0_Event(Window, Event, Gadget, Type)
Debug "#Button_0"
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_0()
If OpenWindow(#Window_0, 0, 0, 400, 280, "TurboTURDo", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
Frame3DGadget(#Frame3D_0, 6, 0, 202, 213, "TIC TAC TURDO")
ButtonGadget(#Button_0, 275, 15, 120, 35, "THIS IS A BUTTON")
RegisterGadgetEvent(#Button_0, @Button_0_Event())
EndIf
EndIf
EndProcedure
Open_Window_0()
OpenWindowedScreen(WindowID(#Window_0),10,15,192,192,0,0,0)
CatchSprite(#MOUSE, ?Image1,#PB_Sprite_Memory)
CatchSprite(#TILE, ?Image2,0)
CatchSprite(#MOUSETILE, ?image3,0)
RefillBoard()
Repeat
ClearScreen(0)
UpdateWindow_(WindowID(#Window_0))
If inscreen
If MouseX() > #MouseScreenH+62 Or MouseY() > #MouseScreenW+62 Or MouseX() < 1 Or MouseY() < 1
inscreen = #False
ReleaseMouse(1)
EndIf
Else
Event = WaitWindowEvent()
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 < #ScreenH+#TopOffset And mx > #TopOffset And my > #LeftOffset And my < #LeftOffset+#ScreenW
ReleaseMouse(0)
MouseLocate(mx-#LeftOffset,my-#TopOffset)
inscreen = #True
EndIf
EndIf
DoScreenDisplay(inscreen)
YYY = 0
For y = 0 To 2
XXX = 0
For x = 0 To 2
DisplaySprite(LAYER(x,y),XXX , YYY)
XXX + SPX
Next
YYY + SPY
Next
ExamineMouse()
DisplayTransparentSprite(#MOUSE,MouseX(),MouseY())
FlipBuffers()
refillboard()
Until Event = #PB_Event_CloseWindow
End