summaryrefslogtreecommitdiffhomepage
path: root/src/main.cpp
blob: 50ccd4795ed6be1bdc9c10c55dbe33a98bef21db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "raylib.h"
#include "raymath.h"
#include "resources.hpp"
#include "renderer.hpp"
#include "physics.hpp"
#include <iostream>

//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
	// Initialization
	//--------------------------------------------------------------------------------------
	const int screenWidth = 800;
	const int screenHeight = 800;

	InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");

	SetTargetFPS(60);               // Set our game to run at 60 frames-per-second
									//--------------------------------------------------------------------------------------

	auto ship_sprite = Renderer::Sprite("kenneySpaceShooter", (Rectangle){1365,1696,198,188}, (Vector2){19.80/2,18.80/2});
	auto rock_sprite = Renderer::Sprite("kenneySpaceShooter", (Rectangle){0,800,440,442}, (Vector2){44.00/2, 44.20/2});

	// Main game loop
	while (!WindowShouldClose())    // Detect window close button or ESC key
	{
		// Update
		//----------------------------------------------------------------------------------
		// TODO: Update your variables here
		//----------------------------------------------------------------------------------

		// Draw
		//----------------------------------------------------------------------------------
		for (int i = 0; i < 50000; i++) {
			Physics::step(0.001);
		}
		std::cout << std::to_string(Vector2Distance(Physics::ship.position, Physics::rock.position)) << std::endl;
		BeginDrawing();

		ClearBackground(BLACK);

		DrawText("Space!", 190, 200, 20, LIGHTGRAY);
		//DrawTexture(Resources::useTexture("ship"), 0, 0, WHITE);
		ship_sprite.draw(Physics::ship.position.x,Physics::ship.position.y, 0.1);
		rock_sprite.draw(Physics::rock.position.x,Physics::rock.position.y, 0.1);

		EndDrawing();
		//----------------------------------------------------------------------------------
	}

	// De-Initialization
	//--------------------------------------------------------------------------------------
	CloseWindow();        // Close window and OpenGL context
						  //--------------------------------------------------------------------------------------

	return 0;
}