Hi, I'm pretty new to C#, I've made a simple Duck Hunt game, but now I'm trying to creating a new game, called Jail Break. But anyways, what I would like to do is have all my PlayerInput (Keyboard Input) in one Class File instead of the Big Form1.cs Code File being gaint.
I've tried something like this.
Created new Class File called it PlayerInput.cs
In it, I have:
Just a simple Class File, right? now I want in it is what shows up when you do a Event for Keydown in Form1.csCode:using System; using System.Collections.Generic; using System.Text; namespace Jail_Break { class PlayerInput { } }
So what I'm trying to do is have the Form1.cs KeyDown WHOLE CODE in the PlayerInput.cs FileCode:private void Form1_KeyDown(object sender, KeyEventArgs e) { }
Something like this:
and then I would like to call the code either in the:Code:using System; using System.Collections.Generic; using System.Text; namespace Jail_Break { class PlayerInput { private void Form1_KeyDown(object sender, KeyEventArgs e) { Code for KeyDown Here.. .. . . . } } }
Code:public Form1() { InitializeComponent(); Call Code Here . . . . }
or in the Form1_Load Event.
Please someone help, this will make my code alot neater, and i can't figure out how to do something like this, I've never ever used a Created Class before for Events or Other stuff.
Thanks, Wesley




Reply With Quote