![]() |
The Exact Center
I've had a LOT of different people tell me different ways to get the exact center of the player. Now, of all that I've heard I know it's either one of two ways:
PHP Code:
PHP Code:
Which is it, this has confused me for so long...? |
It depends on where you want the 'center' of the player. The x is always player.x+1.5, but the y, I usually prefer it in the center of the body, not the whole player.
The 'size' of the player is 3x3, this is shown in Graalshop by the 48x48 pixel box. Now, if you mean the center of that, then it's player.x+1.5 and playery+1.5, but I prefer player.x+1.5 and playery+2(or 2.5), which is near the center of the player's body. |
Zeo knows the exact center of the player apparently...it's like a f'ing long decimal
|
Quote:
Center X - player.x + 1.5 Center Y - player.y + 2 Because I want the center of the body. |
Quote:
|
Quote:
|
Quote:
|
While testing....
PHP Code:
|
Quote:
|
For stuff like baddies(where you want them to aim at the body), I'd say y+2 would be much more appropriate. But it really doesn't matter, but I personally think 1.75 is a little bit too above the body.
|
Quote:
|
PHP Code:
|
Quote:
|
Quote:
|
The blocking part of "showcharacters" and players is x=0.5, y=1, width=2, height=2, so the center would be x=1.5 and y=2
|
Quote:
|
If I want the exact center, and seriously, the exact one, I just do the following:
PHP Code:
|
Quote:
PHP Code:
But his movement system is compatible with gs1 so I've rewritten his movement system to work with gs2, and to use less cpu (gs1 didn't support temp. variables >_<) and I added running to it ;o |
Quote:
|
Quote:
PHP Code:
|
You should not be subtracting 1/32 (half a pixel), as doing so will give you an innacurate result.
If you're wondering why, it's because a pixel has shape to it: it has both a left and right edge. The easiest way to demonstrate this is to draw 2 adjoining squares on a piece of paper with 0 and 2 written on the outside bottom corners, and 1 written on the touching corner. I'm fairly sure that you'll agree the centre is at 1 and not 0.5. PHP Code:
|
So what's the best calculation then Storm?
PHP Code:
|
Quote:
NPC Code:temp.cx = player.x + 1.5; Which give the center of the players base (thats the area which blocks against walls). Add/subtract 1 from those positions to find the respective edges of this region. :) |
Quote:
|
Quote:
|
Quote:
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Zomg 3 pages of arguing this when Stefan answered it in the first? Why would you even begin to think Stefan was wrong?
|
3 pages of arguing...?
|
Quote:
By the way, if just that takes up 3 pages then you should probably display more posts per page methinks? I do 30 a page myself. |
| All times are GMT +2. The time now is 06:17 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.