feat: made hitboxes area dependent
This commit is contained in:
30
code/first.c
30
code/first.c
@@ -219,7 +219,7 @@ int main(int argc, char **argv)
|
||||
world->propTypes[21].scale=1;
|
||||
world->propCount = 0;
|
||||
world->props = M_ArenaPush(arena, World_Prop, .count=WORLD_PROP_MAX);
|
||||
world->hitboxes = M_ArenaPush(arena, AABB, .count=WORLD_HITBOX_MAX);
|
||||
world->hitboxes = M_ArenaPush(arena, World_Hitbox, .count=WORLD_HITBOX_MAX);
|
||||
world->portals = M_ArenaPush(arena, World_Portal, .count=64);
|
||||
world->portalCount=0;
|
||||
GenerateNavMesh(arena, world);
|
||||
@@ -285,11 +285,12 @@ int main(int argc, char **argv)
|
||||
}} else if(e.type==SDL_EVENT_MOUSE_BUTTON_UP && e.button.button == SDL_BUTTON_LEFT && game->editor.mode == G_EDITOR_MODE_HITBOX) {
|
||||
// Add hitbox
|
||||
V2f topLeft = V2F(Min(game->editor.cursor.x, game->editor.dragStart.x), Min(game->editor.cursor.y, game->editor.dragStart.y));
|
||||
game->world->hitboxes[game->world->hitboxCount].pos = topLeft;
|
||||
game->world->hitboxes[game->world->hitboxCount].size = V2F(
|
||||
game->world->hitboxes[game->world->hitboxCount].box.pos = topLeft;
|
||||
game->world->hitboxes[game->world->hitboxCount].box.size = V2F(
|
||||
Abs(game->editor.cursor.x-game->editor.dragStart.x),
|
||||
Abs(game->editor.cursor.y-game->editor.dragStart.y)
|
||||
);
|
||||
game->world->hitboxes[game->world->hitboxCount].area = game->editor.currentAsset;
|
||||
game->world->hitboxCount++;
|
||||
GenerateNavMesh(game->arena, game->world);
|
||||
} else if(e.type==SDL_EVENT_MOUSE_BUTTON_UP && e.button.button == SDL_BUTTON_LEFT && game->editor.mode == G_EDITOR_MODE_PORTAL) {
|
||||
@@ -367,6 +368,7 @@ int main(int argc, char **argv)
|
||||
switch(game->editor.mode) {
|
||||
case G_EDITOR_MODE_PROP: {game->world->propCount--;}
|
||||
case G_EDITOR_MODE_HITBOX: {game->world->hitboxCount--;}
|
||||
case G_EDITOR_MODE_PORTAL: {game->world->portalCount--;}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -471,16 +473,18 @@ int main(int argc, char **argv)
|
||||
}
|
||||
case G_EDITOR_MODE_HITBOX: {
|
||||
for(U32 i = 0; i < game->world->hitboxCount; i++) {
|
||||
V2f centre = AABB_Centre(game->world->hitboxes[i]);
|
||||
D_Rect(
|
||||
&game->draw,
|
||||
centre.x,
|
||||
centre.y,
|
||||
.texture=0,
|
||||
.dim=game->world->hitboxes[i].size,
|
||||
.flags=D_RECT_IGNORE_ASPECT,
|
||||
.c=V4F(100,0,0,0.7f),
|
||||
);
|
||||
if(game->world->player.currentArea == game->world->hitboxes[i].area) {
|
||||
V2f centre = AABB_Centre(game->world->hitboxes[i].box);
|
||||
D_Rect(
|
||||
&game->draw,
|
||||
centre.x,
|
||||
centre.y,
|
||||
.texture=0,
|
||||
.dim=game->world->hitboxes[i].box.size,
|
||||
.flags=D_RECT_IGNORE_ASPECT,
|
||||
.c=V4F(100,0,0,0.7f),
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user