Jump to content
Sign in to follow this  
  • entries
  • comments
  • views

Dual Analog: Target Practice

Sign in to follow this  


[journal dump]

now i know when the joystick is plugged in. again, its not something i can be sure of for more than one, but its ok for this demo for now. now its time to try to get some info out of the joystick and do something with it.

i should probably do things just as the di sample does, and call a GetData() function that loads up a state object every pass through Main. lets add it in. [working]

first, lets change CheckJoystick() to be called JoystickUnplugged() and have it return a bool. then we'll deal with what to do about it in Main. [working] ok, now we do GetData(). [working] ok, it compiles clean. now lets use some of the data. [working] lets set up the axes to go to 1000 like they did in the sample, just for the hell of it. [working] now we'll move the smiley face with state.X and .Y. [working] i have to take a braek for a min. i gotta remember to add a 'got data' thinger to check in the main loop. [away]

got the smiley face moving with the left analog. now we attach the right analog's functionality to the crosshair. the z axis is the right analog's x, and the rz axis is the right analog's y. [working] yup, done. i want to limit the crosshair to only move around in a circle about the smiley. i'll have to check the distance away and force it to the radius i choose. [working]

ok wierd. it limits it to a circle as i wanted it to, but now its doing some wierd stuff.. its skipping all over the place at angles that look like they're right next to one another. i need to rethink this.

suppose the current analog position is further from center than our maxRadius. we just want the angle, right? lets try that instead. [working] well it didn't work any better, but at least i got it to stop being dumb. switch the signs and Sin/Cos positions and i got it. i wonder if i saved any cycles by switching from a one sqrt to an atan2/sin/cos solution.. (doubt it)

i have a choice of things to do right now. i can do the bullet stuff and get a game actually up and running, or i can clean up how i'm doing things a bit and get rid of some of the artifacts we're getting from doing consecutive .Top/.Left changes. i can also fix the centering error - when you let go of the stick, sometimes it doesn't center at 0,0. thats easy to fix, too.

jenn says the jumpiness should be fixed first, so lets do that. the problem is caused by the fact that we're changing .Top and .Left more than once in a single loop, and so the computer has to move it real quick. what we need to do is store the location of the objects seperate from their pictures and then apply the locations after we're done our logic, during the update phase of the main loop. lets seperate out the smiley first. [working]

i did alot of seperating there. anyways, the smiley doesn't jig when you try to push him out of the window now. i need to remember to add a shooty noise when you fire the bullet.. ^_^ the code is cleaner and a bit easier to read. i changed the name of the demo to reflect what its going to be used for: Target Practice.

something else that needs to be done is the game timing, to make it run the same speed, no matter the workload. probably going to need a double buffer going on too - but that might be more than is needed. lets update the crosshair like we did the smiley face. [working] all done. the last thing i want to mention before i take off is that i'm going to want to limit the speed that the face moves in - its not circular like the crosshair is set up to be. i'll fix that too.

so lets make a todo list.
- limit face motion radially, not with cartesian (like crosshairs)
- add timing
- finish actual game >> elaborate <<
- sound effects
- compare atan2-sin-cos vs sqrt methods
- dead-zone the analog sticks

we'll get a start on these things next time. [gone]
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!