Skip to content

Commit

Permalink
CastielM first step to adding enemies - added basic function for enem…
Browse files Browse the repository at this point in the history
…y collision to be detected (sound only) and made them non=solid
  • Loading branch information
CastielM committed May 11, 2024
1 parent e179183 commit bff6059
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
Binary file modified games/VentureAdventure/.vscode/.BROWSE.VC.DB
Binary file not shown.
Binary file modified games/VentureAdventure/.vscode/.BROWSE.VC.DB-shm
Binary file not shown.
18 changes: 17 additions & 1 deletion games/VentureAdventure/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ void get_objects(game_data &game)
for (int i = 0; i < w; i++)
for (int j = 0; j < h; j++)
{
if(game.map_array[i][j] > 1 && game.map_array[i][j] < 300)
//tiles with numbers defined between 1 and 300 are 'solid'. Excludes 'enemy' currently defines as 200 (so that collision is possible. This if statement needs to be adjusted if more enemy tile numbers are added)
if(game.map_array[i][j] > 1 && game.map_array[i][j] < 300 && game.map_array[i][j] != 200)
{
int solid_x = j*TILESIZE;
int solid_y = i*TILESIZE;
Expand Down Expand Up @@ -222,6 +223,7 @@ void swap(gem_data g1, gem_data g2)
g2 = temp;
}


void gem_collision(game_data &game)
{
for (int i = 0; i < game.gems.size(); i++)
Expand All @@ -233,6 +235,18 @@ void gem_collision(game_data &game)
}
}

//adding a first collision check between player and enemy
void enemy_collision(game_data &game)
{
for (int i = 0; i < game.enemies.size(); i++)
if(sprite_collision(game.player.player_sprite, game.enemies[i].enemy_sprite))
{
play_sound_effect("diamond");
//game.player.gem += 1;
//remove_gem(game, i);
}
}

void attack(game_data &game)
{
int box_id;
Expand Down Expand Up @@ -441,6 +455,8 @@ void moving(game_data &game)
// collect gem
gem_collision(game);

enemy_collision(game);

if(game.player.y_prev > game.player.y_pos && game.player.y_pos <= game.player.next)
{
sprite_start_animation(game.player.player_sprite, "stand_u");
Expand Down
Binary file modified games/VentureAdventure/game.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion games/VentureAdventure/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int main()
game = new_game(map);
}

start_debug(game);
//start_debug(game);

refresh_screen(60);

Expand Down

0 comments on commit bff6059

Please sign in to comment.