我在網(wǎng)上找到的實例,發(fā)到附件。
創(chuàng)新互聯(lián)公司專注于義烏企業(yè)網(wǎng)站建設,響應式網(wǎng)站設計,商城網(wǎng)站開發(fā)。義烏網(wǎng)站建設公司,為義烏等地區(qū)提供建站服務。全流程按需網(wǎng)站制作,專業(yè)設計,全程項目跟蹤,創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務
主窗口代碼:
Public Class Form1
Dim x As Integer = 1
Dim y As Integer = 1
Dim line As Integer = 12
Dim row As Integer = 12
Dim time_used As Integer = 0
Dim brick(line, row) As Button
Dim score As Integer = 0
Dim box_rectangle As Button = New Button
Dim box_ellipse As Button = New Button
Dim flage As Integer = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
score = 0
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
TextBox2.Text = Format(Now(), "yyyy/MM/dd HH:mm:ss")
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
time_used += 1
Label7.Text = time_used
End Sub
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
box_ellipse.Location = New Point(box_ellipse.Location.X - x, box_ellipse.Location.Y - y)
If box_ellipse.Location.X 5 Or box_ellipse.Location.X 845 Then????? '左右界
x = -x
End If
If box_ellipse.Location.Y 5 Then????????????????????????????????????? '上界
y = -y
End If
If box_ellipse.Location.Y box_rectangle.Top - 10 Then?????????????????? '低于拍子
If box_ellipse.Location.X box_rectangle.Left And box_ellipse.Location.X box_rectangle.Right Then
y = -y
End If
End If
Dim i As Integer = 0
Dim j As Integer = 0
For i = 0 To line - 1
For j = 0 To row - 1
If box_ellipse.Left = brick(i, j).Left And box_ellipse.Left = brick(i, j).Left + brick(i, j).Width - box_ellipse.Width Then
If box_ellipse.Top = brick(i, j).Top + brick(i, j).Height And brick(i, j).Top + brick(i, j).Height = brick(i, j).Top And
brick(i, j).Visible Then
brick(i, j).Visible = False
GroupBox1.Controls.Remove(brick(i, j))
y = -y
score += 2
Label1.Text = score.ToString
End If
ElseIf brick(i, j).Text = "" And box_ellipse.Top = brick(i, j).Top + brick(i, j).Height - box_ellipse.Height And box_ellipse.Top = brick(i, j).Top Then
If box_ellipse.Left + box_ellipse.Width = brick(i, j).Left And box_ellipse.Left = brick(i, j).Left + brick(i, j).Width And
brick(i, j).Visible Then
brick(i, j).Visible = False
GroupBox1.Controls.Remove(brick(i, j))
x = -x
score += 2
Label1.Text = score.ToString
End If
End If
Next
Next
If box_ellipse.Top box_rectangle.Top - 2 Then??????????????????????????? '下界
Timer2.Enabled = False
Timer3.Enabled = False
MessageBox.Show("在練幾年吧", "游戲結(jié)束")
End If
If score = 2 * line * row Then
Timer2.Enabled = False
Timer3.Enabled = False
MessageBox.Show("恭喜恭喜?。≡賮硪痪郑。?, "游戲結(jié)束")
End If
End Sub
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If box_rectangle.Left = GroupBox1.Left And box_rectangle.Left = 785 Then
If e.KeyCode = Keys.Left Then
box_rectangle.Left -= 20
End If
If e.KeyCode = Keys.Right Then
box_rectangle.Left += 20
End If
ElseIf box_rectangle.Left GroupBox1.Left Then
If e.KeyCode = Keys.Left Then
box_rectangle.Left = 0
End If
If e.KeyCode = Keys.Right Then
box_rectangle.Left += 20
End If
ElseIf box_rectangle.Left 785 Then
If e.KeyCode = Keys.Left Then
box_rectangle.Left -= 20
End If
If e.KeyCode = Keys.Right Then
box_rectangle.Left = 805
End If
End If
End Sub
Private Sub BeginToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BeginToolStripMenuItem.Click
Timer2.Enabled = True
Timer2.Interval = 1000
Timer3.Enabled = True
Timer3.Interval = 1
Call Inite(line, row)
End Sub
Private Sub BridToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BridToolStripMenuItem.Click
Label6.Text = "Bird"
Call Inite(8, 8)
End Sub
Private Sub PlatinumToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlatinumToolStripMenuItem.Click
Label6.Text = "Platinum"
Call Inite(10, 10)
End Sub
Private Sub BoneToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BoneToolStripMenuItem.Click
Label6.Text = "Bone"
Call Inite(12, 12)
End Sub
Private Sub Inite(ByVal l As Integer, ByVal r As Integer)
Timer2.Enabled = True
Timer2.Interval = 1000
Timer3.Enabled = True
Timer3.Interval = 1
KeyPreview = True
line = l
row = r
If flage = 1 Then
GroupBox1.Controls.Clear()
End If
box_ellipse.Location = New Point(GroupBox1.Width / 2 - box_ellipse.Width / 2, GroupBox1.Height - 40)
box_ellipse.Size = New Size(10, 10)
box_ellipse.Name = ""
box_ellipse.BackColor = Color.Green
GroupBox1.Controls.Add(box_ellipse)
box_rectangle.Location = New Point(GroupBox1.Width / 2 - box_rectangle.Width / 2, GroupBox1.Height - 30)
box_rectangle.Size = New Size(60, 10)
box_rectangle.Name = ""
box_rectangle.BackColor = Color.Blue
GroupBox1.Controls.Add(box_rectangle)
Dim i As Integer
Dim j As Integer
For i = 0 To line - 1
For j = 0 To row - 1
brick(i, j) = New Button
brick(i, j).Location = New Point(15 + i * (GroupBox1.Width / line), 10 + j * 20)
brick(i, j).Size = New Size(60, 10)
brick(i, j).Name = i.ToString + j.ToString
brick(i, j).BackColor = Color.Red
GroupBox1.Controls.Add(brick(i, j))
Next
Next
flage = 1
End Sub
Private Sub ConcernToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConcernToolStripMenuItem.Click
MessageBox.Show("Made in China by liangzhijun4 !")
End Sub
Private Sub EndToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EndToolStripMenuItem.Click
Timer2.Enabled = False
Timer3.Enabled = False
MessageBox.Show("游戲結(jié)束", "常來玩哦~~")
End Sub
Private Sub QuitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitToolStripMenuItem.Click
Timer2.Enabled = False
Timer3.Enabled = False
MessageBox.Show("游戲結(jié)束", "常來玩哦~~")
End
End Sub
Private Sub HelpToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HelpToolStripMenuItem1.Click
MessageBox.Show("- 向右 ,-向左")
End Sub
End Class
#includestring.h
#includestdio.h
#include stdlib.h
#includeconio.h
int scr[22][50], q=14, w=30, ban=20, score=1, sx=-1 , zy=-1 ,speed=1, chang=30;
void moveqiu(void);
void penzhuangqiu(void);
void printf(void);
void menu(void);
main(void)
{
int i=0,j=0;
menu();
for(;j50;j++)
scr[i][j]=4;
j=0;i=1;
;for(;i3;i++)
for(j=2;j48;j++)
scr[i][j]=3;
//這里設置磚頭位置
scr[q][w]=2;
while(1)
{
for(j=0;j20;j++)//將板位置歸0
scr[21][ban+j]=0;
if(kbhit())//控制板的移動
switch(getch())
{
case'a':case'A':if(ban1ban=29) ban--;
break;
case'd':case'D':if(ban0ban=28) ban++;
break;
case'w':case'W':getch();break;//暫停鍵
}
for(j=0;j20;j++)//建立板位置為1
scr[21][ban+j]=1;
penzhuangqiu();
moveqiu();
printf();
}
}
void penzhuangqiu(void)
{
int b;
b=0;
if(zy==1)//以下四個if用來檢測撞磚,并改變球的運動方向
if(scr[q][w+1]==3||w+1==49)
{
scr[q][w+1]=0;
zy=-zy;
b=1;
}
if(zy==-1)//判斷運動又有方向
if(scr[q][w-1]==3||w-1==0)
{
scr[q][w-1]=0;
zy=-zy;
b=1;//用來確認是否敲打左右上下的方塊
}
if(sx==1)
if(scr[q-1][w]==3||q-1==0)
{
scr[q-1][w]=0;
sx=-sx;
b=1;
}
if(sx==-1)
if(scr[q+1][w]==3||q+1==21)
{
if(scr[q+1][w]==3)
{scr[q+1][w]=0;
sx=-sx;
b=1;
}
if(q+1==21)
{if(scr[q+1][w]==1)
sx=-sx;
else
{
printf("lose!!!!!!退出游戲");
if(getch())
main();
}
}
}
if(b==0)//斜的磚塊
{
if(zy==1sx==1)
if(scr[q-1][w+1]==3)
{
scr[q-1][w+1]=0;
zy=-zy;
sx=-sx;
}
if(zy==-1sx==1)
if(scr[q-1][w-1]==3)
{
scr[q-1][w-1]=0;
zy=-zy;
sx=-sx;
}
if(zy==1sx==-1)
if(scr[q+1][w+1]==3)
{
scr[q+1][w+1]=0;
zy=-zy;
sx=-sx;
}
if(zy==-1sx==-1)
if(scr[q+1][w-1]==3)
{
scr[q+1][w-1]=0;
zy=-zy;
sx=-sx;
}//斜磚完畢
}
}
void moveqiu(void)
{
scr[q][w]=0;//使原來的球位置為0,并建立新的球位置
if(sx==1zy==1)
{
q--;w++;
}
if(sx==1zy==-1)
{
q--;w--;
}
if(sx==-1zy==1)
{
q++;w++;
}
if(sx==-1zy==-1)
{
q++;w--;
}
scr[q][w]=2;
}
void printf(void)
{
int i, j;
system("cls");
for(i=0;i22;i++)
{
for(j=0;j50;j++)
{
if(scr[i][j]==0)printf(" ");
if(scr[i][j]==1)printf("\3");
if(scr[i][j]==2)printf("\4");
if(scr[i][j]==3)printf("\5");
if(scr[i][j]==4)printf("_");
if(j==49)
printf("|\n");
}
}
}
void menu(void)
{
q=14, w=30, ban=20, score=10, sx=-1 , zy=-1 ,speed=1, chang=30;memset(scr,0, sizeof(int)*1100);
system("cls");
printf("A向左,D向右,W暫停\n開始游戲:任意鍵\n ");
if(getch()) printf("aaaaaa");
}
這個貌似沒什么難度。。。我自己寫了一個
打磚塊
的東西。。和這個差不多了。。
發(fā)你QQ
里邊
,你看看。。呵呵。。。、期待交流!
QQ:279794658
要系統(tǒng)地掌握JAVA關(guān)聯(lián)技術(shù),不僅僅是JAVA基礎(chǔ),還有JDBC,JAVAScript,Servlet,JSP,JAVA框架等等,這些都要學習的。建議你在熟悉掌握JAVA基礎(chǔ)知識的前提下,以這個順利來學習吧:
JDBC--SERVLET--JSP--JAVA框架、、、、個人建議,僅供參考。
祝你成功~~
幻想游戲合集。你搜打磚塊,幻想游戲中的七寶彈球。
你下載一個應用寶,搜索名稱就可以找到了,里面還有很多好玩的游戲,都是官網(wǎng)的。
幻想游戲是好玩的益智休閑游戲合集,在繁忙的工作、學習后,玩一會小游戲,既不會陷入其中,又能放松身心,一舉兩得。適合的人群也非常多,深得上班族、學生、及中老年朋友的喜愛。