掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
画像の周囲に残像が残る (ID:142760)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
ほら、改造してくと、ゲームらしくなってきますよね。 1番簡単なタイプの配列しか使用してません。 Option Strict On 'VisualBasic2008無料版 '必要なもん 'PictureBox1,Button1,Timer1 'をフォームに入れる Public Class Form1 Private hosi_suu As Integer = 200 Private hosi_x(hosi_suu - 1) As Integer Private hosi_y(hosi_suu - 1) As Integer Private hosi_size(hosi_suu - 1) As Integer Private hosi_speed(hosi_suu - 1) As Integer Private hosi_left_right(hosi_suu - 1) As Integer Private hosi_moji(hosi_suu - 1) As Integer Private myRandom As Random Const moji_suu As Integer = 4 Private moji(moji_suu - 1) As String Public Sub New() ' この呼び出しは、Windows フォーム デザイナで必要です。 InitializeComponent() ' InitializeComponent() 呼び出しの後で初期化を追加します。 With Me .BackColor = Color.Brown .Size = New Size(500, 700) .StartPosition = FormStartPosition.CenterScreen End With End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load With PictureBox1 .BackColor = Color.Black .Size = New Size(450, 600) .Location = New Point(20, 50) End With Button1.Location = New Point(210, 20) Button1.Text = "Start" myRandom = New Random() Dim i As Integer For i = 0 To hosi_suu - 1 hosi_size(i) = myRandom.Next(5, 30) hosi_x(i) = myRandom.Next(20, 480) hosi_y(i) = myRandom.Next(20, 500) hosi_speed(i) = myRandom.Next(1, 5) hosi_left_right(i) = myRandom.Next(-2, 2) hosi_moji(i) = myRandom.Next(4) Next moji(0) = "一" : moji(1) = "石" : moji(2) = "二" : moji(3) = "鳥" 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 Dim i, d As Integer For i = 0 To hosi_suu - 1 Dim my_font As New Font("ms gothic", hosi_size(i)) d = hosi_moji(i) g.DrawString(moji(d), my_font, Brushes.Yellow, hosi_x(i), hosi_y(i)) Next End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Interval = 1 Timer1.Start() Button1.Enabled = False End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick For i As Integer = 0 To hosi_suu - 1 hosi_y(i) += hosi_speed(i) hosi_x(i) += hosi_left_right(i) If hosi_y(i) > 600 Or hosi_x(i) < 0 Or hosi_x(i) > 500 Then hosi_y(i) = 0 hosi_x(i) = myRandom.Next(20, 480) hosi_left_right(i) = myRandom.Next(-5, 5) End If PictureBox1.Invalidate() Next End Sub End Class
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.