a partir de l'excellent tuto de MicroWeb sur la création d'un fond étoilé jai crée ce petit logiciel qui permet en chargement une image de crée un fond étoilé mon petit probleme c'est qu'aucune étoile s'affichent . je pense qu'il me manque à affiché l'image mais là j'ai pas trouver car je suis embêter avec FichierImage$ .
https://www.dropbox.com/s/4uww16w1ox40g ... y.zip?dl=0
Code : Tout sélectionner
;***********************************************************************
; STARS SKY v 1.0
;Code écrit par Jean-Bernard sur une base de code crée par MicroWeb
;***********************************************************************
;----- Initialisation -----
EnableExplicit
InitSprite()
InitKeyboard()
UseJPEGImageDecoder()
UsePNGImageDecoder()
;----- Constantes -----
Enumeration Interfaces
#Form_Main
#Frame_0
#Texte_Logo
#Font_Logo
#Font_Texte0
#Texte_Charge
#string_Charge
#bouton_Charge
#Bouton_Creation
#Bouton_Propos
#Bouton_Quitter
EndEnumeration
;--------------------------
Enumeration Stars
#Form_Background
#Stars
EndEnumeration
;----- Globale variables -----
Global Font_Logo,Font_text0,Quitter.b=#False, FichierImage$
Global WinWidth=800,WinHeight=600
;----- Chargement des polices -----
Font_text0= LoadFont(#Font_Texte0,"arial",11,#PB_Font_Bold)
Font_Logo=LoadFont(#Font_logo,"arial",40,#PB_Font_Bold)
;----- Les Procédures ----
Procedure Charge_Image()
Protected Filtre$
FichierImage$=OpenFileRequester("Charge une image de base ", "",Filtre$ , 0)
Filtre$="PNG|*.png|JPG|*.jpg|"
If LoadImage(#FichierImage,FichierImage$)
Else
MessageRequester("Erreur!! ", "Impossible de charger une image " ,#PB_MessageRequester_Ok )
EndIf
SetGadgetText(#string_Charge,GetFilePart(FichierImage$))
EndProcedure
;--------------------------
Procedure OpenMain()
OpenWindow(#Form_Main,0,0,500,400,"STARS SKY V1.0",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget)
FrameGadget(#Frame_0, 10, 10, 480, 380, "", #PB_Frame_Flat)
TextGadget(#Texte_Logo,50,20,400,55,"STARS SKY",#PB_Text_Center)
SetGadgetFont(#Texte_Logo,Font_Logo)
SetGadgetColor(#Texte_Logo,#PB_Gadget_FrontColor ,RGB(32,143,255))
TextGadget(#Texte_Charge,150,110,200,20,"Choisir une image de base :",#PB_Text_Center)
SetGadgetFont(#Texte_Charge,Font_text0)
ButtonGadget(#Bouton_Charge,20,145,210,30,"Charge une image de base ")
SetGadgetFont(#bouton_Charge,Font_text0)
StringGadget(#string_Charge,250,150,200,20," ", #PB_String_UpperCase|#PB_String_ReadOnly )
SetGadgetFont(#string_Charge,Font_text0)
ButtonGadget(#Bouton_Creation,150,220,210,30,"Création du Background ")
SetGadgetFont(#Bouton_Creation,Font_text0)
ButtonGadget(#Bouton_Propos,150,270,210,30,"A Propos de ...")
SetGadgetFont(#Bouton_Propos,Font_text0)
ButtonGadget(#Bouton_Quitter,150,320,210,30,"Quitter")
SetGadgetFont(#Bouton_Quitter,Font_text0)
EndProcedure
;--------------------------
Procedure Affiche_sky()
Protected Nombre_Stars=400,MinSize=12,MaxSize=24,X,Y,N,Brush,mySize,XX,Pos_x=0,Pos_y=0
OpenWindow(#Form_Background,0,0,WinWidth,WinHeight,"",#PB_Window_SystemMenu|#PB_Window_Maximize)
WinWidth=WindowWidth(#Form_Background)
WinHeight=WindowHeight(#Form_Background)
OpenWindowedScreen(WindowID(#Form_Background),0,0,WinWidth,WinHeight)
CreateSprite(#Stars,WinWidth,WinHeight)
StartDrawing(SpriteOutput(#Stars))
For N=1 To Nombre_Stars
Brush=Random(4,1)
mySize=Random(MaxSize,MinSize)
X=Random(WinWidth-20,20)
Y=Random(WinHeight-20,20)
XX= (Brush-1)*64
GrabImage(#FichierImage,1,XX,0,64,64)
DrawImage(ImageID(1),X,Y,mySize,mySize)
Next
StopDrawing()
FreeImage(#FichierImage)
DisplaySprite( #Stars,Pos_x,Pos_y)
ClearScreen(RGB(0,0,0))
FlipBuffers()
EndProcedure
;----- Boucle principale du programme ----
OpenMain()
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case #Bouton_Charge : Charge_Image()
Case #Bouton_Creation : Affiche_sky()
Case #Bouton_Propos : MessageRequester("A propos de Stars Sky v 1.0 ", " Crée par jean-Bernard 2015 " ,#PB_MessageRequester_Ok )
Case #Bouton_Quitter:Quitter=#True
EndSelect
Case #PB_Event_CloseWindow
Quitter=#True
EndSelect
Until Quitter
End