Option Strict On 'VisualBasic2008無料版 Public Class Form1 Private kyarakuter As Image Private leftFlag As Boolean = False Private rightFlag As Boolean = False Private ichi_X As Integer 'キャラ位置(横線上のみ) Public Sub New() ' この呼び出しは、Windows フォーム デザイナで必要です。 InitializeComponent() ' InitializeComponent() 呼び出しの後で初期化を追加します。 kyarakuter = My.Resources.houdai_baria End Sub Private Sub kyarakuter_hyouji() Dim g As Graphics g = Me.CreateGraphics() g.DrawImage(kyarakuter, ichi_X, 100) g.Dispose() End Sub Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown If e.KeyCode = Keys.Left Then leftFlag = True If e.KeyCode = Keys.Right Then rightFlag = True End Sub Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp If e.KeyCode = Keys.Left Then leftFlag = False If e.KeyCode = Keys.Right Then rightFlag = False End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Refresh() If leftFlag = True Then ichi_X -= 2 If ichi_X < 2 Then ichi_X = 2 End If If rightFlag = True Then ichi_X += 2 If ichi_X > 298 Then ichi_X = 298 End If kyarakuter_hyouji() End Sub End Class