Advertisement
Redomine

Untitled

Aug 30th, 2020 (edited)
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. function draw(data){
  2. //ctx.clearRect(0,0,1200,700);
  3. console.log(render_mode);
  4. if (render_mode === "map") {
  5. ctx.drawImage(img.space,0,0);
  6. for (i in data.star_systems) {
  7. img.star = new Image();
  8. img.star.src = '/img' + '/stars' + data.star_systems[i][2];
  9. star_size = data.star_systems[i][5];
  10. star_x = data.star_systems[i][3];
  11. star_y = data.star_systems[i][4];
  12. star_name = data.star_systems[i][1];
  13. ctx.drawImage(img.star,star_x - star_size,star_y - star_size, star_size, star_size);
  14. ctx.fillText(star_name, star_x - star_size,star_y+30 - star_size);
  15. console.log(4);
  16. }
  17. }
  18. if (render_mode === "star_system") {...}
  19. window.requestAnimationFrame(animate)
  20.  
  21. }
  22.  
  23. function animate(data) {
  24. draw(data);
  25. }
  26.  
  27. socket.on('render_map', function(data){
  28. window.requestAnimationFrame(animate(data));
  29. console.log(1);
  30.  
  31. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement