Я пытался изменять переменные из функции main()
сначала с помощью указателей, а потом с помощью ссылок, как было указано в одной из статей на этом сайте, но ничего не помогло.
int main()
{
int bl_br_coun = 0, coun_lay = 10;
bool pick = false, las = false, bomb = false;//!Апгрейды персонажа
bool level_complete = false;
bool floor_game = true, wall_game_r = true, wall_game_l = true;
int curt_lev = 0;
float acs = 0.2, vel_x = 2, vel_y = 0;
float height = 60, length = 40;
float bl_range = 60;
float x_hero = 0, y_hero = 0;
int Points = 0;
txCreateWindow(1138, 640);
level_campaing_1(bl_range, x_hero, y_hero, x_hero, y_hero, vel_x,
vel_y, vel_y, acs, height, length);
return 0;
}
void level_campaing_1(float bl_range, float& x_hero_adr,
float& y_hero_adr, float x_hero, float y_hero, float vel_x,
float vel_y, float& vel_y_adr, float acs, float height, float length)
{
startpos_camp_1(x_hero_adr, y_hero_adr);
curt_lev = 1;
while (endingcamp[0] == false)
{
while (floor_game == true)
{
level_blocks_camp_1(bl_range);
game(bl_range, x_hero_adr, y_hero_adr, x_hero, y_hero, vel_x, vel_y,
height, length);
Pickaxe(x_hero, y_hero, height, length);
update();
}
while (floor_game == false)
{
level_blocks_camp_1(bl_range);
game(bl_range, x_hero_adr, y_hero_adr, x_hero, y_hero, vel_x, vel_y,
height, length);
fall(vel_y_adr, acs);
update();
}
vel_y_adr = 0;
}
}
void game(float bl_range, float& x_hero_adr, float& y_hero_adr, float
x_hero, float y_hero, float vel_x, float vel_y, float height,
float length)
{
hero_movement(x_hero_adr, y_hero_adr, vel_x, vel_y);
floor_wall_ch(bl_range, x_hero, y_hero, length, height);
Heroanim_1(x_hero, y_hero, height, length);
}
void hero_movement(float& x_hero, float& y_hero, float vel_x,
float vel_y)
{
y_hero += vel_y;
if (GetAsyncKeyState(VK_RIGHT))
{
if (wall_game_r == false)
{
x_hero += vel_x;
}
}
if (GetAsyncKeyState(VK_LEFT))
{
if (wall_game_l == false)
{
x_hero -= vel_x;
}
}
if (GetAsyncKeyState(VK_UP))
{
if (vel_y = 0)
{
vel_y = -4;
}
}
if (GetAsyncKeyState(VK_DOWN))
{
}
}
void startpos_camp_1(float& x_hero, float& y_hero)
{
x_hero = 260;
y_hero = 400;
}
Функции startpos_camp_1 и hero_movement должны изменять переменные x_hero
и y_hero
, но по факту они не меняются. Подскажите в чем проблема?