user2148492
user2148492

Reputation: 11

WPF MiniGame Project - using two key events in the same time

I have a mini game project to do in WPF c#.

The game is about shooting and most of the game is almost done.

The problem is that I'm using KeyDown event for move up and down, and need also to fire with the space key.

every thing works fine until i'm trying to move up or down and also try to shot. I tried to put the fire event in the KeyUp, but still, when moving and shot together its just dont work.

please ley me know if you have any ideas for that.

BTW, I know WPF dosnt meant to creat games, but its has to be done in WPF.

Thanks!

Upvotes: 0

Views: 620

Answers (1)

mathieu
mathieu

Reputation: 31202

Set booleans like IsMovingUp, IsFiring, and so on to true in the KeyDown event, and mark the events as handled. Set those booleans to false on KeyUp event.

Then in your main game loop, you can check the booleans and act accordingly.

Upvotes: 0

Related Questions