DakiLLa Posted September 20, 2009 Share Posted September 20, 2009 (edited) 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! Edited September 20, 2009 by Guest Link to comment
Gamesnert Posted September 20, 2009 Share Posted September 20, 2009 You can do it by fairly simple calculations: local positionOnBar = distanceFromPlayerToPoint / distanceFromPointToPoint * barHeight Basically it, for as far as I know. Link to comment
DakiLLa Posted September 20, 2009 Author Share Posted September 20, 2009 You can do it by fairly simple calculations: local positionOnBar = distanceFromPlayerToPoint / distanceFromPointToPoint * barHeight Basically it, for as far as I know. uhm, what you mean about 'distanceFromPointToPoint'? Between which points? Link to comment
Gamesnert Posted September 20, 2009 Share Posted September 20, 2009 Start to finish. I thought that would be quite clear... Blergh, apparently not. I guess I have to be a bit more clear about my names next time. Link to comment
DakiLLa Posted September 20, 2009 Author Share Posted September 20, 2009 oh, hehe, ok..ill try.. thx for the fast answering Link to comment
Dark Dragon Posted September 20, 2009 Share Posted September 20, 2009 it would look pretty strange the checkpoints are not always the same distance from each other Link to comment
DakiLLa Posted September 20, 2009 Author Share Posted September 20, 2009 it would look pretty strangethe 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
Dark Dragon Posted September 20, 2009 Share Posted September 20, 2009 uhm? what you mean? i need only the last checkpoint position, not the distance between them... if you just use this distance it won't even be accurate, look more strange and people would go up, then down, then up and so on. Link to comment
50p Posted September 21, 2009 Share Posted September 21, 2009 ...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
Mr.Hankey Posted September 21, 2009 Share Posted September 21, 2009 That's no problem 50p and dragon as in his "Trials" race mode you just drive in a straight line from start to finish. Link to comment
norby89 Posted September 21, 2009 Share Posted September 21, 2009 I'm a bit sleepy but, are you really making a 2D game? Something like Elastomania. Link to comment
DakiLLa Posted September 21, 2009 Author Share Posted September 21, 2009 I'm a bit sleepy but, are you really making a 2D game? Something like Elastomania. hehe, almost ^^. Well, guys, sry, my bad..i forgot to tell one serious thing 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
Gamesnert Posted September 21, 2009 Share Posted September 21, 2009 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! To fix this: (well, probably) local positionOnBar = y/4 + distanceFromPlayerToFinish/distanceFromStartToFinish*((y/1.2)-(y/4)); Link to comment
DakiLLa Posted September 21, 2009 Author Share Posted September 21, 2009 yay! Works great! Thx a lot for help !! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now