private void HandleSideInput(InputManager input) { if (input.LeftMouseButtonPressed) { TryAttack = true; } else { TryAttack = false; } if (input.isKeyHolding(Keys.D)) { VelocityX = _sideSpeed; Mirrored = false; } else if (input.isKeyHolding(Keys.A)) { VelocityX = -_sideSpeed; Mirrored = true; } else { VelocityX = 0; } //_canJump is a variable that allows for doubleJumps if (input.isKeyPressed(Keys.Space) && (!InAir || _canJump)) { //if inAir, player double Jumped, so canJump is now false if (InAir) { _canJump = false; //the double jump is smaller Velocity = new Vector2(VelocityX, -450); } else { Velocity = new Vector2(VelocityX, -630); } } //if R is pressed and the player has picked up the required pickup, perform a superjump else if (input.isKeyPressed(Keys.R) && _canSuperJump) { SuperJump(); } }
private void HandleTopDownInput(InputManager input) { //Highscore test. Als je op H drukt wordt er een random waarde in de highscore lijst gezet met als username Random. //Als dit verplaatst wordt, verplaats dan ook de "using MySql.Data.MySqlClient;" if (input.isKeyPressed(Keys.H)) { //Database initializeren (dit kan ook ergens anders, dan hoef je het niet steeds opnieuw te doen. MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder(); /*builder.Server = SERVER; * builder.UserID = UID; * builder.Password = PASSWORD; * builder.Database = DATABASE;*/ //builder.ConnectionString = "Server="+SERVER+";Database="+DATABASE+";User Id="+UID+";Password="******";"; builder.ConnectionString = "Server=dpstudios.nl;Database=u13357p9566_highscore;Uid=u13357p9566_dps; Password=toeganggeweigerd6;"; String connString = builder.ToString(); builder = null; Console.WriteLine(connString); dbConn = new MySqlConnection(connString); //Einde initializatie //Variabeles die nodig zijn voor de query Random rnd = new Random(); int score = rnd.Next(0, 50); string username = "******"; string userpassword = ""; string hashedpassword = HashSHA1(userpassword); //Score in database zetten QUERY: string query = string.Format("INSERT INTO highscore(username,score) VALUES ('{0}','{1}')", username, score); //Checken of username & wachtwoord in database bestaan: //string query = string.Format("SELECT username FROM users"); //LIMIT 1 WHERE username = '******' //Leestest. //string query = string.Format("SELECT username FROM `users`"); //Checken of username in database bestaat: //string query = string.Format("SELECT * FROM `users` WHERE username = '******' AND hashedpassword = '******'", username, hashedpassword); //public bool isAccountValid //while (reader.Read()) //if (reader["username"].ToString() == username) MySqlCommand cmd = new MySqlCommand(query, dbConn); dbConn.Open(); MySqlDataReader reader = cmd.ExecuteReader(); dbConn.Close(); //Connectie sluiten is belangrijk. } if (input.isKeyHolding(Keys.D)) { VelocityX = _topDownSpeed; Mirrored = false; } else if (input.isKeyHolding(Keys.A)) { VelocityX = -_topDownSpeed; Mirrored = true; } else { VelocityX = 0; } if (input.isKeyHolding(Keys.S)) { VelocityY = _topDownSpeed; } else if (input.isKeyHolding(Keys.W)) { VelocityY = -_topDownSpeed; } else { VelocityY = 0; } }