/*
* Copyright 2023, Ali Arya
* Anyone Can Code: Algorithmic Thinking
* Example 4.4c
*/

#include "Main.h"

int main(int argc, char* argv[])
{
	/////////////////////////////////////////////////////////////////
	// INIT part of the game
	// things that are done only once at the start (initialization)
	/////////////////////////////////////////////////////////////////

	//init SDL library and graphics window
	SDLX_Init("Image", 640, 480, true);

	//get the image
	int imgX = 200;
	int imgY = 200;
	SDLX_Bitmap* img = SDLX_LoadBitmap("Prize.bmp");

	//image dimensions
	int w = img->width;
	int h = img->height;

	//color
	SDLX_Color c;
	c.r = c.g = c.b = 0;

	//loop
	for(int i=0; i < w; i++)
		for (int j = 0; j < h; j++)
		{
			SDLX_PutPixel(img, i, j, &c);
		}
	//draw
	SDLX_DrawBitmap(img, imgX, imgY);
	//update the screen. Needed for SDL/SDLX
	SDLX_Render();

	bool done = false;
	while (!done)
	{
		SDLX_Event e;
		//keyboard events
		if (SDLX_PollEvent(&e))
		{
			if (e.type == SDL_KEYDOWN)
			{
				//press escape to end the game
				if (e.keycode == SDLK_ESCAPE)
					done = true;
			}
		}
	}

	return 0;
}

