I'm currently learning XNA per suggestion from this question's accepted answer:
Where to start writing games, any tutorials or the like?
I have then installed everything to get ready to work with XNA Game Studio 4.0.
General Objective
Writing an Arkanoid-like game. I want to make my ship move when I press either left or right keys.
Code Sample
protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); // TODO: Add your update logic here #if WINDOWS if (Keyboard.GetState().IsKeyDown(Keys.Escape)) this.Exit(); else { if (Keyboard.GetState().IsKeyDown(Keys.Left)) MoveLeft(gameTime); } #endif // Move the sprite around. BounceEnergyBall(gameTime); base.Update(gameTime); } void MoveLeft(GameTime gameTime) { // I'm not sure how to play with the Vector2 object and its position here!... _vausSpacecraftPos /= _vausSpacecraftSpeed.X; // This line makes the spacecraft move diagnol-top-left. } Question
What formula shall I use, or what algorithm shall I consider to make my spaceship move as expected left and right properly?
Thanks for your thoughts! Any clue will be appreciated. I am on my learning curve though I have years of development behind me (already)!