1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
|
Public Class frmSprite1
Private f, d As Integer
'------------------LE SIMPLE BITMAP SPRITE------------------
Private Sprite As Bitmap
Private tab(100000) As PictureBox
Public Sub New()
' Cet appel est requis par le concepteur.
InitializeComponent()
' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
'------------------UTILISE CECI POUR EVITER LE SCINTILLEMENT----------
Me.DoubleBuffered = True
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
f = 50 'nombre de casse
d = 50 'size
'------------------INIT TON SPRITE BITMAP ICI PUISQUE C'EST TOUJOURS ROUGE.PNG
Sprite = New Bitmap(Image.FromFile(Application.StartupPath + "\Resources\rouge.png"), d, d)
'dimension aléatoire du cadre
'dimcadre()
'encadrement
'monde premier étage
'------------------ENCADRE TON SUB "depart" PAR CECI ------------------
Me.SuspendLayout()
depart()
Me.ResumeLayout()
End Sub
Private a, b, c As Integer
Sub depart()
Dim i, s, j As Integer
b = 500 'top
a = 0 'left
For i = 1 To f
Randomize()
c = Int((20 * Rnd()) + 1)
'premier
If i = 1 Then
tab(i) = New PictureBox()
tab(i).Size = New Size(d, d)
tab(i).Visible = True
tab(i).Left = a
tab(i).Top = b
tab(i).Image = Sprite
tab(i).Name = "PictureBox" & i
Me.Controls.Add(tab(i))
s = b
For j = 1 To 50
tab(i) = New PictureBox()
tab(i).Size = New Size(d, d)
tab(i).Visible = True
tab(i).Left = a
tab(i).Top = s
s = s + 50
tab(i).Image = Sprite
tab(i).Name = "PictureBox" & i
Me.Controls.Add(tab(i))
Next
'remplir le dessous
End If
'dessus
If c = 1 Then
tab(i) = New PictureBox()
tab(i).Size = New Size(d, d)
tab(i).Visible = True
b = b - d
tab(i).Left = a
tab(i).Top = b
tab(i).Image = Sprite
tab(i).Name = "PictureBox" & i
'Me.Controls.Add(tab(i))
End If
'dessus devant
If c = 2 Then
tab(i) = New PictureBox()
tab(i).Size = New Size(d, d)
tab(i).Visible = True
a = a + d
b = b - d
tab(i).Left = a
tab(i).Top = b
tab(i).Image = Sprite
tab(i).Name = "PictureBox" & i
'Me.Controls.Add(tab(i))
s = b
For j = 1 To 50
tab(i) = New PictureBox()
tab(i).Size = New Size(d, d)
tab(i).Visible = True
tab(i).Left = a
tab(i).Top = s
s = s + 50
tab(i).Image = Sprite
tab(i).Name = "PictureBox" & i
Me.Controls.Add(tab(i))
Next
End If
'devant
If c > 2 And c < 19 Then
tab(i) = New PictureBox()
tab(i).Size = New Size(d, d)
tab(i).Visible = True
a = a + d
tab(i).Left = a
tab(i).Top = b
tab(i).Image = Sprite
tab(i).Name = "PictureBox" & i
'Me.Controls.Add(tab(i))
s = b
For j = 1 To 50
tab(i) = New PictureBox()
tab(i).Size = New Size(d, d)
tab(i).Visible = True
tab(i).Left = a
tab(i).Top = s
s = s + 50
tab(i).Image = Sprite
tab(i).Name = "PictureBox" & i
Me.Controls.Add(tab(i))
Next
End If
'devant dessous
If c = 19 Then
tab(i) = New PictureBox()
tab(i).Size = New Size(d, d)
tab(i).Visible = True
a = a + d
b = b + d
tab(i).Left = a
tab(i).Top = b
tab(i).Image = Sprite
tab(i).Name = "PictureBox" & i
'Me.Controls.Add(tab(i))
s = b
For j = 1 To 50
tab(i) = New PictureBox()
tab(i).Size = New Size(d, d)
tab(i).Visible = True
tab(i).Left = a
tab(i).Top = s
s = s + 50
tab(i).Image = Sprite
tab(i).Name = "PictureBox" & i
Me.Controls.Add(tab(i))
Next
End If
'dessous
If c = 20 Then
tab(i) = New PictureBox()
tab(i).Size = New Size(d, d)
tab(i).Visible = True
b = b + d
tab(i).Left = a
tab(i).Top = b
tab(i).Image = Sprite
tab(i).Name = "PictureBox" & i
End If
tab(i).Image = Sprite
tab(i).Name = "PictureBox" & i
Next i
'boucle de remplissage
End Sub
End Class |
Partager