i tried this,
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
int carX = 178;
int carY = 161;
public Form1()
{
InitializeComponent();
this.KeyDown += new KeyEventHandler(Form1_KeyDown);
this.KeyUp += new KeyEventHandler(Form1_KeyUp);
}
private void Form1_Load(object sender, EventArgs e)
{
}
void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Up)
{
carY--;
this.carImage.Location = new Point(carX, carY);
}
if (e.KeyCode == Keys.Left)
{
}
}
public static Image RotateImage(Image carImage, float rotationAngle)
{
Bitmap bmp = new Bitmap(carImage.Width, carImage.Height);
Graphics gfx = Graphics.FromImage(bmp);
gfx.TranslateTransform((float)bmp.Width / 2, (float)bmp.Height / 2);
gfx.RotateTransform(rotationAngle);
gfx.TranslateTransform(-(float)bmp.Width / 2, (float)bmp.Height / 2);
gfx.DrawImage(carImage, new Point(0, 0));
return bmp;
}
void Form1_KeyUp(object sender, KeyEventArgs e)
{
while (e.KeyCode == Keys.Up && carY != 161)
{
if (carY > 161)
{
carY--;
}
if (carY < 161)
{
carY++;
}
this.carImage.Location = new Point(carX, carY);
}
}
}
}
but the car (image) does not rotate at all.
So here are my questions.
1. how can i get the car to rotate clockwise when i hit the left arrow key?
2. is it possible to turn the car whilst it is moving forward, if so how?
help is greatly appreciated!!!