SFML и C++ Уроки \ Разработка игр › Форумы › SFML Graphics › Прокрутка заднего фона
В этой теме 1 ответ, 2 участника, последнее обновление barbar 7 года/лет, 7 мес. назад.
-
АвторСообщения
-
Привет, делаю parallax scrolling для фона в игре, но не могу сделать так чтобы когда мой игрок доходит до низа уровня фон останавливался:
pos.x = px + 10 – (WIN_WIDTH / 2);
pos.y = py + 10 – (WIN_HEIGHT / 2);//Ограничить камеру вначале
if(pos.x < 0) pos.x = 0;
if(pos.y < 0) pos.y = 0;
//и в конце уровня
if(PARALLAX_FACTOR > 0)
{
if(pos.x >= WIN_HEIGHT) pos.x = WIN_HEIGHT;
if(pos.y >= WIN_WIDTH) pos.y = WIN_WIDTH;
}
else
{
if(pos.x > BG_WIDTH-WIN_WIDTH) pos.x = BG_WIDTH-WIN_WIDTH;
if(pos.y > BG_HEIGHT-WIN_HEIGHT) pos.y = BG_HEIGHT-WIN_HEIGHT;}
Есть константы: ширина и высота фона, окна и параллакс (на сколько сдвигается фон при движении камеры), как имея эти данные узнать координаты камеры на фоне а не просто на уровне?
полный код здесь: https://github.com/anatsvit/SFML_2d_Platformer/blob/master/main.cpp
Что то у меня не компилируется, вот выхлоп терминала
Shell12345678910111213141516171819202122232425262728293031In file included from main.cpp:4:0:tile.h:20:1: warning: ‘typedef’ was ignored in this declaration};^/tmp/ccgphFSs.o: In function `main':main.cpp:(.text+0x8b0): undefined reference to `update_coords(int, int, Coords*)'main.cpp:(.text+0x978): undefined reference to `update_coords(int, int, Coords*)'/tmp/ccgphFSs.o: In function `is_tile_type(int, int, int)':main.cpp:(.text+0x11fe): undefined reference to `get_tile(int, int)'main.cpp:(.text+0x1208): undefined reference to `get_tile_type(int)'/tmp/ccgphFSs.o: In function `get_my_y(int, int, int)':main.cpp:(.text+0x1240): undefined reference to `get_tile(int, int)'main.cpp:(.text+0x124a): undefined reference to `get_left_level(int)'main.cpp:(.text+0x1256): undefined reference to `get_tile_y_global(int)'main.cpp:(.text+0x1273): undefined reference to `get_tile(int, int)'main.cpp:(.text+0x127d): undefined reference to `get_right_level(int)'main.cpp:(.text+0x1289): undefined reference to `get_tile_y_global(int)'main.cpp:(.text+0x12a6): undefined reference to `get_tile(int, int)'main.cpp:(.text+0x12b3): undefined reference to `get_x_in_tile(int)'main.cpp:(.text+0x12bc): undefined reference to `get_y_level(int, int)'main.cpp:(.text+0x12c8): undefined reference to `get_tile_y_global(int)'/tmp/ccgphFSs.o: In function `modify_xy(int, int, int, int)':main.cpp:(.text+0x133e): undefined reference to `update_coords(int, int, Coords*)'/tmp/ccgphFSs.o: In function `calculate_y(int, int)':main.cpp:(.text+0x1373): undefined reference to `tile_place(int, int)'main.cpp:(.text+0x13c4): undefined reference to `tile_place(int, int)'main.cpp:(.text+0x1418): undefined reference to `tile_place(int, int)'main.cpp:(.text+0x1434): undefined reference to `tile_place(int, int)'main.cpp:(.text+0x1450): undefined reference to `tile_place(int, int)'/tmp/ccgphFSs.o:main.cpp:(.text+0x147d): more undefined references to `tile_place(int, int)' followcollect2: error: ld returned 1 exit status -
АвторСообщения
Для ответа в этой теме необходимо авторизоваться.