Question: I'm building a server-side(!) for online game and I need to check if bullet hit a target.

Client sends me position and angle of bullet fired, I know all the enemies coordinates and sizes. How can I calculate if bullet hit an enemy after a bullet fired? Enemies have different sizes, bullet is 1px size.

For example, I have player shooting angle of 45 degrees from 0, 0 coordinates, and an enemy on 200, 200 coordinates with 10 width, 15 height. How do I calculate that bullet hit the enemy?

**UPDATE:** The game is 2d dhooter from the top, like Crimsonland. Projectiles have start speed which decreases slowly.

Answer: 
When you are calling `new SteamBot();` you are creating a new instance of a `SteamBot`, it depends how you intend to use your SteamBot, do you need multiple steambots or just one ? If you only need one instance in your app,I would advise you to do something like that :

file /steambot.class.js

```
// this file contains your class
class SteamBot {

    ...
}

module.exports = SteamBot; 

```

file /steambot.js

```
const SteamBotClass = require('./steambot.class');
let SteamBot;

module.exports = function(...args) {
    SteamBot = SteamBot || new SteamBotClass(...args);
    return SteamBot;
};

```

/app.js

```
const SteamBot = require('./steambot')({
    'logOnOptions'
});

```

And if you want to use in a third file the same instance:

```
const SteamBot = require('./steambot')();

```

with this structure, in your app, you would be able to create a new class if you need it one day, with just the `.class.js` file, but if you need to keep one instance of `SteamBot` all along the app, just require `steambot.js`.

it gives you a singleton pattern based on file, a bit different from the answer from Grégory which I also like.

Hope this helps :)
It doesn't mater how you name your bot variable. If you name it `bot` you will call `bot.getUserInventory(...)`, if `anotherBot` then `anotherBot.getUserInventory(...)` if `foo` then `foo.getUserInventory(...)` and so on