當前位置:首頁 » 課程大全 » vbnet課程設計游戲

vbnet課程設計游戲

發布時間: 2021-03-09 15:25:39

㈠ 誰能發個用VBnet做的小游戲的源代碼

第一次回答可獲2分,已經發了一個了你看行不
謝謝
答案被採納可獲得懸賞分和額外20分獎勵。

㈡ 用VB.NET編寫3D游戲的教學

想系統的學習,需要的東西太多太多了。想花個幾個月就能做出個游戲可以學學Unity3d,是個完整的游戲引擎,用戶可以寫腳本來實現游戲邏輯,挺好。

㈢ vb.net能用來編寫游戲嗎

所有的語言都可以用來編寫游戲~可關鍵是你游戲的復雜程度.和BUG的最小話~~~所以如果你要做個大行的游戲的話,就必須是個團隊,不同的分工,如果要是簡單的寫個貪事蛇,俄羅斯方塊這樣的,估計只要你好好的看看相關的資料,完全可以自己搞定的~~~

㈣ 求VB.net程序源代碼 繪圖板、二十一點游戲、計算器、井字棋游戲、屏幕保護程序等

說明:1.共有4個文本框其,其中三個是填入或輸出數據的(名稱分別是:txta txtb txtc),剩下的那個是符號(txtd)2.共7個按鈕,4個是符號按鈕,一個計算,一個清零.這是我弄的程序」袖珍計算器」代碼也是自己編寫的,代碼如下:通用聲明Dim j As Integer '定義j為整型
Private Sub Text1_Change()End SubPrivate Sub Command1_Click()
txtfuhao.Text = "+" '將」+」顯示到文本框txtfuhao.Text中
End SubPrivate Sub Command2_Click()
txtfuhao.Text = "-" ''將」-」顯示到文本框txtfuhao.Text中

End SubPrivate Sub Command3_Click()
txtfuhao.Text = "×" '將」×」顯示到文本框txtfuhao.Text中

End SubPrivate Sub Command4_Click()
txtfuhao.Text = "÷" 將」÷」'顯示到文本框txtfuhao.Text中

End Sub
Private Sub Command5_Click()
Dim a, b, c As Integer
a = Val(txta.Text) '將txta.Text里的內容轉化為數值型,然後再賦給a
b = Val(txtb.Text) '將txtb.Text里的內容轉化為數值型,然後再賦給b
If txtfuhao.Text = "+" Then '運算過程
c = a + b '運算過程
ElseIf txtfuhao.Text = "-" Then '運算過程
c = a - b '運算過程
ElseIf txtfuhao.Text = "÷" Then '運算過程
c = a / b '運算過程
ElseIf txtfuhao.Text = "×" Then '運算過程
c = a * b '運算過程
Else
j = MsgBox("您輸入的符號不正確", vbOKOnly, "錯誤信息")
End If
txtc.Text = c '將運算結果c輸出到文本框txtc中
End SubPrivate Sub Command6_Click()
txta.Text = "" '將空字元輸入到文本框內(刷新)
txtb.Text = "" '將空字元輸入到文本框內(刷新)
txtc.Text = "" '將空字元輸入到文本框內(刷新)
txtfuhao.Text = "" '將空字元輸入到文本框內(刷新)
End SubPrivate Sub Command7_Click()
End '結束程序
End SubPrivate Sub Form_Load()End Sub

㈤ vb.net中設計一個小游戲

記憶力測試 翻牌的游戲 都有

㈥ vb.net編寫的貪吃蛇游戲,帶代碼的

需用VB實現,代碼如下

'定義蛇的運動速度枚舉值
Private Enum tpsSpeed
QUICKLY = 0
SLOWLY = 1
End Enum

'定義蛇的運動方向枚舉值
Private Enum tpsDirection
D_UP = 38
D_DOWN = 40
D_LEFT = 37
D_RIGHT = 39
End Enum

'定義運動區域4個禁區的枚舉值
Private Enum tpsForbiddenZone
FZ_TOP = 30
FZ_BOTTOM = 5330
FZ_LEFT = 30
FZ_RIGHT = 5730
End Enum

'定義蛇頭及身體初始化數枚舉值
Private Enum tpsSnake
SNAKEONE = 1
SNAKETWO = 2
SNAKETHREE = 3
SNAKEFOUR = 4
End Enum

'定義蛇寬度的常量
Private Const SNAKEWIDTH As Integer = 100

'該過程用於顯示游戲信息
Private Sub Form_Load()
Me.Show
Me.lblTitle = "BS貪食蛇 — (版本 " & App.Major & "." & App.Minor & "." & App.Revision & ")"
Me.Caption = Me.lblTitle.Caption
frmSplash.Show 1
End Sub

'該過程用於使窗體恢復原始大小
Private Sub Form_Resize()
If Me.WindowState <> 1 Then
Me.Caption = ""
Me.Height = 6405 '窗體高度為 6405 緹
Me.Width = 8535 '窗體寬度為 8535 緹
Me.Left = (Screen.Width - Width) \ 2
Me.Top = (Screen.Height - Height) \ 2
End If
End Sub

'該過程用於重新開始開始游戲
Private Sub cmdGameStart_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Beep
msg = MsgBox("您確認要重新開始游戲嗎?", 4 + 32, "BS貪食蛇")
If msg = 6 Then Call m_subGameInitialize
End Sub

'該過程用於暫停/運行游戲
Private Sub chkPause_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Me.chkPause.Caption = "暫停游戲(&P)" Then
Me.tmrSnakeMove.Enabled = False
Me.tmrGameTime.Enabled = False
Me.picMoveArea.Enabled = False
Me.lblPauseLab.Visible = True
Me.chkPause.Caption = "繼續游戲(&R)"
Else
Me.tmrSnakeMove.Enabled = True
Me.tmrGameTime.Enabled = True
Me.picMoveArea.Enabled = True
Me.lblPauseLab.Visible = False
Me.chkPause.Caption = "暫停游戲(&P)"
End If
End Sub

'該過程用於顯示游戲規則
Private Sub cmdGameRules_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Beep
MsgBox " BS貪食蛇:一個規則最簡單的趣味游戲,您將用鍵盤" & Chr(13) & _
"上的4個方向鍵來控制蛇的運動方向。在運動過程中蛇" & Chr(13) & _
"不能後退,蛇的頭部也不能接觸到運動區域的邊線以外" & Chr(13) & _
"和蛇自己的身體,否則就游戲失敗。在吃掉隨機出現的" & Chr(13) & _
"果子後,蛇的身體會變長,越長難度越大。祝您好運!!", 0 + 64, "游戲規則"
End Sub

'該過程用於顯示游戲開發信息
Private Sub cmdAbout_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Beep
MsgBox "BS貪食蛇" & "(V-" & App.Major & "." & App.Minor & "版本)" & Chr(13) & Chr(13) & _
"" & Chr(13) & Chr(13) & _
"由PigheadPrince設計製作" & Chr(13) & _
"CopyRight(C)2002,BestSoft.TCG", 0, "關於本游戲"
End Sub

'該過程用於退出遊戲
Private Sub cmdExit_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Beep
msg = MsgBox("您要退出本游戲嗎?", 4 + 32, "BS貪食蛇")
Select Case msg
Case 6
End
Case 7
Me.chkWindowButton(2).Value = 0
Exit Sub
End Select
End Sub

'該過程用於拖動窗體_(點擊圖標)
Private Sub imgWindowTop_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage Me.hwnd, WM_SYSCOMMAND, SC_MOVE, 0
End Sub

