Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var oldLine = [];
- // Запоминаем старые значения
- array_copy(oldLine, 0, lineOfSight, 0, array_length(lineOfSight))
- draw_self();
- var lay_id_shadows = layer_get_id("ShadowTiles");
- var map_id_shadows = layer_tilemap_get_id(lay_id_shadows);
- // Клетка, на которой стоим
- var xoCell = x div CellWidth;
- var yoCell = y div CellHeight;
- // Клетка, на которую смотрим
- var xmCell = mouse_x div CellWidth;
- var ymCell = mouse_y div CellHeight;
- // Обновляем значения
- lineOfSight = [];
- var line = scrBresenham(xoCell, yoCell, xmCell, ymCell, global.grid);
- array_copy(lineOfSight, 0, line, 0, array_length(line))
- if !(array_equals(line, oldLine)) {
- var oldLen = array_length(oldLine);
- for (var i = 0; i < oldLen; ++i) {
- tilemap_set(map_id_shadows, 1,
- oldLine[i][0], oldLine[i][1]);
- }
- var newLen = array_length(line);
- for (var i = 0; i < newLen; ++i) {
- tilemap_set(map_id_shadows, 0,
- line[i][0], line[i][1]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement