/*
Raylib example file.
This is an example main file for a simple raylib project.
Use this as a starting point or replace it with your code.

by Jeffery Myers is marked with CC0 1.0. To view a copy of this license, visit https://creativecommons.org/publicdomain/zero/1.0/

*/

#include "raylib.h"

#include "resource_dir.h"	// utility header for SearchAndSetResourceDir
#include <stdlib.h>

typedef struct Player {
    Vector2 position;
    Vector2 size;
    int life;
} Player;

static Player player = {0};

static void characterMovement(void);


int main ()
{
	// Tell the window to use vsync and work on high DPI displays
	SetConfigFlags(FLAG_VSYNC_HINT | FLAG_WINDOW_HIGHDPI);

	// Create the window and OpenGL context
	InitWindow(800, 600, "Hello Emi");

	// Utility function from resource_dir.h to find the resources folder and set it as the current working directory so we can load from it
	SearchAndSetResourceDir("resources");

	// Load a texture from the resources directory
	Image image = LoadImage("mrsh.png");
	Texture2D emi = LoadTextureFromImage(image);
	UnloadImage(image);
	
	int HorizontalPosition = 400;
	int VerticalPosition = 300;

	// game loop
	while (!WindowShouldClose())		// run the loop until the user presses ESCAPE or presses the Close button on the window
	{
		// drawing
		BeginDrawing();

		// Setup the back buffer for drawing (clear color and depth buffers)
		ClearBackground(BLACK);

		// DrawRectangle(HorizontalPosition, VerticalPosition, 10, 10, BLUE);
		DrawTexture(emi, player.position.x, player.position.y, WHITE);

		characterMovement();


		EndDrawing();
	}

	// cleanup
	// unload our texture so it can be cleaned up
	UnloadTexture(emi);

	// destroy the window and cleanup the OpenGL context
	CloseWindow();
	return 0;
}
void characterMovement(void){

		//up
		if (IsKeyDown(74)  ) {
			// draw some text using the default font
			player.position.y = player.position.y+10;
		};
		//down
		if (IsKeyDown(75) ) {
			player.position.y = player.position.y-10;
			// draw some text using the default font
		};
		//left
		if (IsKeyDown(72) ) {
			player.position.x = player.position.x-10;
			// draw some text using the default font
		};
		//right
		if (IsKeyDown(76)) {
			 player.position.x = player.position.x+10;
			// draw some text using the default font
		};
	
}