'該共用過程用於處理窗體控制按鈕組的相關操作_(鎖定、最小化、退出)
Private Sub chkWindowButton_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button <> 1 Then Exit Sub
Select Case Index
Case 0 '鎖定窗體
If Me.chkWindowButton(0).Value = 1 Then
Me.imgWindowTop.BorderStyle = 0
Me.imgWindowTop.Enabled = False
Else
Me.imgWindowTop.BorderStyle = 1
Me.imgWindowTop.Enabled = True
End If
Case 1 '最小化
Me.WindowState = 1
Me.chkWindowButton(1).Value = 0
Me.Caption = "BS貪食蛇 — (V-" & App.Major & "." & App.Minor & "版本)"
Case 2 '退出
Beep
msg = MsgBox("您要退出本游戲嗎?", 4 + 32, "BS貪食蛇")
Select Case msg
Case 6
End
Case 7
Me.chkWindowButton(2).Value = 0
Exit Sub
End Select
End Select
End Sub

'該過程用於設置蛇運動速度的快慢
Private Sub hsbGameSpeed_Change()
Me.tmrSnakeMove.Interval = Me.hsbGameSpeed.Value
End Sub

'該過程用於通過鍵盤的方向鍵改變蛇的運動方向
Private Sub picMoveArea_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case g_intDirection
Case D_UP
If KeyCode = D_DOWN Then Exit Sub
Case D_DOWN
If KeyCode = D_UP Then Exit Sub
Case D_LEFT
If KeyCode = D_RIGHT Then Exit Sub
Case D_RIGHT
If KeyCode = D_LEFT Then Exit Sub
End Select
g_intDirection = KeyCode
End Sub

'該計時循環過程用於計算游戲耗費的秒數並顯示
Private Sub tmrGameTime_Timer()
g_lngGameTime = g_lngGameTime + 1
Me.lblGameTime.Caption = g_lngGameTime & "秒"
End Sub

'該計時循環過程用於控制蛇的行動軌跡
Private Sub tmrSnakeMove_Timer()
Dim lngSnakeX As Long, lngSnakeY As Long, lngSnakeColor As Long
Dim lngPointX As Long, lngPointY As Long, lngPointColor As Long
Randomize
Me.picMoveArea.SetFocus
Me.picMoveArea.Cls
'確認蛇頭的運動方向並獲取新的位置
Select Case g_intDirection
Case D_UP '向上運動
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_OldX
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_OldY
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_CurY - SNAKEWIDTH
Case D_DOWN '向下運動
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_OldX
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_OldY
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_CurY + SNAKEWIDTH
Case D_LEFT '向左運動
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_OldX
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_CurX - SNAKEWIDTH
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_OldY
Case D_RIGHT '向右運動
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_OldX
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_CurX + SNAKEWIDTH
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_OldY
End Select
'根據新的位置繪制蛇頭
lngSnakeX = g_udtSnake(SNAKEONE).Snake_CurX
lngSnakeY = g_udtSnake(SNAKEONE).Snake_CurY
lngSnakeColor = g_udtSnake(SNAKEONE).Snake_Color
Me.picMoveArea.PSet (lngSnakeX, lngSnakeY), lngSnakeColor
'移動蛇身體其他部分的位置
For i = 2 To g_intSnakeLength
g_udtSnake(i).Snake_CurX = g_udtSnake(i - 1).Snake_OldX
g_udtSnake(i).Snake_CurY = g_udtSnake(i - 1).Snake_OldY
lngSnakeX = g_udtSnake(i).Snake_CurX
lngSnakeY = g_udtSnake(i).Snake_CurY
lngSnakeColor = g_udtSnake(i).Snake_Color
Me.picMoveArea.PSet (lngSnakeX, lngSnakeY), lngSnakeColor
Next i
'更新蛇舊的坐標位置
For j = 1 To g_intSnakeLength
g_udtSnake(j).Snake_OldX = g_udtSnake(j).Snake_CurX
g_udtSnake(j).Snake_OldY = g_udtSnake(j).Snake_CurY
Next j
'判斷蛇在移動中是否到了禁區而導致游戲失敗
If m_funMoveForbiddenZone(g_udtSnake(SNAKEONE).Snake_CurX, g_udtSnake(SNAKEONE).Snake_CurY) Then
Beep
MsgBox "您的蛇移動到了禁區,游戲失敗!", 0 + 16, "BS貪食蛇"
Me.tmrSnakeMove.Enabled = False
Me.tmrGameTime.Enabled = False
Me.picMoveArea.Visible = False
Exit Sub
End If
'判斷蛇在移動中是否碰到了自己的身體而導致游戲失敗
If m_funTouchSnakeBody(g_udtSnake(SNAKEONE).Snake_CurX, g_udtSnake(SNAKEONE).Snake_CurY) Then
Beep
MsgBox "您的蛇在移動中碰到了自己的身體,游戲失敗!", 0 + 16, "BS貪食蛇"
Me.tmrSnakeMove.Enabled = False
Me.tmrGameTime.Enabled = False
Me.picMoveArea.Visible = False
Exit Sub
End If
'判斷蛇是否吃到了果子
If m_funEatPoint(g_udtSnake(SNAKEONE).Snake_CurX, g_udtSnake(SNAKEONE).Snake_CurY) Then
'累加玩家的得分並刷新得分顯示
g_intPlayerScore = g_intPlayerScore + 1
Me.lblYourScore.Caption = g_intPlayerScore & "分"
Call m_subAddSnake '加長蛇的身體
Call m_subGetPoint '獲取下一個果子的位置和顏色
Else
'繪制果子
lngPointX = g_udtPoint.Point_X
lngPointY = g_udtPoint.Point_Y
lngPointColor = g_udtPoint.Point_Color
Me.picMoveArea.PSet (lngPointX, lngPointY), lngPointColor
End If
End Sub

