Why does this keep happening? I research it and know of them helps. Codes:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Security.Policy;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace Pratice
{
public class CharacterClass
{
public Texture2D texture;
public Vector2 position, velocity;
public Rectangle SourceRect;
public string path;
public bool HasJumped;
public CharacterClass()
{
HasJumped = false;
position = new Vector2();
texture = null;
}
public void Initialize()
{
}
public void LoadContent(ContentManager Content)
{
path = "Character/BlueAnvil";
texture = Content.Load<Texture2D>(path);
}
public void Update(GameTime gameTime)
{
position += velocity;
//input Controls
KeyboardState keyState = Keyboard.GetState();
if (keyState.IsKeyDown(Keys.A))
position.X -= 5f;
if (keyState.IsKeyDown(Keys.D))
position.X = 5f;
if (keyState.IsKeyDown(Keys.Space) && HasJumped == false)
{
position.Y -= 10f;
velocity.Y = -5f;
HasJumped = true;
}
if (HasJumped == true)
{
float i = 1;
velocity.Y += 0.15f*i;
}
if (position.Y + texture.Height >= 450)
HasJumped = false;
if (HasJumped == false)
velocity.Y = 0f;
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(texture, position, Color.White);
}
}
}
I need get this fix so I can remember it. Understand to how to do this I'll need help to do it. So I need help, to understand what I'm doing wrong.