用c#回复我的游戏 [英] reply for my game in c#

查看:93
本文介绍了用c#回复我的游戏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好每个我用C#形式写的游戏,我有2个(图片框),他们的形状是汽车,我可以通过键盘和鼠标控制他们。之后我的游戏时间(比如60秒)我想要回复我的游戏这意味着需要对游戏有回复的速度游戏我想要回复谢谢yoooooooooooooooooooooou

hello every one I wrote a game in C# form that I have 2 (picture box) that their shape is car and I can control their by keyboard and mouse.after a time my game over (such as 60 second )I want reply of my game this means that such as need for speed games that have reply for games I want reply of that thank yoooooooooooooooooooooou

推荐答案

为了做一个动作重播 - 这就是我认为你要求的 - 你必须记录汽车所采取的每一个行动 - 如果用户开始向左移动,你必须记录何时,以及多远。如果他开始向左稍微移动,你需要知道什么时候和多少。

或者,你需要记录每辆车的确切路径。即如果你在计时器中绘制/移动它们,那么每个刻度,你必须记录你正在绘制或移动它们的位置。

然后你需要将这些信息反馈到你的游戏中以显示重放 - 如果不了解更多关于你的游戏的话,究竟怎么说很难。







非常抱歉,先生或想念OriginalGriff我可以在记事本文件中记录我的汽车位置,但我明天无法从他们那里读取我必须将这个项目交给我的主人请帮帮我

< br $> b $ b

好​​吧,记事本文件是个坏主意!

看看yiu删除的问题(我在阅读文本信息时遇到问题 [ ^ ])很难弄清楚你是怎么做到的:434 234 567 764 2 38看起来好像它应该是某种坐标,但它们看起来不完整所以很难分辨。



我不知道你是怎么回事实现你的游戏,但我会这样做(至少从一开始)将是每辆车有两个速度:左和前,零是没有离开,正面是一些左,负面是有些权利,等等。

然后我会设置一个(比如说)40毫秒间隔的计时器。每次计时器打勾时,我会将每辆车的速度添加到适当的车辆,并更新图片框X和Y位置。

每次用户移动鼠标/键盘时,都会影响仅适当速度的值。



要对此进行动作重播,我会设置一个List< Point>每辆车,每次我执行计时器Tick事件,我会将当前位置添加到适当的列表。然后,要运行重放,再次设置初始位置,每个Tick,只需使用每个列表中的下一个值作为每辆车的直接位置,而不是使用速度来计算新位置。



再一次,我不知道你是怎么做的,但是你的方案在某些方面可能很相似 - 你应该能够修改它以适应代码的工作方式。 :)
In order to do an "action replay" - which is what I think you are asking for - you would have to record every action taken by the "cars" - if the user starts them moving left, you have to record when, and how far. If he starts them moving slightly less left, again, you need to know when and how much.
Or, you need to record the exact path taken by each car. I.e. if you are drawing/moving them in a timer, then every tick, you must record where you are drawing or moving them to.
You then need to feed this info back into your game to show the replay - exactly how is difficult to say without knowing a lot more about your game.



"very sorry Mr or miss OriginalGriff I can record my cars location in a notepad file but I cannot read from them tomorrow I must deliver this project to my master please help me"


Okay, a notepad file is a bad idea!
Looking at yiu deleted question (I have a problem in reading information from text[^]) it is difficult to work out how you are doing this: "434 234 567 764 238" looks as if it should be coordinates of some kind, but they do not look complete so it is difficult to tell.

I don't know how you are implementing your game, but the way I would do it (at least to start with) would be to have two "velocities" per car: Left and forward, where zero was "no left", positive was "some left" and negative was "some right", and so forth.
I would then set up a timer of (say) 40 milliseconds interval. Each time the timer ticked, I would add the velocity for each car to the appropriate vehicle, and update the picture box X and Y positions.
Each time the user moved the mouse / keyboard, it would affect the value in the appropriate velocity only.

To do an action replay with this, I would set up a List<Point> per car, and each time I executed the timer Tick event, I would add the current position to the appropriate list. Then, to run the replay, set the initial positions again, and each Tick, just use the next value from each list as the direct position for each car rather than using the velocities to calculate a new position.

Again, I don't know how you are doing it, but you scheme is likely to be similar in some respects - you should be able to modify this to fit how you code works. :)


Aslamoalaikum ......我是来自巴基斯坦的Arzoo Ahmed。我为如何在c#中加载图像制作了一个代码。即

问题:

开发一个C#应用程序,考虑以下三种形式;

1.主表单

2 Form1

3. Form2

我在PictureF和MainForm中的一个按钮。按下按钮Form1必须显示。 Form1必须有两个按钮(button1和按钮2)。按下按钮1时,必须加载图像并以主窗体显示。按下按钮2,必须显示form2。 Form2必须至少有2个文本框和一个按钮。用户可以在文本框中输入文本,该文本框必须以表单2中的任何控件显示。一旦文本显示为form2,则隐藏表单。此外,按下表格1中的两个按钮,它也必须关闭。完成任务后,只有主表格必须可见。



使用系统;

使用System.Collections.Generic;

使用System.ComponentModel;

使用System.Data;

使用System.Drawing;

使用System.Linq;

使用System.Text;

使用System.Threading.Tasks;

使用System.Windows.Forms;



名称空间Lab_8 {

公共部分类Form1:表格

{

public Form1()

{

InitializeComponent();

}



private void Display_Click(object sender,EventArgs e )

{

Form2 y = new Form2();

y.Show();


使用System.Collections.Generic ;

使用System.ComponentModel;

使用System.Data;

使用System.Drawing;

使用System.Linq;

使用System.Text;

使用System.Threading。任务;

使用System.Windows.Forms;



名称空间Lab_8

{

public partial class Form2:Form

{

PictureBox pb;

public Form2()

{

InitializeComponent();

}



private void button2_Click(object sender,EventArgs e)

{

Form3 d = new Form3();

d.Show();

}



private void button1_Click(object sender,EventArgs e)

{

OpenFileDialog dlg = new OpenFileDialog();

dlg.Title =打开照片;

dlg.Filter =jpg文件(* .jpg)| * .jpg |所有文件(*。*)| *。*;

if(dlg.ShowDialog() == DialogResult.OK)

{

pb.Image = new Bitmap(dlg.OpenFile());

}

dlg.Dispose();

}

}

}

使用System;

使用System.Collections.Generic;

使用System.ComponentModel;

使用System.Data;

使用System。绘图;

使用System.Linq;

使用System.Text;

使用System.Threading.Tasks;

使用System.Windows.Forms;



命名空间Lab_8

{

公共部分类Form3:表单< br $>
{

public Form3()

{

InitializeComponent();

}



private void Hide_Click(object sender,EventArgs e)

{

this.Hide(); < br $>
}



private void button1_Click(ob ject发送者,EventArgs e)

{

string s =;

s = s + textBox1.Text +\ n;

s = s + textBox2.Text +\ n;

richTextBox1.Text = s;

}

}

}
Aslamoalaikum... I am Arzoo Ahmed From Pakistan. I made a code for how to load an image in c#. i.e
Question:
Develop a C# application, consider following three forms;
1. Main Form
2. Form1
3. Form2
I take PictureBox and a button in MainForm. On press of button Form1 must display. Form1 must have two buttons (button1 and button 2). On press of button1, an image must be loaded and displayed in Main Form. On Press on button2, form2 must be displayed. Form2 is required to have at least 2 textboxes and a button. User can enter text in text boxes which must be displayed in any control in form 2. Once the text is displayed form2, hide the form. Further, on press of two buttons in form 1, it must also close. On completion of tasks, only main form must be visible.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Lab_8{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Display_Click(object sender, EventArgs e)
{
Form2 y = new Form2();
y.Show();

}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Lab_8
{
public partial class Form2 : Form
{
PictureBox pb;
public Form2()
{
InitializeComponent();
}

private void button2_Click(object sender, EventArgs e)
{
Form3 d = new Form3();
d.Show();
}

private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Open Photo";
dlg.Filter = "jpg files (*.jpg)|*.jpg|All files (*.*)|*.*";
if (dlg.ShowDialog() == DialogResult.OK)
{
pb.Image = new Bitmap(dlg.OpenFile());
}
dlg.Dispose();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Lab_8
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}

private void Hide_Click(object sender, EventArgs e)
{
this.Hide();
}

private void button1_Click(object sender, EventArgs e)
{
string s = "";
s = s + textBox1.Text + "\n";
s = s + textBox2.Text + "\n";
richTextBox1.Text = s;
}
}
}


这篇关于用c#回复我的游戏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