New answers tagged

1

You can use a noise texture to "perturbate" the position of particles. The noise texture is used to apply changes in the direction of the particles. var noiseTexture = new BABYLON.NoiseProceduralTexture("perlin", 256, scene); noiseTexture.animationSpeedFactor = 5; noiseTexture.persistence = 2; noiseTexture.brightness = 0.5; ...


0

I did this : function search(from,to,i) { if(i == 1){ if (isHexNear(from,to) || JSON.stringify(from) == JSON.stringify(to)){ return [[from, to]] } return [] } let all_paths = [] let neighbors = nearestHexesArr(from) neighbors.push(from) for (let node of neighbors) { let neighbor_all_paths = search(node,to,i-1) for( let path ...


0

The JavaScript FontFace class is (as of July 2020) still a working draft, but already supported by all browsers except (as usual) Internet Explorer. It can be used to load a font via JavaScript and provides a Promise-based API which allows to execute a callback function if/when the font is actually loaded: let myFont = new FontFace("myFont", "...


0

This answer about a similar question on StackOverflow gives a detailed solution to detecting when the font has loaded. It repeatedly draws a character in the font that should be loaded, and when it notices that the number of pixels suddenly changes it knows the font has been loaded and invokes a callback. The detection function is written for FontAwesome and ...


0

This reminds me of a problem I did on Google Foobar recently. It's dynamic programming. Basically first compute every path where you can get to the destination in exactly 1 move (from any tile location). Then compute every path that you can get to the destination in exactly 2 moves (this is done by computing every path that can reach a tile in the previous ...


1

Some pseudo brute force that just goes into all direction and stops on either length > 6 or repeated field function searchPath(x, y, z, gamefield, pathlength, pathtaken) { if (tile[x, y, z] == destination) { solutions.add(pathtaken); } else if (pathlength < 6) { if (gamefield[x, y, z] = false) { gamefield[x, y, z] = true; pathtaken.add(...


1

Inside your A* algorithm, you have a loop where you iterate over the reachable nodes neighbouring the current node under inspection. If the elevation disparity between the two nodes is greater than your threshold, it is not reachable. You skip over that neighbour, so the algorithm doesn't try traversing the edge between these two nodes. It might help if you ...


2

Disclaimer: talking from Unity game development experience. It is not about resolution... Base resolution has very little to do with responsive UI. UI elements can be up-scaled or down-scaled. Resolution pretty much only gives you sharpness (or more space if you don't scale your elements accordingly (would not recommend)). Personally, I choose 1920x1080 (...


1

Unfortunately there are so many different devices with so many different resolutions and aspect ratios that there is no one default screen size you can assume. So you have to design your game's UI in a way which looks reasonable well on any device some player might own. You will have to create a responsive layout where UI elements are positioned relative to ...


0

So is the problem that when the player is moving in both directions at the same time a collision is detected and the player stops moving? You can either redo the whole collision detection function which probably isn't a bad idea or simply try moving in each direction separately and see if that works.


1

Another solution is to pass the texture's dimensions into the PIXI.Texture.from() method. let texture = PIXI.Texture.from('img/character.png', {width: 256, height: 256}); texture.frame = new PIXI.Rectangle(0, 0, 86, 132); // display texture here Character sprite sheet After cropping with frame Other arguments accepted by from() can be found in PixiJS Docs....


0

You could set velocity for the box, apply force or directly change location.


0

Use breakpoints. Every major browser has those right now, and if you are using any decently supported toolset (e.g. using javascript in some other context) it should also have support. This lets you step through line by line and inspect whatever values you need to without having to constantly rerun your code with additional logging statements.


Top 50 recent answers are included