Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Kasc

Member Since 07 Sep 2011
Offline Last Active Mar 02 2013 01:27 PM

Posts I've Made

In Topic: Have done XNA/C#, what's next?

26 February 2013 - 08:28 PM

I have known about Monogame for a while and it did look interested, however the majority of my coding knowledge has been gained through using XNA it seemed very overwhelming to use since there is not proper documentation for beginners like there is for XNA.

 

Also, the last time I queried that line thought they suggested to build your game within XNA/Visual Studio and just port it over (HOW you did that wasn't obvious); is that not a good thing to do anymore?


In Topic: XNA custom gamepads in Visual Studio

03 August 2012 - 08:21 AM

Use SlimDX's direct input library, you access the joystick like so:

[source lang="csharp"] Joystick joystick; int joystickButtonCount; int joystickAxesCount; JoystickState joystickState, oldJoystickState; public Game() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; CreateDevice(); } ... protected override void Update(GameTime gameTime) { joystickState = joystick.GetCurrentState(); bool[] buttons = joystickState.GetButtons(); Console.Clear(); Console.WriteLine("Using device: {0}\nButton count: {1}\nAxes count: {2}\n", joystick.Information.ProductName, joystickButtonCount, joystickAxesCount); for (int i = 0; i < joystickButtonCount; i++) { Console.WriteLine("{0}: {1}", i + 1, buttons[i]); } } void CreateDevice() { DirectInput dinput = new DirectInput(); foreach (DeviceInstance device in dinput.GetDevices(DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly)) { try { joystick = new Joystick(dinput, device.InstanceGuid); joystickAxesCount = joystick.Capabilities.AxesCount; joystickButtonCount = joystick.Capabilities.ButtonCount; break; } catch { } } if (joystick == null) { Console.WriteLine("No devices"); return; ; } joystick.Acquire(); foreach (DeviceObjectInstance deviceObject in joystick.GetObjects()) { if ((deviceObject.ObjectType & ObjectDeviceType.Axis) != 0) joystick.GetObjectPropertiesById((int)deviceObject.ObjectType).SetRange(-1000, 1000); } }[/source]

Getting your axis information is a little different, if you do joystickState{dot} intellisense will show you a lot of properties, the ones with X, Y and Z on the end will give you your axis info, so to find out which one your joystick uses you'll have to print them all the console and see.

EDIT:

These two lines:

joystickAxesCount = joystick.Capabilities.AxesCount;
joystickButtonCount = joystick.Capabilities.ButtonCount;

may cause you to hang for a few seconds, so you may want to create your device on a seperate thread so your main game loop won't stall until it responds. You could also cut this out entirely and loop over the entire bool[] buttons array which I think is of size 128.

In Topic: Achieving oldschool platformer physics

02 August 2012 - 06:09 AM

Whilst looking for the exact same thing yourself, I came across Wildybunny's tutorials but find they didn't suit my needs because I wanted to have slopes that responded correctly.

What I ended implementing was something called SAT (Seperate axis theorem), which is probably half of what Box2D uses, just without accounting for friction, gravity, acceleration etc. for a full blown rigid body simulator.

If you want to have a crack at doing this, I used the tutorials on the following youtube video (description):

I actually think these are originally hosted on here somewhere, but this is where I found them. The only problem I can foresee of going down this route is that if you haven't got a grasp of the theory itself, trying to debug any thing, or expand upon the system for your needs will be hard if not impossible.

Edit: I don't know what language/framework you are using as I have never really looked properly at Box2D, I only know what it does. These tutorials were meant for C++, but I was able to implement it into C#/XNA without much trouble even though I have never learnt C++.

PARTNERS