Quantcast
Channel: Recent Discussions — shoryuken
Viewing all articles
Browse latest Browse all 45982

Eat. Sleep. Code: The Computer Programming Thread, Ver. 010

$
0
0
It looks like my old thread disappeared, so here's a new one for all the coders out there. Use this thread for anything relating to programming, especially if you're looking for help. Speaking of which...

I'm in the middle of tweaking a game I made for Windows 7 phones using XNA, and I'm trying to make the controls more precise. In my game, I move a ball around by sliding the cursor (I'm using the phone emulator). Currently, there are a few problems:
  1. The ball moves a bit too much when I make even slight movements
  2. If I slide in a direction when the cursor is not on the ball, the ball will move in that direction. The ball should move only when the cursor is on the ball.
I think I can figure out #2 fairly quickly as there's a way to get the position of where the user touched the screen. #1 is a bit more troublesome. I do have a variable to adjust the slide distance before any movement is registered, but I don't think that's enough. I'll try increasing the slide distance further and see where that goes. Here's the code I'm using:
Spoiler:
protected override void SetupInputs()   //TODO: make controls good!
        {
            float slideDistance = 20.0f;

            //Code for sliding to the left
            input.AddTouchSlideInput(ActionMoveLeft, Input.Direction.Left, slideDistance);
            //input.AddTouchGestureInput(ActionMoveRight, GestureType.Tap, ScreenRightHalf);

            //Code for sliding to the right
            input.AddTouchSlideInput(ActionMoveRight, Input.Direction.Right, slideDistance);
            //input.AddTouchGestureInput(ActionMoveLeft, GestureType.Tap, ScreenLeftHalf);

            //Code for sliding up
            input.AddTouchSlideInput(ActionMoveUp, Input.Direction.Up, slideDistance);

            //Code for sliding down
            input.AddTouchSlideInput(ActionMoveDown, Input.Direction.Down, slideDistance);

            //Code for restarting level
            input.AddTouchGestureInput(ActionRestart, GestureType.Tap, restartButton.TouchArea);
        }

Viewing all articles
Browse latest Browse all 45982

Trending Articles