public override void GameLogic() { // This runs every frame and handles game logic Player player = (Player)GetObjectByName("Player"); SpriteComponent playerSpriteComp = (SpriteComponent)player.GetComponent("SpriteComponent"); GameObject GameResTextObj = GetUIObjectByName("GameRenderTextObj"); TextComponent GameResTextObjComp = (TextComponent)GameResTextObj.GetComponent("TextComponent"); GameResTextObjComp.SetText("Render Width: " + GameResolutionWidth.ToString() + ", Render Height: " + GameResolutionHeight.ToString()); GameObject WindowSizeTextObj = GetUIObjectByName("WindowSizeTextObj"); TextComponent WindowSizeTextObjComp = (TextComponent)WindowSizeTextObj.GetComponent("TextComponent"); WindowSizeTextObjComp.SetText("Window Width: " + WindowWidth.ToString() + ", Render Height: " + WindowHeight.ToString()); // Handle Key Presses if (PressedKeys.Count > 0) { for (int i = 0; i < PressedKeys.Count; i++) { //Keys currentKeyCode = PressedKeys[i]; //printText(EngineClass.debugType.Debug, PressedKeys[i].ToString()); if (PressedKeys[i] == Keys.W) { player.moveUp(60); //playerSpriteComp.SetImageRotation(Rotation.Up); } // REMOVED S to go down because gravity pulls the player down //else if (PressedKeys[i] == Keys.S || PressedKeys[i] == Keys.Down) //{ // player.moveDown(playerSpeed); // //playerSpriteComp.SetImageRotation(Rotation.Down); //} if (PressedKeys[i] == Keys.A) { player.moveLeft(playerSpeed); playerSpriteComp.SetImageRotation(HRotation.Left, VRotation.Up); } else if (PressedKeys[i] == Keys.D) { player.moveRight(playerSpeed); playerSpriteComp.SetImageRotation(HRotation.Right, VRotation.Up); } if (PressedKeys[i] == Keys.Up) { GlobalCoords[1] += 10; } if (PressedKeys[i] == Keys.Down) { GlobalCoords[1] -= 10; } if (PressedKeys[i] == Keys.Left) { GlobalCoords[0] += 10; } if (PressedKeys[i] == Keys.Right) { GlobalCoords[0] -= 10; } if (PressedKeys[i] == Keys.O) { GlobalScale[0] += (float)0.25; GlobalScale[1] += (float)0.25; //PrintText(debugType.Error, "GlobalScale X = " + GlobalScale[0].ToString() + ", Y = " + GlobalScale[1].ToString()); } else if (PressedKeys[i] == Keys.P) { GlobalScale[0] -= (float)0.25; GlobalScale[1] -= (float)0.25; //PrintText(debugType.Error, "GlobalScale X = " + GlobalScale[0].ToString() + ", Y = " + GlobalScale[1].ToString()); } //printText(debugType.Debug, player.x.ToString()); //printText(debugType.Debug, player.y.ToString()); } PressedKeys.Clear(); // Handle Collision //if (player.GetX() + player.GetWidth() > GetCanvasWidth()) //{ // player.x = GetCanvasWidth() - player.width; //} //else if (player.x < 0) //{ // player.x = 0; //} //if (player.y + player.height > GetCanvasHeight()) //{ // player.y = GetCanvasHeight() - player.height; //} //else if (player.y < 0) //{ // player.y = 0; //} } }