'該私有子過程用於初始化游戲
Private Sub m_subGameInitialize()
Erase g_udtSnake '清空蛇的結構數組
g_intPlayerScore = 0 '清空玩家的得分
g_lngGameTime = 0 '清空游戲耗費的秒數
g_intDirection = D_DOWN '設定蛇的初始運動方向為下
g_intSnakeLength = 4 '設定蛇的初始長度
ReDim g_udtSnake(1 To g_intSnakeLength) '重新定義蛇的長度
'定義蛇頭部的數據
With g_udtSnake(SNAKEONE)
.Snake_OldX = 530
.Snake_OldY = 530
.Snake_Color = vbBlack
End With
'定義蛇身第2節的數據
With g_udtSnake(SNAKETWO)
.Snake_OldX = 530
.Snake_OldY = 430
.Snake_Color = vbGreen
End With
'定義蛇身第3節的數據
With g_udtSnake(SNAKETHREE)
.Snake_OldX = 530
.Snake_OldY = 330
.Snake_Color = vbYellow
End With
'定義蛇身第4節的數據
With g_udtSnake(SNAKEFOUR)
.Snake_OldX = 530
.Snake_OldY = 230
.Snake_Color = vbRed
End With
Me.picMoveArea.Visible = True
Me.lblYourScore.Caption = g_intPlayerScore & "分"
Me.lblGameTime.Caption = g_lngGameTime & "秒"
Me.tmrSnakeMove.Interval = Me.hsbGameSpeed.Value
Me.tmrSnakeMove.Enabled = True
Me.tmrGameTime.Enabled = True
Call m_subGetPoint '獲取第一個果子的位置和顏色
End Sub

㈦ 用VB編寫一個小游戲

如果要做1-52的牌的話,建議這么來,1-4是1,5-8是2……以此類推,37-40是10吧,應該不是45吧?內
這種情況下,只要容將牌的序號整除4,然後+1得到的結果就是拍的數值了,比如9/4+1=3,這張牌是3,再假設1是黑桃,2是紅桃,3是梅花,4是方塊,那麼將牌的序號對4去模,就能得到牌對應的花色,比如9MOD4=1,那麼這張牌的花色就是黑桃。

加牌的方法很簡單,你講1-52張排做一個數組,,裡面填充的值是1-52每次抽牌都是一個1-52的隨機數(要無限循環,直到取到牌才break出來),比如取到了33號牌,那麼就標記一下33號的數字為0,這樣你下次再隨機抽中33的時候判斷一下他的數值是不是0就能知道這張牌是不是被抽走了。

㈧ 求幫做VB課程設計(打字游戲)

