INIT
This commit is contained in:
46
player_functions.c
Normal file
46
player_functions.c
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// 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--;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user