Option Strict On Public Class Form1 'Gameコード途中制作 'PictureBox1をフォームに入れる 'Timer1とTimer2をフォームに入れる 'コードをすべて消してから、書き込む。 Dim font_1 As New Font("ms ui gothic", 30, FontStyle.Bold) Dim font_2 As New Font("ms ui gothic", 50, FontStyle.Italic) Dim my_gradient As New Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(300, 350), Color.Blue, Color.Red) Dim score% = 0 Dim score_ichi% Dim life_point% = 0 Public Sub New() ' この呼び出しは、Windows フォーム デザイナで必要です。 InitializeComponent() ' InitializeComponent() 呼び出しの後で初期化を追加します。 Me.Size = New Size(700, 700) Me.StartPosition = FormStartPosition.CenterScreen Me.BackColor = Color.Blue Me.FormBorderStyle = Windows.Forms.FormBorderStyle.Fixed3D Me.MaximizeBox = False : Me.MinimizeBox = False Me.Text = "ダイアモンド" End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load With PictureBox1 .Size = New Size(665, 645) .Location = New Point(10, 10) .BackColor = Color.Black End With Timer1.Interval = 100 Timer1.Start() Timer2.Interval = 200 Timer2.Start() End Sub Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint Dim g As Graphics = e.Graphics g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias g.FillRectangle(Brushes.Green, 460, 0, 205, 645) g.DrawLine(Pens.Yellow, 0, 500, 459, 500) g.FillEllipse(my_gradient, 550, 190 + life_point, 40, 400 - life_point) moji("Score", font_1, Brushes.Aqua, 500, 30, g) moji(CStr(score), font_1, Brushes.Yellow, score_ichi, 70, g) moji("★", font_1, Brushes.Pink, 542, 160 + life_point, g) If life_point > 399 Then moji("Game Over", font_2, Brushes.Red, 50, 250, g) End If End Sub Sub moji(ByVal a As String, ByVal b As Font, ByVal c As Brush, ByVal x As Integer, ByVal y As Integer, ByVal g As Graphics) g.DrawString(a, b, Brushes.White, x + 1, y + 1) g.DrawString(a, b, c, x, y) End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick score += 1 score_ichi = 570 - ((CStr(score).Length - 1) * 20) PictureBox1.Invalidate() End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick life_point += 1 If life_point > 400 Then Timer1.Stop() : Timer2.Stop() End If End Sub End Class