I am working on a windows form application that draws two tanks and bullets. my question is how do I get the tanks to fire the bullets in a parabolic fashion. here is my code
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 WindowsFormsApp13
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
int x1 = 525;
int x2 = 20;
float y1 = 405.0f;
private void Form1_Paint(object sender, PaintEventArgs e)
{
Image myImage = Image.FromFile("tankspriteone.png");
e.Graphics.DrawImage(myImage, x1, 405);
Image myImage_two = Image.FromFile("tanksprite.png");
e.Graphics.DrawImage(myImage_two, x2, 405);
Image myImage_three = Image.FromFile("bkgnd.png");
for(int i=0; i<=580;i+=20)
{
e.Graphics.DrawImage(myImage_three, i, 425);
}
Image myImage_four = Image.FromFile("tankbullet.png");
e.Graphics.DrawImage(myImage_four, x2+40, y1);
Image myImage_five = Image.FromFile("tankbulletone.png");
e.Graphics.DrawImage(myImage_five, x1-5, y1);
}
private void button1_Click(object sender, EventArgs e)
{
x1 -= 5;
Invalidate();
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
private void button2_Click(object sender, EventArgs e)
{
x1 += 5;
Invalidate();
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
private void button3_Click(object sender, EventArgs e)
{
x2 -= 5;
Invalidate();
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
private void button4_Click(object sender, EventArgs e)
{
x2 += 5;
Invalidate();
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
private void button6_Click(object sender, EventArgs e)
{
x1 -= 5;
y1 = (-0.5f) * (x1 * x1) + 35.0f;
Invalidate();
}
private void button5_Click(object sender, EventArgs e)
{
x2 += 5;
Invalidate();
}
}
}