Help - Search - Members - Calendar
Full Version: Hotkeys In C#?
BleepingComputer.com > Software > Programming
   
Wolfy87
i need to assign w, a, s, d, to move a image box round the screen by pressing i.e... W will add 6 to the Y axsis. Can anyone help?
groovicus
Sure. What research have you done so far, and what does your code look like. Part of learning how to program is being able to use your favorite search engine in order to find what you need. Try that first.
Wolfy87
Well thats just it, every were i look the awnsers are proboly stairing me in the face but i just cant understand it so im thinking of trying something like this but it dosent seem to work but here it is anyway...

private void W_Click(object sender, EventArgs e)
{
//Moves Char up the Map.
pictureBox3.Location = (187, 183+1);
}

I am using a label named &W as the button...

Can i use this sort of code for i want it to be If the char is in grass (whitch will be placed around the map) then there will be a random event where it chosses a random number between for example 1 and 6 and if its a 1 or 4 nothing happens but if its a 5 or 6 you have to fight something. i have that planned but how will i tell it to activate this process. would it be something like this...

If pictureBox3.Location = (201, 178) then....i have the bit after that all worked out but how do i use the locations??

i have alot more code and i will have to do the same for asd but this is how i started then i came to a grinding halt, it worked on my scoring system on my shooting game though...

Also how do i make a form pop up due to a click of a button in C# because it worked like this in VB and wont work in here...
Form2.Show();
Thats all i got :s
groovicus
I think you should look a this:
http://creators.xna.com/en-US/education/gettingstarted
Wolfy87
But i am using C# not xna? i dont get it, i will gladly watch it but are they a compleatly different laguage?

Ah! i see it uses C# but this is 2005 i have 2008 will that be a problem?
Wolfy87
I am downloading XNA 2.0 now and i spose its a sort of mod for C# or an add on and dose it explain hot keys in the videos then?... Thanks for all you help, Ollie
groovicus
It is a development environment specifically for creating games using C#. THe video tutorial I linked you to should answer questions about event listeners, as well as a few other things. Languages do not have 'mods' or 'add-ons'; they have libraries. Some of the stuff is hidden in the background, but if you have a game that you are trying to develop, then do it in the game studio, since it will handle a lot of the details for you. There is also an excellent support forum where you can find all sorts of code, and help.
Wolfy87
ok then thanks and if i learn code from this 2005 can i use it in my own game witch is in 2008?
groovicus
C# is a programming language. The environment that you use to create a program using C# in no way alters the programming language. IF you learn the code in XNA, the code is exactly the same no matter where you use it.
Wolfy87
Thats great, Thankyou all i have to do now is wait for C# 2005 and SP1 to install sad.gif .
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.