-
Posts
8 -
Joined
-
Last visited
Everything posted by geralsoft
-
fitting canvas on non-fullscreen, user scrolling
geralsoft replied to Sandcastle Games's topic in Coding and Game Design
function gcd(a, b) { if (b > a) { let _temp = a; a = b; b = _temp } while (b != 0) { let _m = a % b; a = b; b = _m; } return a; } function ratio(x, y) { let _c = gcd(x, y); return "" + (x / _c) + ":" + (y / _c) } class Utilidades{ //width = ancho //height = alto construct(){ } getAspect(){ aspect = ratio(window.innerWidth,window.innerHeight); console.log("que "+aspect); switch(aspect) { case '4:3': ancho=2048; alto=1536; //console.log(this.alto+" aa "+this.ancho); break;case '1:5': ancho=2048; alto=1536; //console.log(this.alto+" aa "+this.ancho); break; case '16:9': ancho=1920; alto=1080; console.log("bb"); break; default: ancho=1920; alto=960; console.log("ccc"); break; } anchoMid= ~~(ancho/2); altoMid= ~~(alto/2); console.log("width g "+ancho+" height g "+alto); } setDisplay(){ //dataRes.mode = false; let gameWidth = window.innerWidth; let gameHeight = window.innerHeight; let scaleToFitX = gameWidth/ancho ; let scaleToFitY = gameHeight/alto ; let currentScreenRatio = gameWidth / gameHeight; let optimalRatio = Math.min(scaleToFitX, scaleToFitY); if (currentScreenRatio >= 1.77 && currentScreenRatio <= 1.79) { canvas.style.width = gameWidth + "px"; canvas.style.height = gameHeight + "px"; canvas.style.left = ((gameWidth - (ancho * optimalRatio))/2)+"px"; canvas.style.top = ((gameHeight - (alto * optimalRatio))/2)+"px"; console.log("a "+canvas.style.left); }else { canvas.style.left = ((gameWidth - (ancho * optimalRatio))/2)+"px"; canvas.style.top = ((gameHeight - (alto * optimalRatio))/2)+"px"; canvas.style.width = ancho * optimalRatio + "px"; canvas.style.height = alto * optimalRatio + "px"; // console.log("b "+canvas.style.left); } scaleX = ancho/(gameWidth-(gameWidth-(ancho*optimalRatio))); scaleY = alto/(gameHeight-(gameHeight - (alto*optimalRatio))); //console.log("scale x "+scaleX+" scaley "+scaleY); console.log("width "+ancho+" height "+alto); dataRatio.offx = parseInt(canvas.offsetLeft); dataRatio.offy = parseInt(canvas.offsetTop); //if(jugando){ engine.resize(); }//fin de setDisplay setAspect(){ } }//end of class utils call util.getAspect(); on load, and setDisplay on resize event -
oh... well, the most complex game that I have made, not the most complex in the world, also has features that are not visible, such as automatic aspect ratio detection (4: 3, 16: 9, 18: 9, 19: 9); Multiple forms of control: keyboard / mouse, gamepad and touchpad. (you can play with any peripheral at any time in the gameplay) stereo sound particle system a creator of levels, (not published). multiple ads platform (admob, facebook ads and others) and.. without frameworks like pixi, phaser, some libraries to sound, bezier lines... Unfortunately, I'm not good at drawing, I hired a graphic designer but I didn't reach the budget, that's why I know about his graphic shortcomings, besides the requirement to finish the missions is not clear
-
my most complex html5 game https://www.crazygames.com/game/space-jumper
-
We have marketing, you have a game
geralsoft replied to redpeter's topic in Collaborations (un-paid)
Hi, write me and maybe we can talk about this -
Anyone can recommend a good site for html5 games?
geralsoft replied to totoper's topic in General Talk
crazzygames -
Hi for all, share mi game in crazzygames, please playt it and tell me your opinion: https://www.crazygames.com/game/space-jumper
-
Sent my videogame with rewarded videos, and they reject it because it doesn't show videos at any other time than from the "watch video" button ?