Questions tagged [javascript]

"JavaScript (sometimes abbreviated JS) is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles." From Wikipedia. http://en.wikipedia.org/wiki/JavaScript

Filter by
Sorted by
Tagged with
1 vote
1 answer
104 views

Randomly distribute damage among allies

Let's say I have regiments of varying sizes, 500, 1000, 4000 troops. I want to distribute 1000 troops worth of losses to them so that in aggregate they lose 1000 troops. I want to do it as a ...
  • 167
0 votes
0 answers
50 views

How to create a basic strategic AI?

I started creating a Vue3 version of the classic Sid Meier game Colonization. I have the basic player mechanics in place and even created a map editor. So I have 3 of the 4X in place: Explore, Expand ...
  • 101
1 vote
1 answer
139 views

How can I protect against a cheater changing variables on the client?

I built a multiplayer fighting game with impactjs, socket.io and nodejs and faced with "change variables hack" (I want to call it like this). All my current logic with jump, running, shoot ...
0 votes
1 answer
72 views

How to spread circles evenly around a point?

In my game there's a part where a bunch of circles need to evenly spread around a point. Like in this demo below: ...
0 votes
1 answer
93 views

Algorithm for taking the shortest path between two XY coordinates

I am making a simple game in Phaser (but the library doesn't really matter). I have an enemy that is moving towards the player on a 2 dimensional grid. I have written some code that makes the enemy ...
  • 103
0 votes
1 answer
44 views

Invisible sprites with requestAnimationFrame

I'm trying to animate a sprite sheet. I have a single image, and multiple objects of the same type but drawn at different locations on the canvas. What I'm trying to do is have each object move with ...
0 votes
0 answers
35 views

Octree build time crashes page for complex mesh

Using the standard three.js FPS example of octree implementation with a more advanced mesh, crashes the page on load. My first idea is to write a few functions to save the octee data to a file, then ...
  • 101
0 votes
1 answer
54 views

How do I go about creating images, which are units with traits?

Lets say there are 5 units, displayed as images on an html5-canvas. Each image (unit) has a different size. For the game I need to know the size of that unit, and also it's middle point. How and where ...
  • 1
0 votes
1 answer
97 views

How to send a JS game using a Discord bot?

I have made a JavaScript game. Now I want to make a Discord bot that embeds it in a message, so a reader can click on the embed to play the game inside the chat. Something similar to this Snake game. ...
0 votes
1 answer
84 views

Efficient calculation of billboard sprite transformations

I'm currently adding a billboard mode to animated sprites and static sprites in my 3D engine. The code below works fine, but I want to know if a more optimized solution exists. I've heard about ...
  • 3
0 votes
1 answer
37 views

Remove 2D images from layer where overlapping layers hide them completely

I'm creating a 2d game (engine written in JavaScript) with layers system. I would like to have some post process to optimize the images and the layers. If there is too many images in one layer it ...
  • 147
0 votes
0 answers
34 views

Streaming animation data via WebSockets

I have a 3D character model and I am streaming animation frames from a server to the client via a WebSocket (I am using three.js). I need some advice on how to correctly integrate the streaming data ...
  • 1
0 votes
0 answers
55 views

How can I fix this wall jittering in capsule to octree collision?

In the three.js example for a first person game https://threejs.org/examples/?q=game#games_fps you should notice that at the corners it gets stuck, seemingly because it collides with one side, then ...
0 votes
0 answers
81 views

Game networking with physics different client and server languages

We are currently having only "turn based" multiplayer games in our party game lobby system. Now we considered to add realtime multiplayer games as well, for example golf in 3D. Our current ...
0 votes
1 answer
74 views

Multiplayer game - Player position updates transmission pattern

I'm building a very basic 3D multiplayer game using Three.js and Socket.io where all the player does is move in an environment. Considering there will be ~ 100 players in a single room and all data ...
0 votes
0 answers
89 views

How do I respond to AABB collisions?

I'm coding a physics engine in Javascript. Forces, Gravity, Friction, AABBs are taken care of. Now, the big question: how do I respond to AABB collisions? Right now, when an object collides, it prints ...
  • 1
0 votes
0 answers
50 views

How to hide unused quads in quadtree that are not close to the camera?

This is my Quadtree implementation in threejs. It works fine when the camera passes some threshold and the quads need to be created. The problem is how can I hide the quads that are not needed anymore ...
1 vote
1 answer
39 views

How should I share the states amongst all the executions of a Behaviour Tree triggered from all ticks?

I'm still learning about Behaviour Trees and my understanding of the "blackboard" is essentially a state object. When passing the state object through the ticks to the function calls (which ...
  • 417
0 votes
1 answer
43 views

Creating a Game in Three.js do i share camera, scene objects?

Im creating a game with React and Three.js and vanilla Javascript, i have several clases, representing objects in the game, do i need to create a camera, scene, renderer for each class or i simply ...
1 vote
0 answers
99 views

Aircraft simulation

Trying to get a "semi" realistic aircraft simulator. I'm pulling my hair out because I just can't get the math right. I'm not looking for super realistic but want to at least get some ...
  • 111
0 votes
0 answers
34 views

How can I run Javascript + WASM on game consoles?

Is there a way to run Javascript and WASM on game consoles or platforms that don't support JIT? I see V8 as a good option except that its JIT-less mode doesn't support WASM as far as I know.
0 votes
1 answer
51 views

JS 2D top down movement doesn't act as expected

I realise this is very similar to other 2D movement questions already posted but cant find a solution that fits the behaviour I'm looking for, so I'm posting in the hope that someone more ...
1 vote
0 answers
301 views

How to make an update loop in a Node.js game server

I'm making a multiplayer game with a Node.js server, and I'm searching for how to write the game loop. I'm currently using a setinterval every 15ms, but someone ...
0 votes
0 answers
49 views

How to render the border of a collection of many overlapping radii on the surface of a sphere

I am developing a 3D game with THREE.js where all players are represented as points on the surface a sphere. The player A can move on the surface of the sphere within a radius of X meters. If another ...
  • 1
0 votes
3 answers
142 views

How to prevent a huge backlog of physics calculations from freezing browser when tabbing out of browser game?

I'm developing a browser game and am using the timestep implementation from the famous Fix your timestep! article. It works perfectly, but there is one problem. If you tab out of the tab and then come ...
0 votes
1 answer
111 views

Struggling with breadth first search for hex grid

I cant seem to get breadth first search right. Ive gone through redblobs implementation guides of hex grids and have that all figured out but pathfinding is proving to be difficult. So I have a search ...
0 votes
1 answer
140 views

How to make a cubemap image with perlin noise?

Recently I just finished a program which makes a plane image using perlin noise. Now I want to make that image a cubemap image. This because I want to apply it to a planet (which was made from a cube)...
1 vote
1 answer
201 views

Besides 3d, why would I need to use a canvas instead of using plain css and html?

Purely speaking for the use of 2d. First off, redrawing the canvas on every frame seems quite inefficient. Even when you can create multiple to not redraw everything etc. CSS animations to move ...
  • 13
0 votes
2 answers
108 views

How to efficiently do one-to-many collision checks?

Scenario: 4 players, each can have from 1 to 100 pawns. I want to be able to efficiently check if Player 1's pawns collides with Player 2, 3, and 4. Currently I have an AABB check, done first on ...
  • 15
-1 votes
2 answers
59 views

How to interpolate angular data properly

I have been trying to interpolate raw angular data in degree (for a flow map grid) but any attempt fails because there is always two path, and I can't figure out how to interpolate on the shorter one ...
  • 197
0 votes
0 answers
62 views

Three.js Animate Text error geometry.faces

In this three.js Text example they animate text, i am trying to implement it on React/Three.js but i got the error TypeError: can't access property "length", geometry.faces is undefined in ...
0 votes
0 answers
144 views

Issue with Steam Web API

So, I have been working on this for several hours, but so far it doesn't look like there's going to be a solution. ...
0 votes
0 answers
35 views

How to set boundary for 3D objects in Javascript

[EDIT] Found the answer, solution in comment I have this 3d first person game made with Js/css. I have to set boundaries or clipping to the map as the character moves around the 3d object, I only need ...
0 votes
1 answer
119 views

Alternative to redrawing the background canvas for camera movements?

I have multiple canvases placed on top of each other for different layers (background, game objects, foreground). I was expecting this to allow me to have the background and foreground update at a ...
  • 3
0 votes
1 answer
113 views

How to add a texture inside a specific area in a canvas in javascript?

How could I draw a texture between the bottom of the canvas and below the green line, in javascript? I dynamically add coordinates in a canvas, then draw lines between these points. EDIT : Solution: ...
  • 11
0 votes
0 answers
37 views

Javascript Game Collision Shaking

I have a problem with collision shaking. The problem doesn't come from the collision, but from client side (sometime the it's smooth and sometimes not). Here is a video to show it : https://www....
1 vote
0 answers
261 views

