Jump to content

New race Radar


DakiLLa

Recommended Posts

Hello guys! i got one idea from my friend. I dont know, how to name this thing..but you can take a look on this picture (left side of picture, hehe, there is another images ^^). The line with dots (players) over it. I think you have seen something like this in another games. Not so bad idea for mta, isnt it?

Well, i want to make something like that, but dont know, from what i should begin. Could be a nice replacement for a usual radar and also looks cool.

I know only that i need to get position betwen player and finish but.. then how can i 'convert' (idk how to say..may be calculate) this value to the pixels of screen to let red dots move up or down over line. Any ideas?

Thx for the replies! :D

Edited by Guest
Link to comment
it would look pretty strange

the checkpoints are not always the same distance from each other

uhm? what you mean? i need only the last checkpoint position, not the distance between them...

well, i did as said Gamesnert, works perfect, but i got one problem: if i stay at the start point, the position of image on bar is incorrect..it must be in the bottom of line, but it isnt... and if im near finish, image is somewhere over the chat window...

Screenshot is here

And this is my code:

local gMe = getLocalPlayer();
 
addEventHandler( 'onClientRender', getRootElement(),
function ()
local x, y = guiGetScreenSize();
dxDrawLine( x/10, y/4, x/10, y/1.2, tocolor( 255, 255, 255, 255 ), 8.5 );
 
local myX, myY = getElementPosition( gMe );
local fiX, fiY = getElementPosition( getElementsByType( 'checkpoint' )[#getElementsByType( 'checkpoint' )] );
local stX, stY = getElementPosition( getElementsByType( 'spawnpoint' )[1] );
 
local distanceFromPlayerToFinish = getDistanceBetweenPoints2D( myX, myY, fiX, fiY );
local distanceFromStartToFinish  = getDistanceBetweenPoints2D( stX, stY, fiX, fiY );
 
local positionOnBar = distanceFromPlayerToFinish/distanceFromStartToFinish*((y/1.2)-(y/4));
 
dxDrawImage( x/10, positionOnBar, x/40, y/32, 'images/dot.png', 0, 0, 0, tocolor( 255, 255, 255, 255 ) );
end
);

I have taken a t-shirt image from Talidan's teammanager just for test ^^

Link to comment
...

uhm? what you mean? i need only the last checkpoint position, not the distance between them...

...

What if you had 2 checkpoints race. 1 checkpoints at 1 side of the airport and 1 and the place where you started the race? You want to calculate distance from start to finish which would be 0 or about 5. You need to know the distance of the entire race (add up distances between checkpoints). That would be easier but not very very accurate.

Link to comment
I'm a bit sleepy but, are you really making a 2D game? :P Something like Elastomania.

hehe, almost ^^. Well, guys, sry, my bad..i forgot to tell one serious thing :oops: I'm making my own mode where you must drive only in one side: to the north. And all checkpoints are located one by one in a row. Thats why i told only about the last checkpoint..

Soo..can anybody tell, why the image on a bar is in wrong place...?

Link to comment
well, i did as said Gamesnert, works perfect, but i got one problem: if i stay at the start point, the position of image on bar is incorrect..it must be in the bottom of line, but it isnt... and if im near finish, image is somewhere over the chat window...

Screenshot is here

If I look at the image, and look at the distance between the T-shirt and the bottom, it seems exactly equal to the empty space above the bar. This means you've got one thing wrong:

local positionOnBar = distanceFromPlayerToFinish/distanceFromStartToFinish*((y/1.2)-(y/4));

Note that it's called positionOnBar. You do it perfect, except that you forget to add the line's start position! :P To fix this: (well, probably)

local positionOnBar = y/4 + distanceFromPlayerToFinish/distanceFromStartToFinish*((y/1.2)-(y/4));

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...