raycast start
This commit is contained in:
21
code/first.c
21
code/first.c
@@ -9,6 +9,7 @@
|
||||
#include "vulkan/core.h"
|
||||
|
||||
#include "game/impl/player.c"
|
||||
#include "game/impl/aabb.c"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@@ -34,11 +35,31 @@ int main(int argc, char **argv)
|
||||
Player player;
|
||||
player.pos.x = 0;
|
||||
player.pos.y = 0;
|
||||
AABB a;
|
||||
a.pos.x = 10;
|
||||
a.pos.y = 10;
|
||||
a.size.x = 10;
|
||||
a.size.y = 10;
|
||||
while (running)
|
||||
{
|
||||
SDL_Event e;
|
||||
while (SDL_PollEvent(&e))
|
||||
{
|
||||
SDL_MouseButtonEvent mouseBtn = e.button;
|
||||
if (mouseBtn.clicks == 1)
|
||||
{
|
||||
V2f point;
|
||||
point.x = mouseBtn.x;
|
||||
point.y = mouseBtn.y;
|
||||
if (AABB_Slab(player.pos, point, a))
|
||||
{
|
||||
printf("hit");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("miss");
|
||||
}
|
||||
}
|
||||
PlayerUpdate(&e, &player);
|
||||
if (e.type == SDL_EVENT_QUIT)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user