Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function draw(data){
- //ctx.clearRect(0,0,1200,700);
- console.log(render_mode);
- if (render_mode === "map") {
- ctx.drawImage(img.space,0,0);
- for (i in data.star_systems) {
- img.star = new Image();
- img.star.src = '/img' + '/stars' + data.star_systems[i][2];
- star_size = data.star_systems[i][5];
- star_x = data.star_systems[i][3];
- star_y = data.star_systems[i][4];
- star_name = data.star_systems[i][1];
- ctx.drawImage(img.star,star_x - star_size,star_y - star_size, star_size, star_size);
- ctx.fillText(star_name, star_x - star_size,star_y+30 - star_size);
- console.log(4);
- }
- }
- if (render_mode === "star_system") {...}
- window.requestAnimationFrame(animate)
- }
- function animate(data) {
- draw(data);
- }
- socket.on('render_map', function(data){
- window.requestAnimationFrame(animate(data));
- console.log(1);
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement