46 lines
997 B
C
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--;
|
|
}
|
|
}
|
|
|
|
} |