Files
ConsoleMenu/player_functions.c
felicianoa237 806041eaaa Updated code
2025-03-24 09:02:39 -05:00

46 lines
997 B
C

//
// Created by tony on 11/27/2024.
//
#include <windows.h>
#include <stdbool.h>
#include <stdio.h>
#include "entities.h"
static void getUserInput(struct Entity *pPlayer, SMALL_RECT *pScreenBounds)
{
// Check for specific keyboard keys
if (GetAsyncKeyState(VK_UP))
{
pPlayer->position.Y--;
if (pPlayer->position.Y < pScreenBounds->Top)
{
pPlayer->position.Y++;
}
}
if (GetAsyncKeyState(VK_DOWN))
{
pPlayer->position.Y++;
if (pPlayer->position.Y > pScreenBounds->Bottom)
{
pPlayer->position.Y--;
}
}
if (GetAsyncKeyState(VK_LEFT))
{
pPlayer->position.X--;
if (pPlayer->position.X < pScreenBounds->Left)
{
pPlayer->position.X++;
}
}
if (GetAsyncKeyState(VK_RIGHT))
{
pPlayer->position.X++;
if (pPlayer->position.X > pScreenBounds->Right)
{
pPlayer->position.X--;
}
}
}