What is causing my touchstart event to end while I'm still touching the screen, and how can I fix that?

What I'm trying to do: I'm trying to add touch controls to games created with the html canvas and JavaScript so that they can be used on mobile / tablet devices. The controls should simply move a ...
0 votes
0 answers
50 views

Right Axis warps on 3D planet's equator

I am using JavaScript and WebGL for a game which rotates a spaceship around a 3D planet. Below is the code for rotating a sphere spaceship and sphere planet. I looked over your camera code and now it ...
0 votes
1 answer
144 views

Trouble using delta in my movement function

...
0 votes
1 answer
126 views

Interpolate colors between vertex in a plane

So I have this plane generated with two different Perlin noises. It has mainly 3 regions, divided by color. I want to smooth out the lines, to create a "gradient" so there are no abrupt ...
  • 5
0 votes
1 answer
324 views

Assign biomes to areas with a Voronoi noise function

I've created this terrain based on a Voronoi noise function: This is how it looks without the elevation: I want to assign biomes to the polygons following certain rules and use the slope on the ...
  • 5
0 votes
0 answers
44 views

How should I modify my terrain according to the biome? [duplicate]

I have this terrain I generated using Perlin Noise layers whose colors are applied based on the height of the vertex, just for reference before I am done being clear about how I will implement the ...
  • 5
0 votes
1 answer
716 views

How to calculate item drop rate?

I am developing an RPG that will be played in the browser, so far the development is going very well. However, I reached a point in the project where I'm "stuck" because I can't find a good ...
  • 197
0 votes
1 answer
651 views

find one meter to scale in earth heightmap

I have a heightmap that scales from 0 to 255. the map is only for elevation (discluding water and ice) what would be the appropriate way to calculate the scale of one meter? heightmap below
0 votes
1 answer
73 views

Why does my enemy go the other way when the player moves more than a few pixels away from (0, 0)?

My enemy initially goes to the player when the game starts, but when the player moves away from its starting position, it goes away. Code: ...
1 vote
1 answer
103 views

Cannot properly get 2D top-down tile-based collisions

I am using HTML, CSS, and plain JavaScript for a 2D top-down tile-based simulation. I am trying to do collisions in which, for example, if I move up and hit the ceiling collision tile, I cannot ...
  • 35
0 votes
1 answer
91 views

Technology behind retrogames.cc video games

What is the technology used in embedding the games on the retrogames.cc site? I managed to see an HTML tag, but I don't know how they are inserted, are they simulators of real games?
  • 101
0 votes
0 answers
30 views

Hashing images like CDs for Monster Rancher style randomizations

I have been kicking around an idea for creating a web based game where they can upload images in order to create random monsters/items. This I thought was most similar to how monster rancher ...
1 vote
0 answers
92 views

Jittery entity Interpolation when tick-rate exceeds framerate

In my current game implementation, our game servers send data to the clients only 10 times per second (~every 100ms). However, due to recent changes, we are now expected to change the server tick-rate ...
3 votes
1 answer
104 views

Storing stateful function-based actions in a JSON

System: My game uses an "ECS + event queue" architecture where every tick, various events change the state of JSON-able data. Plain JS objects. Problem: I want to be able to save the game-...

1
2 3 4 5
28