summaryrefslogtreecommitdiffhomepage
path: root/src/main.c
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2024-05-12 17:34:21 -0400
committerrealtradam <[email protected]>2024-05-12 17:34:21 -0400
commit8475767975a0f07507908ba53dba894b97b48795 (patch)
tree4d5bf2f8c49eb92f8d9777e0606d944dca01905d /src/main.c
parentf5311cc940fd94aa70808f19a38581c80b764615 (diff)
downloadtojam2024-8475767975a0f07507908ba53dba894b97b48795.tar.gz
tojam2024-8475767975a0f07507908ba53dba894b97b48795.zip
shooting bullets
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 38f6576..e60c9f2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -29,6 +29,7 @@ bool xflag=false;
#include "input.h"
#include "render.h"
#include "world.h"
+#include "bullet.h"
Camera camera = { 0 };
Camera camera2 = { 0 };
@@ -59,12 +60,14 @@ World world = {
.direction = { 1, 0, 0 },
.speed = 1.0f/60.0f,
.color = BLUE,
+ .camera_mode = 1,
},
{
.position = { 2, 0, 0 },
.direction = { -1, 0, 0 },
.speed = 1.0f/60.0f,
- .color = RED,
+ .color = MAGENTA,
+ .camera_mode = 1,
}
}
};
@@ -115,8 +118,41 @@ int main(void)
// Update
//-----------------------------------------------------
//controller_read(&controllers);
+ updateController();
+
+ if(pressed_p1.r)
+ {
+ if(world.players[0].camera_mode == 0)
+ {
+ world.players[0].camera_mode = 1;
+ }
+ else
+ {
+ world.players[0].camera_mode = 0;
+ }
+ }
+
+ if(pressed_p2.r)
+ {
+ if(world.players[1].camera_mode == 0)
+ {
+ world.players[1].camera_mode = 1;
+ }
+ else
+ {
+ world.players[1].camera_mode = 0;
+ }
+ }
+ if(pressed_p1.z)
+ {
+ spawn_bullet(1, world.players[0].position, world.players[0].direction);
+ }
+ bullet_collision_check();
+
+ movePlayers();
camera = lookThroughPlayer(camera, world.players[0]);
+ camera2 = lookThroughPlayer(camera2, world.players[1]);
// Update
//----------------------------------------------------------------------------------
@@ -147,8 +183,6 @@ int main(void)
//DrawCubeTextureRec(texture, (Rectangle){ 0, texture.height/2, texture.width/2, texture.height/2 },
// (Vector3){ 2.0f, 1.0f, 0.0f }, 2.0f, 2.0f, 2.0f, WHITE);
- movePlayers();
- updateController();
char text[50];
sprintf(text, "Joystick %d,%d", inputs_p1.stick_x, inputs_p1.stick_y);