Advertisement
Ulabael

oPlayer::draw_event

Sep 23rd, 2022
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. var oldLine = [];
  2. // Запоминаем старые значения
  3. array_copy(oldLine, 0, lineOfSight, 0, array_length(lineOfSight))
  4. draw_self();
  5.  
  6. var lay_id_shadows = layer_get_id("ShadowTiles");
  7. var map_id_shadows = layer_tilemap_get_id(lay_id_shadows);
  8.  
  9. // Клетка, на которой стоим
  10. var xoCell = x div CellWidth;
  11. var yoCell = y div CellHeight;
  12.  
  13. // Клетка, на которую смотрим
  14. var xmCell = mouse_x div CellWidth;
  15. var ymCell = mouse_y div CellHeight;
  16.  
  17. // Обновляем значения
  18. lineOfSight = [];
  19. var line = scrBresenham(xoCell, yoCell, xmCell, ymCell, global.grid);
  20. array_copy(lineOfSight, 0, line, 0, array_length(line))
  21.  
  22. if !(array_equals(line, oldLine)) {
  23. var oldLen = array_length(oldLine);
  24. for (var i = 0; i < oldLen; ++i) {
  25. tilemap_set(map_id_shadows, 1,
  26. oldLine[i][0], oldLine[i][1]);
  27. }
  28. var newLen = array_length(line);
  29. for (var i = 0; i < newLen; ++i) {
  30. tilemap_set(map_id_shadows, 0,
  31. line[i][0], line[i][1]);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement