verebes122 Posted February 23, 2020 Share Posted February 23, 2020 Sziasztok! Angol nyelvű topicban már megnyitottam ezt a témát de nem sikerült megoldani. Esetleg valaki tud segíteni ? A problémám, hogy egyáltalán nem jelenik meg blip bárhogy számolgatok pozíciókat. Itt a kód, a blip koord számítást, most kitöröltem belőle. local c = exports.gw_core local screenX,screenY = guiGetScreenSize() local fonts = c:getFonts() local options = c:getOptions() local w,h = c:getSize(300), c:getSize(250) local bx,by = c:getSize(50), screenY - c:getSize(50)-h local x,y = c:getSize(60), screenY - c:getSize(40) - h local arrowSize = c:getSize(30) local bw,bh = w*2,h*2 local map = dxCreateTexture('world.jpg') local blipTarget = dxCreateRenderTarget(bw,bh) local zoom = 5 setPlayerHudComponentVisible ( 'radar',false) function getMapCord(element) local x,y = getElementPosition(element) local imgSize = 3072 return ((x + 3000) / 6000) * imgSize, (-(y - 3000) / 6000) * imgSize end local blip = createBlip (2075.62890625,-1715.8212890625,13.546875, 0) addEventHandler('onClientRender',root,function() local _,_,r = getElementRotation(getCamera()) local _,_,pr = getElementRotation(localPlayer) local posX,posY = getMapCord(localPlayer) local playerX,playerY = getElementPosition(localPlayer) dxSetRenderTarget(blipTarget) dxDrawImageSection ( 0,0, bw,bh,posX - bw/2, posY - bh/2, bw ,bh ,map,r) for k,v in pairs(getElementsByType('blip')) do -- ITT KÉNE VALAHOGY KISZÁMITANI end dxSetRenderTarget() dxDrawRectangle ( bx,by,w+c:getSize(20),h+c:getSize(20), options.panelDark) dxDrawImageSection ( x,y,w,h,w/2,h/2,w,h,blipTarget) dxDrawImage ( x + w/2 - arrowSize/2, y + h/2 - arrowSize/2, arrowSize,arrowSize,'player.png',r-pr,0,0) end) 33.sor amit nézni kell, ott nem tudom ,hogy milyen számítást kéne végezzek. Link to comment
verebes122 Posted February 23, 2020 Author Share Posted February 23, 2020 EDIT: Mostmár ha telibe ránézek jó helyen van de ha elfordulok akkor fordul a kamerával: for k,v in pairs(getElementsByType('blip')) do local blipPosX,blipPosY = getElementPosition(v) local rotationBetween = findRotation(playerX,playerY,blipPosX,blipPosY) local distanceBetween_GAME = getDistanceBetweenPoints2D (playerX,playerY,blipPosX,blipPosY) local distanceBetween_PIXELS = distanceBetween_GAME * (3000/6000) local x,y = w/2, h/2 local blipScreenX,blipScreenY = getPointFromDistanceRotation(x+w/2,y+h/2,distanceBetween_PIXELS,rotationBetween) dxDrawText ( blipScreenX .. ' , '.. blipScreenY , bw/2,bh/2,bw/2,bh/2 ,tocolor(255,255,255,255)) blipScreenX = math.max(x, math.min(x+w, blipScreenX)) blipScreenY = math.max(y, math.min(y+h, blipScreenY)) dxDrawImage(blipScreenX- 10, blipScreenY - 10, 20, 20, 'player.png'); end Link to comment
Moderators Patrick Posted February 24, 2020 Moderators Share Posted February 24, 2020 (edited) Hali. Elkerülte a figyelmem a legutóbb, hogy renderTargetben vagy, mert dxDrawImageSection-t használsz. (elég a dxDrawImage) így viszont, hogy renderTargetben vagy, nem kell korlátozni a (min-maxos cucc) blip max távolságát. (kivettem) A findRotationnál pont fordítva kell a különbséget nézni, hogy egyszerűbb legyen számolni. getPointFromDistanceRotation-nál pedig mivel renderTarget-ben vagy, annak a közepét kell megadni, azon belül. for k,v in pairs(getElementsByType('blip')) do local blipPosX,blipPosY = getElementPosition(v) local rotationBetween = findRotation(blipPosX,blipPosY,playerX,playerY) local distanceBetween_GAME = getDistanceBetweenPoints2D (playerX,playerY,blipPosX,blipPosY) local distanceBetween_PIXELS = distanceBetween_GAME * (3072/6000) local blipScreenX,blipScreenY = getPointFromDistanceRotation(w,h,distanceBetween_PIXELS,rotationBetween-r) dxDrawText ( blipScreenX .. ' , '.. blipScreenY , bw/2,bh/2,bw/2,bh/2 ,tocolor(255,255,255,255)) dxDrawImage(blipScreenX- 10, blipScreenY - 10, 20, 20, 'player.png'); end Edited February 24, 2020 by Patrick Link to comment
verebes122 Posted February 24, 2020 Author Share Posted February 24, 2020 Köszi már közben valahogy megoldottam, bár picit másképp néz ki. Le is akartam zárni a topicot csak nem tudtam hogy kell 1 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