Dim h As Integer
Dim n As Integer

Private Function zi()
Randomize
If Form1.Option1.Value Then
a = Int((122 - 97 + 1) * Rnd + 97)
ElseIf Form1.Option2.Value Then
a = Int((90 - 65 + 1) * Rnd + 65)
ElseIf Form1.Option3.Value Then
a = Int((126 - 48 + 1) * Rnd + 48)
End If
zi = Chr(a)
End Function

Private Sub Form_KeyPress(KeyAscii As Integer)
Dim b As Integer
Dim c As Integer
b = -1
c = -1
For i = 0 To Label1.Count - 1
If Label1(i).Caption = Chr(KeyAscii) Then
If Label1(i).Top > b Then
c = i
End If
End If
Next
If c > -1 Then
Image1.Top = Label1(c).Top
Image1.Left = Label1(c).Left
Image1.Visible = True
Label1(c).Top = -10
Label1(c).Caption = zi
h = h + 1
Label2.Caption = "當前得分:" & h
If Form1.Option4.Value Then
h = h + 1
ElseIf Form1.Option5.Value Then
h = h + 2
ElseIf Form1.Option6.Value Then
h = h + 3
End If

End if
If KeyAscii = 27 Then
If MsgBox("真的要退出嗎", vbYesNo) = vbYes Then
MsgBox "您的得分" & h & "分", , "成績"
Unload Form2
Form1.Show
End If
End If

End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Image1.Visible = False
End Sub

Private Sub Form_Load()
Dim lu As String
lu = App.Path
If Right(lu, 1) <> "/" Then
lu = lu & "/"
End If
lu = lu & "3.jpg"
Image1.Picture = LoadPicture(lu)

h = 0
n = 0
For i = 0 To Label1.Count - 1
Label1(i).Top = 0 - 380 * (i + 1)
Label1(i).Caption = zi
Next
End Sub

Private Sub Timer1_Timer()
For i = 0 To Label1.Count - 1
If Form1.Option4.Value Then
If h > 100 Then
Label1(i).Top = Label1(i).Top + 80
Else
Label1(i).Top = Label1(i).Top + 40
End If
ElseIf Form1.Option5.Value Then
If h > 200 Then
Label1(i).Top = Label1(i).Top + 120
Else
Label1(i).Top = Label1(i).Top + 60
End If
ElseIf Form1.Option6.Value Then
If h > 300 Then
Label1(i).Top = Label1(i).Top + 160
Else
Label1(i).Top = Label1(i).Top + 80
End If
End If
If Label1(i).Top > 6525 Then
n = n + 1
Label3.Caption = "掉落個數:" & n
Label1(i).Top = -10
Label1(i).Caption = zi
End If
If n = 27 Then
If MsgBox("掉落的個數已經超過" & n & "個,是否重新開始", vbYesNo) = vbYes Then
MsgBox "您的得分:" & h & "分", , "成績"
Unload Form2
Form1.Visible = True
Exit Sub
Else
MsgBox "您的得分" & h & "分", , "成績"
End
End If
End If

Next

End Sub

熱點內容
武漢大學學生會輔導員寄語 發布:2021-03-16 21:44:16 瀏覽:612
七年級學生作文輔導學案 發布:2021-03-16 21:42:09 瀏覽:1
不屑弟高考成績 發布:2021-03-16 21:40:59 瀏覽:754
大學畢業證會有成績單 發布:2021-03-16 21:40:07 瀏覽:756
2017信陽學院輔導員招聘名單 發布:2021-03-16 21:40:02 瀏覽:800
查詢重慶2018中考成績查詢 發布:2021-03-16 21:39:58 瀏覽:21
結業考試成績怎麼查詢 發布:2021-03-16 21:28:40 瀏覽:679
14中醫醫師資格筆試考試成績查分 發布:2021-03-16 21:28:39 瀏覽:655
名著賞析課程標准 發布:2021-03-16 21:27:57 瀏覽:881
北京大學商業領袖高端培訓課程 發布:2021-03-16 21:27:41 瀏覽:919