Jump to content

Compass


.:HyPeX:.

Recommended Posts

Posted

Hey guys, i'm trying to create a compass, how could i update the image on every frame? it draws it up on the pixels 400-500 always.. idk why.

  
function dxDrawImageX() 
local rotz = getElementRotation(getLocalPlayer()) 
local now = rotz 
local End = 360 
local progress = now / End 
local DrawX = interpolateBetween(0,0,0,400, 0,0,progress, "Linear") 
image = dxDrawImageSection(65, 516,165, 50, DrawX, 0, 100, 50, "360.png") 
  
end 
addEventHandler("onClientRender", getRootElement(), dxDrawImageX) 

Help pls.

Image: http://imgur.com/wlCwvyO

PD: Image size is 500x50 (0-400, 400-500 is a replica of 0-100)

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

  • Moderators
Posted
function dxDrawImageX() 
    local rotz = getElementRotation(getLocalPlayer()) 
    local now = rotz 
    local End = 360 
    local progress = now / End 
    dxDrawImageSection(65+(progress*250),516,500, 50, 65, 0, 100, 50, "360.png") 
end 
addEventHandler("onClientRender", getRootElement(), dxDrawImageX) 

As you said image is 500x 50 and not 165x50 which you did.

Does the image move or what?

And at what value does the image starts? Is the 0 in the middle?

You have to see dxImageSection as a photoshop masker(except it isn't moving with the image).

Between those arguments the image is visible:

[b]u:[/b] the absolute X coordinate of the top left corner of the section which should be drawn from image 
[b]v:[/b] the absolute Y coordinate of the top left corner of the section which should be drawn from image 
[b]usize:[/b] the absolute width of the image section 
[b]vsize:[/b] the absolute height of the image section  

My screen is 1920x1080. And I want to show an image on my screen which has a non pixel border(50 px).

Then I would use those values:

posX    = [color=#FF8000]0[/color] 
posY    = [color=#FF8000]0[/color] 
width   =[color=#FF8000] 1920[/color] 
height  =[color=#FF8000] 1080[/color] 
u       =[color=#FF8000] 50[/color] 
v       =[color=#FF8000] 50[/color] 
usize   = [color=#FF8000]1870[/color][color=#00FF00] -- 1920-50[/color] 
vsize   = [color=#FF8000]1030[/color] [color=#00FF00]-- 1080-50[/color] 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

That stuff is bad, no offense, but it is 100 pixels, as it goes from 65 - 165 (165 - 65 = 100), and it works just fine.

Anyways, found out it was this:

  
local rotx, roty, rotz = getElementRotation(getLocalPlayer()) 

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

  • Moderators
Posted

oh lol I haven't seen that too.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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...