ça ferai un labyrhinte donc les murs changerai de place
en fonction de l'heure

on se promènerai dedans

Dobro a écrit :c'est curieux , moi ça ne me pose aucun soucis !![]()
je lis instantanément l'heure ...
auriez vous des problemes de vue ?
Code : Tout sélectionner
;LoadSprite(#block,"E:\Dobro\PureBasic\dobro\Dobro_creation\montre\blockA.png",#PB_Sprite_Texture)
Code : Tout sélectionner
CreateSprite(#block,16,16, #PB_Sprite_Texture)
StartDrawing(SpriteOutput(#block))
LineXY(0,0,16,16,#green)
StopDrawing()
Code : Tout sélectionner
;
Enumeration
#window
#imgad
#im0
#im1
#im2
#im3
#font1
#timer
EndEnumeration
;
Global Dim heure.i(25,18)
Global Dim minut.i(25,18)
Global flagh.i,flagm.i
;
Procedure DrawTime()
Protected x.i,y.i
CreateImage(#im3,40,20)
StartDrawing(ImageOutput(#im3))
DrawingFont(FontID(#font1))
If Hour(Date()) <10
DrawText(1,1,"0"+Str(Hour(Date())),#Green)
Else
DrawText(1,1,Str(Hour(Date())),#Green)
EndIf
If Minute(Date())<10
DrawText(20,1,"0"+Str(Minute(Date())),#Green)
Else
DrawText(20,1,Str(Minute(Date())),#Green)
EndIf
For y=0 To 16
For x=1 To 17
heure(x,y)=Point(x,y)
minut(x,y)=Point(x+19,y)
Next x
Next y
StopDrawing()
;
FreeImage(#im3)
EndProcedure
Procedure drawmotif()
Protected x.i,y.i
;
StartDrawing(ImageOutput(#im0))
Box(0,0,270,350,#Black)
;
For y=0 To 12
For x=2 To 18
If heure(x,y)>0
DrawImage(ImageID(#im2), (x*16)-30,(y*16)-30)
Else
If flagh =0
DrawImage(ImageID(#im1),(x*16)-30,(y*16)-30)
EndIf
EndIf
Next x
Next y
;
For y=2 To 12
For x=2 To 18
If minut(x,y)>0
DrawImage(ImageID(#im2),(x*16)-31,(y*16)+145)
Else
If flagm=0
DrawImage(ImageID(#im1),(x*16)-31,(y*16)+145)
EndIf
EndIf
Next x
Next y
;
StopDrawing()
;
SetGadgetState(#imgad,ImageID(#im0))
EndProcedure
;
;-debut
;
OpenWindow(#window, 0, 0, 270, 350, "TimeMotif", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
ImageGadget(#imgad,0,0,270,350,0)
;
CreateImage(#im1,16,16);,32|#PB_Image_Transparent) ; \
StartDrawing(ImageOutput(#im1))
Line(0,0,16,16,#Green)
Line(1,0,16,16,#Green)
Line(0,1,16,16,#Green)
StopDrawing()
;
CreateImage(#im2,16,16);,32|#PB_Image_Transparent) ; /
StartDrawing(ImageOutput(#im2))
LineXY(0,16,16,0,#Green)
LineXY(1,16,15,0,#Green)
LineXY(0,15,16,1,#Green)
StopDrawing()
;
CreateImage(#im0,270,350)
;
LoadFont(#font1, "Courier", 10,#PB_Font_Bold)
;
Drawtime()
drawmotif()
;
AddWindowTimer(#window,#timer,1000)
;
Repeat
Event = WaitWindowEvent()
Select event
Case #PB_Event_Gadget
If EventGadget()=#imgad
If EventType()=#PB_EventType_LeftClick
flagh= (Not flagh)
flagm= (Not flagm)
drawmotif()
EndIf
EndIf
Case #PB_Event_Timer
If EventTimer() = #timer
drawtime()
drawmotif()
EndIf
EndSelect
Until Event = #PB_Event_CloseWindow
Merci, je trouve le résultat plus "lisible" avec ce code.zaphod a écrit :Salut tous,
une adaption du code de dobro, sans sprites :
Code : Tout sélectionner
; Enumeration #window #imgad #im0 #im1 #im2 #im3 #font1 #timer EndEnumeration ; Global Dim heure.i(25,18) Global Dim minut.i(25,18) Global flagh.i,flagm.i ; Procedure DrawTime() Protected x.i,y.i CreateImage(#im3,40,20) StartDrawing(ImageOutput(#im3)) DrawingFont(FontID(#font1)) If Hour(Date()) <10 DrawText(1,1,"0"+Str(Hour(Date())),#Green) Else DrawText(1,1,Str(Hour(Date())),#Green) EndIf If Minute(Date())<10 DrawText(20,1,"0"+Str(Minute(Date())),#Green) Else DrawText(20,1,Str(Minute(Date())),#Green) EndIf For y=0 To 16 For x=1 To 17 heure(x,y)=Point(x,y) minut(x,y)=Point(x+19,y) Next x Next y StopDrawing() ; FreeImage(#im3) EndProcedure Procedure drawmotif() Protected x.i,y.i ; StartDrawing(ImageOutput(#im0)) Box(0,0,270,350,#Black) ; For y=0 To 12 For x=2 To 18 If heure(x,y)>0 DrawImage(ImageID(#im2), (x*16)-30,(y*16)-30) Else If flagh =0 DrawImage(ImageID(#im1),(x*16)-30,(y*16)-30) EndIf EndIf Next x Next y ; For y=2 To 12 For x=2 To 18 If minut(x,y)>0 DrawImage(ImageID(#im2),(x*16)-31,(y*16)+145) Else If flagm=0 DrawImage(ImageID(#im1),(x*16)-31,(y*16)+145) EndIf EndIf Next x Next y ; StopDrawing() ; SetGadgetState(#imgad,ImageID(#im0)) EndProcedure ; ;-debut ; OpenWindow(#window, 0, 0, 270, 350, "TimeMotif", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered) ImageGadget(#imgad,0,0,270,350,0) ; CreateImage(#im1,16,16);,32|#PB_Image_Transparent) ; \ StartDrawing(ImageOutput(#im1)) Line(0,0,16,16,#Green) Line(1,0,16,16,#Green) Line(0,1,16,16,#Green) StopDrawing() ; CreateImage(#im2,16,16);,32|#PB_Image_Transparent) ; / StartDrawing(ImageOutput(#im2)) LineXY(0,16,16,0,#Green) LineXY(1,16,15,0,#Green) LineXY(0,15,16,1,#Green) StopDrawing() ; CreateImage(#im0,270,350) ; LoadFont(#font1, "Courier", 10,#PB_Font_Bold) ; Drawtime() drawmotif() ; AddWindowTimer(#window,#timer,1000) ; Repeat Event = WaitWindowEvent() Select event Case #PB_Event_Gadget If EventGadget()=#imgad If EventType()=#PB_EventType_LeftClick flagh= (Not flagh) flagm= (Not flagm) drawmotif() EndIf EndIf Case #PB_Event_Timer If EventTimer() = #timer drawtime() drawmotif() EndIf EndSelect Until Event = #PB_Event_CloseWindow