Pour contrer le problème des fausses détections de la part des antivirus, j'étais parti, comme la fait Denis, pour ajouter du code afin de ne plus avoir de soucis.
Sauf que j'ajoutais uniquement qlq lignes en plus ce qui n'était pas forcément suffisant.
J'ai donc codé quelques choses de plus gros et de plus rigolo, avec des fonctions PB simple et standard pour que l'exe ne charge pas de librairie supplémentaire.
Le but étant d'insérer ce code dans mes petits programmes sujet au fausses détections.
Le code, bien entendu, ne faisant rien car il est bloqué par une condition IF qui empêche de le lancer.
Et comme par hasard, je n'ai plus de problème de fausses détections depuis que j'ai finis mon code. je n'ai visiblement même pas besoin de l'utiliser. bref, du travail pour rien
Enfin, c'est rigolo quand même, ce bout de code.
Donc il s'agit d'une procedure nommé Virus()
Si on met Virus(1), le code s'exécute
Si on met Virus(0), ça ne fais rien
Et le code est un Pong sous Window, LSI Versus AntiVirus
Bien entendu, LSI gagne toujours (c'est fais pour hou le tricheur)
Pour l'exemple, je lance donc avec virus(1)
Pour quitter, il faut cliquer sur le score.
Code : Tout sélectionner
Procedure Virus_Gestion()
Protected Police, Texte.s, x, y, Couleur
Protected Dim Pivot(24 - 1, 128 - 1)
Protected Image_Raquette_D, Image_Raquette_G, Image_Balle, Image_Score, Image
Protected Fenetre_Raquette_D, Fenetre_Raquette_G, Fenetre_Balle, Fenetre_Score
Protected Raquette_D_Y.f, Raquette_G_Y.f, Balle_X.f, Balle_Y.f, Balle_Dx.f, Balle_Dy.f, Balle_Vitesse.f, Balle_X_Estimation.f, Balle_Y_Estimation.f, Balle_Dy_Estimation.f
Protected Raquette_G_Retour, Raquette_D_Retour, Raquette_G_Y_Estimation.f, Raquette_D_Y_Estimation.f
Protected Score_G, Score_D, Score_Affiche, Score_Gadget, Depart
Protected Ecran_X, Ecran_Y, Ecran_H, Ecran_L
Police = LoadFont(#PB_Any, "Verdana", 10, #PB_Font_HighQuality)
If Police
Image = CreateImage(#PB_Any, 128, 24, 24)
Image_Score = CreateImage(#PB_Any, 128, 24, 24)
Image_Raquette_D = CreateImage(#PB_Any, 24, 128, 24)
Image_Raquette_G = CreateImage(#PB_Any, 24, 128, 24)
Image_Balle = CreateImage(#PB_Any, 8, 8, 24)
If Image And Image_Raquette_D And Image_Raquette_G And Image_Balle
If ExamineDesktops()
; Analyse de l'écran
Ecran_X = DesktopX(0)
Ecran_Y = DesktopY(0)
Ecran_L = DesktopWidth(0)
Ecran_H = DesktopHeight(0)
; Position par défaut des éléments
Raquette_G_Y = Ecran_Y + (Ecran_H - 128) / 2
Raquette_D_Y = Ecran_Y + (Ecran_H - 128) / 2
Balle_X = Ecran_X + 24 + 1
Balle_Y = Ecran_Y + (Ecran_H - 8) / 2
Balle_Dx = -1
Balle_Dy = 0
Balle_Vitesse = 1
Depart = 1 * 1000 / 20
; Fenêtres
Fenetre_Score = OpenWindow(#PB_Any, Ecran_X + (Ecran_L - 128) / 2, Ecran_Y, 128, 24, "LSI VS AntiVirus", #PB_Window_BorderLess)
If Fenetre_Score
Fenetre_Raquette_G = OpenWindow(#PB_Any, Ecran_X, Raquette_G_Y, 24, 128, "LSI", #PB_Window_BorderLess, WindowID(Fenetre_Score))
Fenetre_Raquette_D = OpenWindow(#PB_Any, Ecran_X + Ecran_L - 24, Raquette_D_Y, 24, 128, "AntiVirus", #PB_Window_BorderLess, WindowID(Fenetre_Score))
Fenetre_Balle = OpenWindow(#PB_Any, Balle_X, Balle_Y, 8, 8, "balle", #PB_Window_BorderLess, WindowID(Fenetre_Score))
If Fenetre_Raquette_G And Fenetre_Raquette_D And Fenetre_Balle
StickyWindow(Fenetre_Score, 1)
StickyWindow(Fenetre_Balle, 1)
StickyWindow(Fenetre_Raquette_D, 1)
StickyWindow(Fenetre_Raquette_G, 1)
; Dessin de la raquette gauche
StartDrawing(ImageOutput(Image))
Box(0, 0, 128, 24, $FFFFFF)
DrawingMode(#PB_2DDrawing_Outlined | #PB_2DDrawing_Transparent)
Box(0, 0, 128, 24, 0)
DrawingFont(FontID(Police))
Texte = "LSI"
DrawText((128 - TextWidth(Texte)) / 2,(24 - TextHeight(Texte)) / 2, Texte, 0)
; Enregistre l'image pivotée
For x = 0 To 128 - 1
For y = 0 To 24 - 1
Couleur = Point(x, y)
Pivot(y, x) = Couleur
Next
Next
StopDrawing()
StartDrawing(ImageOutput(Image_Raquette_G))
For x = 0 To 24 - 1
For y = 0 To 128 - 1
Couleur = Pivot(x, y)
Plot(x, 128 - 1 - y, Couleur)
Next
Next
StopDrawing()
UseGadgetList(WindowID(Fenetre_Raquette_G))
ImageGadget(#PB_Any, 0, 0, 24, 128, ImageID(Image_Raquette_G))
; Dessin de la raquette droite
StartDrawing(ImageOutput(Image))
Box(0, 0, 128, 24, $FFFFFF)
DrawingMode(#PB_2DDrawing_Outlined | #PB_2DDrawing_Transparent)
Box(0, 0, 128, 24, 0)
DrawingFont(FontID(Police))
Texte = "AntiVirus"
DrawText((128 - TextWidth(Texte)) / 2,(24 - TextHeight(Texte)) / 2, Texte, 0)
; Enregistre l'image pivotée
For x = 0 To 128 - 1
For y = 0 To 24 - 1
Couleur = Point(x, y)
Pivot(24 - 1 - y, x) = Couleur
Next
Next
StopDrawing()
StartDrawing(ImageOutput(Image_Raquette_D))
For x = 0 To 24 - 1
For y = 0 To 128 - 1
Couleur = Pivot(x, y)
Plot(x, y, Couleur)
Next
Next
StopDrawing()
UseGadgetList(WindowID(Fenetre_Raquette_D))
ImageGadget(#PB_Any, 0, 0, 24, 128, ImageID(Image_Raquette_D))
; Dessin de la balle
StartDrawing(ImageOutput(Image_Balle))
Box(0, 0, 8, 8, $00FFFF)
DrawingMode(#PB_2DDrawing_Outlined)
Box(0, 0, 8, 8, 0)
StopDrawing()
UseGadgetList(WindowID(Fenetre_Balle))
ImageGadget(#PB_Any, 0, 0, 8, 8, ImageID(Image_Balle))
UseGadgetList(WindowID(Fenetre_Score))
Score_Gadget = ImageGadget(#PB_Any, 0, 0, 8, 8, ImageID(Image_Score))
Score_Affiche = 1
AddWindowTimer(Fenetre_Score, 999, 20)
Repeat
Event = WaitWindowEvent()
If EventWindow() = Fenetre_Score
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case Score_Gadget
Select EventType()
Case #PB_EventType_LeftClick
If MessageRequester("LSI VS AntiVirus", "Souhaitez-vous quitter cette partie passionnante ?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
Quitter = 1
EndIf
EndSelect
EndSelect
Case #PB_Event_Timer
Select EventTimer()
Case 999
; Animation
If Depart = 0
; Position de la balle
Balle_X + Balle_Dx * Balle_Vitesse
Balle_Y + Balle_Dy * Balle_Vitesse
; Position de la raquette gauche
If Balle_Dx < 0
Balle_X_Estimation = Balle_X
Balle_Y_Estimation = Balle_Y
Balle_Dy_Estimation = Balle_Dy
x = Balle_X_Estimation
y = Balle_Y_Estimation
Repeat
Balle_X_Estimation + Balle_Dx * Balle_Vitesse
Balle_Y_Estimation + Balle_Dy_Estimation * Balle_Vitesse
If (Balle_Y_Estimation <= Ecran_Y And Balle_Dy_Estimation < 0) Or (Balle_Y_Estimation >= Ecran_Y + Ecran_H - 8 And Balle_Dy_Estimation > 0)
x = Abs(Balle_Y_Estimation - y) + Abs(Balle_X_Estimation - x)
Balle_Dy_Estimation * -1
Balle_X_Estimation + (Random(x) - x / 2) * 0.5
x = Balle_X_Estimation
y = Balle_Y_Estimation
EndIf
Until Balle_X_Estimation <= Ecran_X
x = Abs(Balle_Y_Estimation - y) + Abs(Balle_X_Estimation - x)
Balle_Y_Estimation + (Random(x) - x / 2) * 0.5
Raquette_G_Y_Estimation * 0.98 + Balle_Y_Estimation * 0.02
Raquette_G_Retour = 0
Else
If Raquette_G_Retour <> 1
Raquette_G_Retour = 1
Raquette_G_Y_Estimation = Random(1000) / 500
Raquette_G_Y_Estimation = 2 * Raquette_G_Y_Estimation - Raquette_G_Y_Estimation * Raquette_G_Y_Estimation - 1
Raquette_G_Y_Estimation = Ecran_Y + Ecran_H / 2 + Ecran_H * Raquette_G_Y_Estimation / 2
EndIf
EndIf
If Raquette_G_Y_Estimation + 4 < Raquette_G_Y + 48
Raquette_G_Y - 8
ElseIf Raquette_G_Y_Estimation + 4 > Raquette_G_Y + 128 - 48
Raquette_G_Y + 8
EndIf
; Position de la raquette droite
If Balle_Dx > 0
Balle_X_Estimation = Balle_X
Balle_Y_Estimation = Balle_Y
Balle_Dy_Estimation = Balle_Dy
x = Balle_X_Estimation
y = Balle_Y_Estimation
Repeat
Balle_X_Estimation + Balle_Dx * Balle_Vitesse
Balle_Y_Estimation + Balle_Dy_Estimation * Balle_Vitesse
If (Balle_Y_Estimation <= Ecran_Y And Balle_Dy_Estimation < 0) Or (Balle_Y_Estimation >= Ecran_Y + Ecran_H - 8 And Balle_Dy_Estimation > 0)
x = Abs(Balle_Y_Estimation - y) + Abs(Balle_X_Estimation - x)
Balle_Dy_Estimation * -1
Balle_X_Estimation + (Random(x) - x / 2) * 3
x = Balle_X_Estimation
y = Balle_Y_Estimation
EndIf
Until Balle_X_Estimation >= Ecran_X + Ecran_L
x = Abs(Balle_Y_Estimation - y) + Abs(Balle_X_Estimation - x)
Balle_Y_Estimation + (Random(x) - x / 2) * 3
Raquette_D_Y_Estimation * 0.98 + Balle_Y_Estimation * 0.02
Raquette_D_Retour = 0
Else
If Raquette_D_Retour <> 1
Raquette_D_Retour = 1
Raquette_D_Y_Estimation = Random(1000) / 500
Raquette_D_Y_Estimation = 2 * Raquette_D_Y_Estimation - Raquette_D_Y_Estimation * Raquette_D_Y_Estimation - 1
Raquette_D_Y_Estimation = Ecran_Y + Ecran_H / 2 + Ecran_H * Raquette_D_Y_Estimation / 2
EndIf
EndIf
If Raquette_D_Y_Estimation + 4 < Raquette_D_Y + 24
Raquette_D_Y - 8
ElseIf Raquette_D_Y_Estimation + 4 > Raquette_D_Y + 128 - 24
Raquette_D_Y + 8
EndIf
; Rebond en haut et en bas
If (Balle_Y <= Ecran_Y And Balle_Dy < 0) Or (Balle_Y >= Ecran_Y + Ecran_H - 8 And Balle_Dy > 0)
Balle_Dy * -1
EndIf
; Rebond sur les raquettes
If (Balle_X <= Ecran_X + 24 And Balle_Y - 8 > Raquette_G_Y And Balle_Y + 8 < Raquette_G_Y + 128 - 1) Or (Balle_X >= Ecran_X + Ecran_L - 24 - 8 And Balle_Y - 8 > Raquette_D_Y And Balle_Y + 8 < Raquette_D_Y + 128 - 1)
; La balle tape sur une raquette
Balle_Vitesse = Random(1000) / 1000
Balle_Vitesse * Balle_Vitesse * 10 + 10
Balle_Dx = 0.25 + Random(1000) / 1000 * 0.75
If Balle_X > Ecran_X + 24
Balle_Dx * -1
EndIf
Balle_Dy = Sqr(1 - Balle_Dx * Balle_Dx)
If Random(1) = 1
Balle_Dy * -1
EndIf
EndIf
; Raté la balle coté gauche
If Balle_X < Ecran_X
Score_Affiche + 1
Score_D + 1
Raquette_G_Y = Ecran_Y + (Ecran_H - 128) / 2
Raquette_D_Y = Ecran_Y + (Ecran_H - 128) / 2
Balle_X = Ecran_X + Ecran_L - 24 - 8 - 1
Balle_Y = Ecran_Y + (Ecran_H - 8) / 2
Balle_Dx = 1
Balle_Dy = 0
Balle_Vitesse = 1
Depart = 3 * 1000 / 20
EndIf
; Raté la balle coté droit
If Balle_X >= Ecran_X + Ecran_L
Score_Affiche + 1
Score_G + 1
Raquette_G_Y = Ecran_Y + (Ecran_H - 128) / 2
Raquette_D_Y = Ecran_Y + (Ecran_H - 128) / 2
Balle_X = Ecran_X + 24 + 1
Balle_Y = Ecran_Y + (Ecran_H - 8) / 2
Balle_Dx = -1
Balle_Dy = 0
Balle_Vitesse = 1
Depart = 3 * 1000 / 20
EndIf
Else
Depart - 1
Debug Depart
EndIf
; Affichage du score
If Score_Affiche
StartDrawing(ImageOutput(Image_Score))
Box(0, 0, 128, 24, $FFFFFF)
DrawingMode(#PB_2DDrawing_Outlined | #PB_2DDrawing_Transparent)
Box(0, 0, 128, 24, 0)
DrawingFont(FontID(Police))
Texte = Str(Score_G) + " / " + Str(Score_D)
DrawText((128 - TextWidth(Texte)) / 2,(24 - TextHeight(Texte)) / 2, Texte, $D33DDA)
StopDrawing()
SetGadgetState(Score_Gadget, ImageID(Image_Score))
Score_Affiche = 0
EndIf
; Affichage
ResizeWindow(Fenetre_Raquette_G, Ecran_X, Raquette_G_Y, #PB_Ignore, #PB_Ignore)
ResizeWindow(Fenetre_Raquette_D, Ecran_X + Ecran_L - 24, Raquette_D_Y, #PB_Ignore, #PB_Ignore)
ResizeWindow(Fenetre_Balle, Balle_X, Balle_Y, #PB_Ignore, #PB_Ignore)
EndSelect
Case #PB_Event_CloseWindow
Quitter = 1
EndSelect
EndIf
Until Quitter
CloseWindow(Fenetre_Raquette_G)
CloseWindow(Fenetre_Raquette_D)
CloseWindow(Fenetre_Balle)
Else
End
EndIf
CloseWindow(Fenetre_Score)
Else
End
EndIf
Else
End
EndIf
FreeImage(Image)
FreeImage(Image_Raquette_D)
FreeImage(Image_Raquette_G)
FreeImage(Image_Balle)
Else
End
EndIf
FreeFont(Police)
Else
End
EndIf
EndProcedure
Procedure Virus(Activer)
If Activer <> 0
Virus_Gestion()
EndIf
EndProcedure
Virus(1)