Same diametric move intensity on different resolutions in Matter.js











up vote
-2
down vote

favorite












I need help. I have a player and i want jump player always in same diametric order. I wanted to fix this with getHeight with return ( innerHeight/100 * per ) but no improved. Even worst if canvas size become bigger player have smallest jump , for smaller window player jumps higher! I dont want to callibrate in hard code way. I need responsive function!



"leave a comment before vote negative"



r.player.force = {
x: 0,
y: -(getHeight(0.03)),
};
Matter.Body.applyForce(r.player, { x: r.player.position.x, y: r.player.position.y }, r.player.force);

public getHeight(percente: number): number {
return this.reperH() / 100 * percente;
}

this.reperH = function () {

if ((window as any).innerHeight > (window as any).innerWidth / this.aspectRatio) {
return (window as any).innerWidth / this.aspectRatio;
} else {
return (window as any).innerHeight;
}

};


Full source : link










share|improve this question
























  • Please leave comment whats wrong with this Q ?!
    – Nikola Lukic
    yesterday

















up vote
-2
down vote

favorite












I need help. I have a player and i want jump player always in same diametric order. I wanted to fix this with getHeight with return ( innerHeight/100 * per ) but no improved. Even worst if canvas size become bigger player have smallest jump , for smaller window player jumps higher! I dont want to callibrate in hard code way. I need responsive function!



"leave a comment before vote negative"



r.player.force = {
x: 0,
y: -(getHeight(0.03)),
};
Matter.Body.applyForce(r.player, { x: r.player.position.x, y: r.player.position.y }, r.player.force);

public getHeight(percente: number): number {
return this.reperH() / 100 * percente;
}

this.reperH = function () {

if ((window as any).innerHeight > (window as any).innerWidth / this.aspectRatio) {
return (window as any).innerWidth / this.aspectRatio;
} else {
return (window as any).innerHeight;
}

};


Full source : link










share|improve this question
























  • Please leave comment whats wrong with this Q ?!
    – Nikola Lukic
    yesterday















up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











I need help. I have a player and i want jump player always in same diametric order. I wanted to fix this with getHeight with return ( innerHeight/100 * per ) but no improved. Even worst if canvas size become bigger player have smallest jump , for smaller window player jumps higher! I dont want to callibrate in hard code way. I need responsive function!



"leave a comment before vote negative"



r.player.force = {
x: 0,
y: -(getHeight(0.03)),
};
Matter.Body.applyForce(r.player, { x: r.player.position.x, y: r.player.position.y }, r.player.force);

public getHeight(percente: number): number {
return this.reperH() / 100 * percente;
}

this.reperH = function () {

if ((window as any).innerHeight > (window as any).innerWidth / this.aspectRatio) {
return (window as any).innerWidth / this.aspectRatio;
} else {
return (window as any).innerHeight;
}

};


Full source : link










share|improve this question















I need help. I have a player and i want jump player always in same diametric order. I wanted to fix this with getHeight with return ( innerHeight/100 * per ) but no improved. Even worst if canvas size become bigger player have smallest jump , for smaller window player jumps higher! I dont want to callibrate in hard code way. I need responsive function!



"leave a comment before vote negative"



r.player.force = {
x: 0,
y: -(getHeight(0.03)),
};
Matter.Body.applyForce(r.player, { x: r.player.position.x, y: r.player.position.y }, r.player.force);

public getHeight(percente: number): number {
return this.reperH() / 100 * percente;
}

this.reperH = function () {

if ((window as any).innerHeight > (window as any).innerWidth / this.aspectRatio) {
return (window as any).innerWidth / this.aspectRatio;
} else {
return (window as any).innerHeight;
}

};


Full source : link







javascript typescript3.0 matterjs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









wanttobeprofessional

81331222




81331222










asked Nov 18 at 20:02









Nikola Lukic

1,67821735




1,67821735












  • Please leave comment whats wrong with this Q ?!
    – Nikola Lukic
    yesterday




















  • Please leave comment whats wrong with this Q ?!
    – Nikola Lukic
    yesterday


















Please leave comment whats wrong with this Q ?!
– Nikola Lukic
yesterday






Please leave comment whats wrong with this Q ?!
– Nikola Lukic
yesterday



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53364905%2fsame-diametric-move-intensity-on-different-resolutions-in-matter-js%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53364905%2fsame-diametric-move-intensity-on-different-resolutions-in-matter-js%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin