- 分享
- 0
- 人气
- 0
- 主题
- 0
- 帖子
- 84
- UID
- 192730
- 积分
- 69
- 阅读权限
- 12
- 注册时间
- 2009-1-15
- 最后登录
- 2010-9-14
- 在线时间
- 30 小时
|
Imports System.Drawing.Drawing2D
Imports System.Drawing.Graphics
Public Class Form1
Dim circle As New Rectangle(12, 208, 28, 23)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.KeyPreview = True
End Sub
Private Sub PictureBox2_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Dim graphicsObjectC As Graphics = e.Graphics
Dim carbody As SolidBrush = New SolidBrush(Color.BlueViolet)
Dim carbodypen As Pen = New Pen(carbody)
Dim carcover As SolidBrush = New SolidBrush(Color.White)
Dim carcoverpen As Pen = New Pen(carcover)
Dim carwin As SolidBrush = New SolidBrush(Color.White)
Dim carwinpen As Pen = New Pen(carwin)
Dim cartyback As New Rectangle(23, 65, 20, 20)
Dim cartybrush As New SolidBrush(Color.Black)
Dim cartypen As New Pen(Color.Black, 8)
Dim cartyfront As New Rectangle(100, 65, 20, 20)
Dim cartyfrontbrush As New SolidBrush(Color.Black)
Dim cartyfrontpen As New Pen(Color.Black, 8)
carbodypen.Color = Color.DarkCyan
carbodypen.Width = 60
carbodypen.DashCap = LineCap.Round
carbodypen.DashStyle = DashStyle.Solid
graphicsObjectC.DrawLine(carbodypen, 10, 45, 145, 45)
carcoverpen.Color = Color.White
carcoverpen.Width = 33
carcoverpen.DashCap = LineCap.Round
carcoverpen.DashStyle = DashStyle.Solid
graphicsObjectC.DrawLine(carcoverpen, 90, 29, 150, 29)
carwinpen.Color = Color.White
carwinpen.Width = 13
carwinpen.DashCap = LineCap.Round
carwinpen.DashStyle = DashStyle.Solid
graphicsObjectC.DrawLine(carwinpen, 22, 30, 75, 30)
e.Graphics.FillEllipse(cartybrush, cartyback)
e.Graphics.DrawEllipse(cartypen, cartyback)
e.Graphics.FillEllipse(cartyfrontbrush, cartyfront)
e.Graphics.DrawEllipse(cartyfrontpen, cartyfront)
End Sub
Public Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
'spike=========================================================================================================
Dim graphicsObject As Graphics = e.Graphics
'Line Drawed --------------------------------------------------------------------------------------------------
Dim straight As SolidBrush = New SolidBrush(Color.Black)
Dim straightPen As Pen = New Pen(straight)
Dim left As SolidBrush = New SolidBrush(Color.Black)
Dim leftPen As Pen = New Pen(left)
Dim right As SolidBrush = New SolidBrush(Color.Black)
Dim rightPen As Pen = New Pen(right)
'--------------------------------------------------------------------------------------------------------------
'Circle drawed
Dim circlebrush As New SolidBrush(Color.Blue)
Dim circlepen As New Pen(Color.Blue, 8)
'--------------------------------------------------------------------------------------------------------------
'eyes drawed
Dim eyel As New Rectangle(16, 212, 6, 6)
Dim eyelbrush As New SolidBrush(Color.Black)
Dim eyelpen As New Pen(Color.Black, 3)
Dim eyer As New Rectangle(28, 212, 6, 6)
Dim eyerbrush As New SolidBrush(Color.Black)
Dim eyerpen As New Pen(Color.Black, 3)
'Rectangle drawed
Dim rect As New RectangleF(18, 226, 16, 3)
Dim rectbrush As New SolidBrush(Color.Red)
straightPen.Color = Color.Black
straightPen.Width = 4
straightPen.DashCap = LineCap.Round
straightPen.DashStyle = DashStyle.Solid
graphicsObject.DrawLine(straightPen, 2, 220, 53, 220)
leftPen.Color = Color.Black
leftPen.Width = 4
leftPen.DashCap = LineCap.Round
leftPen.DashStyle = DashStyle.Solid
graphicsObject.DrawLine(leftPen, 10, 238, 40, 202)
rightPen.Color = Color.Black
rightPen.Width = 4
rightPen.DashCap = LineCap.Round
rightPen.DashStyle = DashStyle.Solid
graphicsObject.DrawLine(rightPen, 13, 202, 40, 238)
e.Graphics.FillEllipse(circlebrush, circle)
e.Graphics.DrawEllipse(circlepen, circle)
e.Graphics.FillEllipse(eyelbrush, eyel)
e.Graphics.DrawEllipse(eyelpen, eyel)
e.Graphics.FillEllipse(eyerbrush, eyer)
e.Graphics.DrawEllipse(eyerpen, eyer)
e.Graphics.FillRectangle(rectbrush, rect)
'spike=========================================================================================================
End Sub
Public Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Dim Loc As Point
Select Case e.KeyCode
Case Keys.Left
If Not circle.Location.X - 5 < 0 Then
Loc = New Point(circle.Location.X - 5, circle.Location.Y)
circle.Location = Loc
End If
Case Keys.Right
If Not circle.Location.X + 5 > Me.Width - circle.Width - 5 Then
Loc = New Point(circle.Location.X + 5, circle.Location.Y)
circle.Location = Loc
End If
Case Keys.Up
If Not circle.Location.Y - 5 < 0 Then
Loc = New Point(circle.Location.X, circle.Location.Y - 5)
circle.Location = Loc
End If
Case Keys.Down
If Not circle.Location.Y - 5 > Me.Height - circle.Height * 1.5 Then
Loc = New Point(circle.Location.X, circle.Location.Y + 5)
circle.Location = Loc
End If
End Select
End Sub
End Class |
|