# SolvedESP DrawRectangle size increase with distance

#### KISKE

##### Game Developer
Meme Tier VIP
Fleep Tier Donator
Hi,
I'm so happy right now because I made my first ESP and it work out in my first attempt, it's for AssaultCube but I don't care, I started from somewhere.

I have this classic problem that I saw in some places, but I don't know how to fix it and I confess, I'm not very good at math.

I have this (perfect):

My rectangle method is this: https://msdn.microsoft.com/en-us/library/system.drawing.rectangle
C#:
``Rectangle(x, y, w, h);``

I have the distance between the target and me, I just don't figure it out where to put it.

Last edited:

#### Rake

I worked on some code that would do this on different resolutions and different aspect ratios, and generally only require you to change one value per game
C++:
``````#define GAME_UNIT_MAGIC 400
#define VIRTUAL_SCREEN_WIDTH 800
#define PLAYER_HEIGHT 5.25f
#define PLAYER_WIDTH 2.0f
#define PLAYER_ASPECT_RATIO PLAYER_HEIGHT / PLAYER_WIDTH

ESP::DrawBox(FW::Player_t player, vec3_t screenCoords, GL::Font &font, int windowWidth)
{
float scale = (GAME_UNIT_MAGIC / player.distance) * ( windowWidth / VIRTUAL_SCREEN_WIDTH);
float x = screenCoords.x - scale;
float y = screenCoords.y - scale * PLAYER_ASPECT_RATIO;
float width = scale * 2;
float height = scale * PLAYER_ASPECT_RATIO * 2;

GL::DrawOutline(x, y, width, height);
}``````
When you're making a hack, you probably test the whole thing in a window at a certain resolution and every game will use a different unit of measure.

VIRTUAL_SCREEN_WIDTH is the width of the window you originally test your ESP code in
GAME_UNIT_MAGIC is some magical number that you will change for every game and is used to scale the ESP box per the games unit of measure

PLAYER_HEIGHT & PLAYER_WIDTH you will either find by reversing the game or by estimation but I believe these numbers will be about the same for every game because it directly corresponds to the aspect ratio of the player models and if these numbers were different, the models would not proportionally portray realistic human characters

int windowWidth is the current game window width. vec3 screenCoords are the result of your World2Screen function.

So basically for most games you just make your hack in 800x600, and then modify GAME_UNIT_MAGIC until it scales correctly and you're done. Easily modified by changing the defines

#### KISKE

##### Game Developer
Meme Tier VIP
Fleep Tier Donator

#### KISKE

##### Game Developer
Meme Tier VIP
Fleep Tier Donator
Rake;47074 said:
I worked on some code that would do this on different resolutions and different aspect ratios, and generally only require you to change one value per game
C++:
``````#define GAME_UNIT_MAGIC 400
#define VIRTUAL_SCREEN_WIDTH 800
#define PLAYER_HEIGHT 5.25f
#define PLAYER_WIDTH 2.0f
#define PLAYER_ASPECT_RATIO PLAYER_HEIGHT / PLAYER_WIDTH

ESP::DrawBox(FW::Player_t player, vec3_t screenCoords, GL::Font &font, int windowWidth)
{
float scale = (GAME_UNIT_MAGIC / player.distance) * ( windowWidth / VIRTUAL_SCREEN_WIDTH);
float x = screenCoords.x - scale;
float y = screenCoords.y - scale * PLAYER_ASPECT_RATIO;
float width = scale * 2;
float height = scale * PLAYER_ASPECT_RATIO * 2;

GL::DrawOutline(x, y, width, height);
}``````
When you're making a hack, you probably test the whole thing in a window at a certain resolution and every game will use a different unit of measure.

VIRTUAL_SCREEN_WIDTH is the width of the window you originally test your ESP code in
GAME_UNIT_MAGIC is some magical number that you will change for every game and is used to scale the ESP box per the games unit of measure

PLAYER_HEIGHT & PLAYER_WIDTH you will either find by reversing the game or by estimation but I believe these numbers will be about the same for every game because it directly corresponds to the aspect ratio of the player models and if these numbers were different, the models would not proportionally portray realistic human characters

int windowWidth is the current game window width. vec3 screenCoords are the result of your World2Screen function.

So basically for most games you just make your hack in 800x600, and then modify GAME_UNIT_MAGIC until it scales correctly and you're done. Easily modified by changing the defines
You are truly amazing, you know that ?
I will save that snippet code for future ESP.

Thank you.

Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

• Fill out the form correctly
• Tell us the game name & coding language
• Post everything we need to know to help you
• Ask specific questions, be descriptive
• Post errors, line numbers & screenshots
• Post code snippets using code tags
• If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.