1 decade ago by emati
Hello dominic, I made some kind of researches and wrote some code and i discover some strange things.
First thing is velocity of entities which are working correctly for me. I tried to wrote shooting thing which is spawn entity with correct angle and velocity.
I didnt have any problem with angle. But velocity worked strange for me.
This is the code:
When i used this code and when i had this.speed with 100, and when i shoot in game in some angles my bullet flew into the corner and it didnt flew to my cursor.
But when i used this code:
Everything is correct and perfect.
Second thing is a question about impact font class. I tried to render text with fillText function and i compere it to the impact font rendering and i get meybe 1ms of difference (in older browser it was bigger) but i want to ask why didnt you used fillText function for impact font class? This is faster a bit and easier i guess.
And last thing isnt question, but suggestion. I tried to do it by myself but with no luck. Its about drawing things the same in every frame. I mean this is pointless, in background-map case this map isnt changeing at all, and this is very very heavy to draw, so some kind of thing like drawing bg-map once would be great stuff.
I think this is possible in certian ways. But i tried html5/js implemented way to do it but without luck, so i give it up to you.
// Sorry if i wrote something wired, i dont know english too good.
First thing is velocity of entities which are working correctly for me. I tried to wrote shooting thing which is spawn entity with correct angle and velocity.
I didnt have any problem with angle. But velocity worked strange for me.
This is the code:
this.vel.x = (Math.cos(this.angle)) * this.speed; this.vel.y = (Math.sin(this.angle)) * this.speed;
When i used this code and when i had this.speed with 100, and when i shoot in game in some angles my bullet flew into the corner and it didnt flew to my cursor.
But when i used this code:
this.pos.x += (Math.cos(this.angle)) * this.speed; this.pos.y += (Math.sin(this.angle)) * this.speed;
Everything is correct and perfect.
Second thing is a question about impact font class. I tried to render text with fillText function and i compere it to the impact font rendering and i get meybe 1ms of difference (in older browser it was bigger) but i want to ask why didnt you used fillText function for impact font class? This is faster a bit and easier i guess.
And last thing isnt question, but suggestion. I tried to do it by myself but with no luck. Its about drawing things the same in every frame. I mean this is pointless, in background-map case this map isnt changeing at all, and this is very very heavy to draw, so some kind of thing like drawing bg-map once would be great stuff.
I think this is possible in certian ways. But i tried html5/js implemented way to do it but without luck, so i give it up to you.
// Sorry if i wrote something wired, i dont know english too good.