どうすれば毎回同じジャンプができますか?
using System;
using System.Diagnostics;
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 jump002
{
public partial class Form1 : Form
{
Stopwatch sw = new Stopwatch();
PictureBox Player = new PictureBox();
int x, y;
double time,time2,timer3,y_jump;
Decimal Round;
Timer timer1 = new Timer();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Set();
TimerSet();
PlayerSet();
}
void Set()
{
this.Width = 900;
this.Height = 600;
time = 0.70;
}
void TimerSet()
{
timer1.Enabled = true;
timer1.Interval = 1;
timer1.Tick += new EventHandler(Jump);
}
void PlayerSet()
{
x = 45;
y = 450;
Player.BackColor = Color.Red;
Player.Height = 64;
Player.Width = 64;
Player.Location = new Point(x, y);
Controls.Add(Player);
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
sw.Restart();
}
void Jump(object sender,EventArgs e)
{
time2 = (double)sw.ElapsedTicks
/ (double)Stopwatch.Frequency;
Round = (Decimal)Math.Round(time2, 2, MidpointRounding.AwayFromZero);
timer3 = time - (double)Round;
y_jump = 980 * (timer3 * timer3);
y = (int)y_jump;
x++;
Player.Location = new Point(x,y);
Controls.Add(Player);
}
}
}