Not strong in this :L
Not good with Forms, Events and system.Drawing
Im making a key event draw a new Rectangle when the key is (Down) is pressed, but its not drawing a new rectangle when i press down continuously:
Code:
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
Graphics GE = Graphics.FromHwnd(this.Handle);
Pen PE = new Pen(Color.Black);
Rectangle NE = new Rectangle(15, 15, 20, 50);
if (e.KeyCode == Keys.Down)
{
NE.Y++;
GE.DrawRectangle(PE, NE);
}
}
Can you please point me in the right direction, even though i've probably got this completely wrong :L
Shouldn't this be drawing a new rectangle, but displaced in Y Direction by 1 everytime the Down key is pressed?
EDIT:
Tried doing:
Code:
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
Graphics GE = Graphics.FromHwnd(this.Handle);
Pen PE = new Pen(Color.Black);
Rectangle NE = new Rectangle(15, 15, 20, 50);
GE.DrawRectangle(PE, NE);
if (e.KeyCode == Keys.Down)
{
NE.OffSet(17,17);
}
}
To move the current shape drawn, but it doesn't move at all.
Not strong in this :L
Not good with Forms, Events and system.Drawing
Im making a key event draw a new Rectangle when the key is (Down) is pressed, but its not drawing a new rectangle when i press down continuously:
Code:
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
Graphics GE = Graphics.FromHwnd(this.Handle);
Pen PE = new Pen(Color.Black);
Rectangle NE = new Rectangle(15, 15, 20, 50);
if (e.KeyCode == Keys.Down)
{
NE.Y++;
GE.DrawRectangle(PE, NE);
}
}
Can you please point me in the right direction, even though i've probably got this completely wrong :L
Shouldn't this be drawing a new rectangle, but displaced in Y Direction by 1 everytime the Down key is pressed?
EDIT:
Tried doing:
Code:
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
Graphics GE = Graphics.FromHwnd(this.Handle);
Pen PE = new Pen(Color.Black);
Rectangle NE = new Rectangle(15, 15, 20, 50);
GE.DrawRectangle(PE, NE);
if (e.KeyCode == Keys.Down)
{
NE.OffSet(17,17);
}
}
To move the current shape drawn, but it doesn't move at all.
Try doing this.
Code:
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
Graphics GE = Graphics.FromHwnd(this.Handle);
Pen PE = new Pen(Color.Black);
[B] int X = 10;
int Y = 10;[/B]
Rectangle NE = new Rectangle(15, 15, [B]X, Y[/B]);
if (e.KeyCode == Keys.Down)
{
Y++;
GE.DrawRectangle(PE, NE);
}
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
Graphics GE = Graphics.FromHwnd(this.Handle);
Pen PE = new Pen(Color.Black);
[B] int X = 10;
int Y = 10;[/B]
Rectangle NE = new Rectangle(15, 15, [B]X, Y[/B]);
if (e.KeyCode == Keys.Down)
{
Y++;
GE.DrawRectangle(PE, NE);
}
}
The problem with your code and Ian*'s is that you're both redeclaring and reinstantiating the variables that depend on the Rectangle's location. You may alter those values at the bottom of that method, but you're losing those changes because either your Rectangle variable or your X and Y variables need to be declared at the class level.
It may be more preferable to use the and instead of using the UI's event dispatch thread. may provide you with some useful examples.
Action 6 is drawing near ^^ 03/17/2010 - Dekaron - 9 Replies ::: Welcome to GAMEHI :::
And here i thought it was going to be at the end of march XD
Woot lets go own with our new skills and bust up some new maps ^^
SRO related drawing 01/19/2008 - Silkroad Online - 6 Replies I am making a drawing of a Glaiver, I was just bored and wanted to get peoples opinion, it does not use any of the sro armor, I made up my own items, the glaive is somewhat like the level 100 glaive.
http://img147.imageshack.us/img147/4301/scannedim agedl3.th.jpg
Leave a comment. :)
It is still a drawing in progress, not done yet.
Quality is really low in imageshack, I do not know any other place.
Download attachment, maybe it has better details...