I'm working in Xna 4.0 and iwant to make a program that uses the same code in 2 different windows. What i want out of this is that one player plays in one window and the other player to play in the second window.

So i have 2 different questions:

Is it possible to use 2 windows for the same program?

Is it possible for 1 window to have focus on one controller and the other window on the other?

  • \$\begingroup\$ That's definitely something that can be implemented using networking, with the added benefit that it scales over a network. But there might me a more straightforward way. \$\endgroup\$ – Laurent Couvidou May 21 '12 at 9:39
  • 2
    \$\begingroup\$ Why don't you let the main window accept both inputs and just split the output over 2 windows? \$\endgroup\$ – Hackworth May 21 '12 at 10:57

Xna does not work well with two active window forms running xna code at same time...

You should work with one window splitted in two viewports.

Each xbox game controller has its own index, one will be playerindex1 and the other playerindex2, this way you can identify which controller is related to a player/viewport.

  • 1
    \$\begingroup\$ my question was if it worked. Not if it worked well... \$\endgroup\$ – Eric Nilsson May 23 '12 at 8:12

What you're asking to do is possible, but the results are not necessarily pretty. Keep in mind that with Windows, you can only have one application being 'focused' on at one time. This means that your game will need to accept updates while out of focus, since both players cannot have a focused window at the same time. Generally, you want to avoid this in favor of pausing the game whenever the window handle tells it that the player had to minimize it for some reason.

What might be a better (and simpler) idea is to do traditional 'split-screen' co-op/head-to-head. Why exactly do you need two separate windows? Perhaps there is an alternative method.

  • \$\begingroup\$ I can think of many GUI uses for several windows. Instead of using ingame moveable frames you create separate windows and let the user mix, match and resize them. \$\endgroup\$ – MLProgrammer-CiM May 21 '12 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.