游戏之 空中接球。。。。。
来源:互联网 发布:iapp怎么制作软件 编辑:程序博客网 时间:2024/04/29 23:22
感想:
从最先学的球接触面使之反弹的简单小程序(额,,应该是几句代码),再到设计的一个小游戏(额,,其实也就是多了点操作的)。其目的在于两点。一是巩固原学过的东西且在借助游戏增加功能的同时学习引用新的东西,二是借助游戏的设计提升自己的设计性(,,虽然并没有牛逼的东西,,)但初学嘛,什么都会是最有用的,多多益善。。。
内容:
在最原始的让球能够在遇到边缘的时候能反弹会来的基础上,增加了一些具有操作功能的东西,如 ,,,,,移动,界面,加速,时间,,,,等等简单的东西。
代码:
public partial class Form1 : Form { int ox, oy; int a = 3; int step = 30; Random d = new Random(); int i = 0 ; public Form1() { InitializeComponent(); label2.Text = "■■■■■"; button1.Text = "start"; int[] array = { - 1,1 }; oy = array[d.Next(2)]; ox = array[d.Next(2)]; textBox1.Visible = false; label1.Text = "ready"; label3.Text = "now time:"; label4.Text = "游戏说明\n 本游戏通过实现移动挡板来让黑点反弹而\n不掉下去,目标:看谁坚持更久时间,也\n可以改变速度增加挑战性.欢迎来挑战\n游戏操作说明\n 进入游戏请按w键,a,d分别控制\n左右移动方向。游戏默认为最慢的速度若\n要更改速度,请单击不同难度的按键或按\nz,x,c来实现简单,中等,困难的难\n度的增加。退出游戏按q键。"; } private void Form1_Load(object sender, EventArgs e) { this.KeyPreview = true; } private void button1_Click(object sender, EventArgs e) { //以下注释为开挂软件。取消注释即可。哈哈哈 //if (timer1.Enabled) // timer1.Stop(); //else timer1.Start(); label4.Text = ""; label2.Location = new Point(175, 234); timer2.Start(); i = 0; } private void timer1_Tick(object sender, EventArgs e) { //up if (oy == -1 && pictureBox1.Location.Y <= 0) oy = 1; //right if ((pictureBox1.Location.X + pictureBox1.Width >= this.ClientRectangle.Width) && ox == 1) ox = -1; //left if (pictureBox1.Location.X <= 0 && ox == -1) ox = 1; //down if (oy == 1 && (pictureBox1.Location.Y + pictureBox1.Size.Height + 10 >= label2.Location.Y) && (pictureBox1.Location.X + 5 <= label2.Location.X + label2.Size.Width) && (label2.Location.X <= pictureBox1.Location.X)) oy = -1; //出界 if (pictureBox1.Location.Y >= label2.Location.Y) { pictureBox1.Location = new Point(150 , 10); timer1.Stop(); timer2.Stop(); MessageBox.Show("你输了,垃圾"); } pictureBox1.Location = new Point(pictureBox1.Location.X + ox * a, pictureBox1.Location.Y + oy * a); } private void Form1_KeyPress(object sender, KeyPressEventArgs e) { //向左移动 if (e.KeyChar == 'a') label2.Location = new Point(label2.Location.X - step, label2.Location.Y); //向右移动 if (e.KeyChar == 'd') label2.Location = new Point(label2.Location.X + step, label2.Location.Y); //开始键 if (e.KeyChar == 'w') button1_Click(null, null); //调试简单速度 if (e.KeyChar == 'z') button3_Click(null, null); //调试中等速度 if (e.KeyChar == 'x') button4_Click(null, null); //调试困难速度 if (e.KeyChar == 'c') button5_Click(null, null); //退出游戏 if (e.KeyChar == 'q') button6_Click(null, null); } private void button3_Click(object sender, EventArgs e) { a = 3; step = 30; int[] array = { -1, 1 }; oy = array[d.Next(2)]; ox = array[d.Next(2)]; } private void button4_Click(object sender, EventArgs e) { a = 4; step = 40; int[] array = { -1, 1 }; oy = array[d.Next(2)]; ox = array[d.Next(2)]; } private void button5_Click(object sender, EventArgs e) { a = 5; step = 50; int[] array = { -1, 1 }; oy = array[d.Next(2)]; ox = array[d.Next(2)]; } private void button6_Click(object sender, EventArgs e) { Application.Exit(); } private void timer2_Tick(object sender, EventArgs e) { i = i + 1; label1.Text = i.ToString(); } }
效果图如下:
目的:
就这样咯。。。。。简单,益操作了。
2 0
- 游戏之 空中接球。。。。。
- 游戏盒子接球
- 游戏盒子接球最终版
- 汇编语言编写的一个“接球游戏”
- .net 制作的一个接球游戏
- 空中邮递员游戏源码
- Scratch儿童项目式编程--接球游戏 Scratch children program programming
- 【VC++游戏开发#三】2D篇 —— 游戏之一:空中大战(SpaceWar)
- 黑马程序员----java编程之空中网面试题
- 《黑马程序员》 空中网面试题之第一题
- Python pygame 接球的小游戏
- CC2540 CC2541 蓝牙4.0BLE开发板实现 空中飞鼠、体感游戏手柄【多图】
- 空中财富
- 空中打击
- 空中接口
- 空中花园
- 空中下载
- 空中键盘
- 如何使用火狐浏览器更方便快捷的调试程序
- BZOJ 2064 分裂
- C#:如何解决WebBrowser.DocumentCompleted事件的多次调用
- hdu 2089 数位dp入门
- throw new RuntimeException
- 游戏之 空中接球。。。。。
- osx系统git下载地址
- php namescpace 命名空间use引入文件
- CODEVS 1214线段覆盖
- POJ 3304 (计算几何)
- 如何理解左操作数必须为左值
- hexo d后 ERROR Deployer not found: git
- Cookie学习
- Java List的equals方法学习