As of May 31, 2023, we have updated our Code of Conduct.

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
486 views

Do you need to know JavaScript to make games with RPG Maker?

Do I have to know how to code in JavaScript to make good games in RPG Maker MZ? I'm asking cause I know you don't really have to code in RPG Maker. I already tried some programming languages, so I ...
3 votes
2 answers
335 views

Why use sprite tile maps on the GPU in WebGL?

I'm trying to figure out the best way of rendering my layered tiled maps with WebGL, and have come across this tutorial several times: https://blog.tojicode.com/2012/07/sprite-tile-maps-on-gpu.html ...
0 votes
1 answer
720 views

Blend different biomes using linear interpolation

I've been scouring the internet for hours looking for a solution to blending biomes that have different amplitudes and frequencies together to create a seamless world. A recurring theme I'm seeing is ...
1 vote
1 answer
698 views

Help solving Uncaught Abort on HTML5 Build

For some reason there is a Invoke that is triggered when a button is clicked that causes my game to crash. Any idea how I can sort this out? I have plenty other Invokes and none has given problems. I ...
0 votes
1 answer
2k views

Calling setInterval from requestAnimationFrame causes enemies to shoot continuously

I am making a 2D canvas game in JavaScript. I am trying to make the enemies shoot a bullet every 3 seconds. ...
1 vote
1 answer
353 views

Behaviour of containers in Phaser 3 framework

I don't understand the behaviour of containers in this example: Phaser example The part I don't unerstand is line 41. Why is lastContainer assigned to newContainer? In line 40, newContainer is added ...
1 vote
2 answers
340 views

Rotated Sprites collision detection

I am trying to implement checkCollision function in my game, I used AABB method but the problem is that my sprites are rotated so it's not really precise. I could finely describe my Sprites with ...
1 vote
1 answer
1k views

How to rotate player to face mouse on canvas?

I'm building a basic game using plain javascript and I am trying to rotate my object to follow my mouse. I've tried getting the client's mouse X and Y then subtracting the canvas width and height ...
0 votes
0 answers
11 views

Mixamo -> Blender -> BabylonJS empty scene

I am following this tutorial on babylon.js and managed to export a .babylon file, but when I load it with: ...
1 vote
1 answer
482 views

RayCasting with Mode7

I'm trying to join the mode7 algorithm with RayCasting. For mode7, I'm using a simple rotation matrix to implement the rotation. The result is a little strange and I can't fix it. Do you know what is ...
1 vote
1 answer
403 views

How to perform a sliding collision between a square and a circle?

Please point me to the duplicate if this has been asked before. I couldn't find it. Basically, I am creating a 2d top-down game where the player is represented by a circle, and the tiles are ...
1 vote
0 answers
29 views

steering behaviors collision avoidance: vehicle shaking before arrive at destination

I have made a test sketch of collision avoidance using javascript, as you can see right here. I want the vehicle to move to the clicked location, avoiding obstacles on the way. It is working, but not ...
2 votes
2 answers
8k views

How to lock aspect ratio when resizing game window in unity?

I want a scalable game window that when resized stays at 16:9 aspect ratio. The goal is for the user to be able grab the window on the right or bottom and resize it. The game should adjust the ...
1 vote
2 answers
94 views

How to publish WebXR game on Quest or Steam stores?

I would like to develop a simple and small game for WebXR so that Quest, Index, etc. can play it. I would eventually like to be able to put it on the Quest store and Steam. Is there a way to publish a ...
8 votes
3 answers
31k views

How to rotate an image on an HTML5 canvas, without rotating the whole canvas?

I want to rotate single sprites on the canvas without rotating the whole canvas. I also don't want to create a new canvas for each object I have. Also, it would be interesting to know which solution ...
1 vote
1 answer
59 views

How to draw/calculate a parabolic arch to hit stationary target in Javascript

First off I must admit I'm really not good at math and am trying to learn but have had a hard time finding examples someone like myself can follow. I'm trying to figure out how to draw and calculate ...
0 votes
2 answers
463 views

Recognising when a user is clicking below a particular sprite

I have a game, built using pixi.js, where I want to run some code every time the user presses below a certain sprite. I am handling the press event using hammer.js. The problem is that the y attribute ...
4 votes
1 answer
1k views

HTML5 Canvas - Drawing with Floats

I'm trying to implement a game where you have car moving along a line in HTML5 Canvas. Using a little bit of trigonometrie I managed to get the right x and y coordinates to add to the coordinates of ...
0 votes
0 answers
23 views

Player Jumping inconsistent and bugged

I am having a lot of different issues while coding player jumping for my game. Sometimes when the player hits the jump key the jump is delayed and/or doesn't jump to the heigh it usually does. I am ...
0 votes
0 answers
59 views

How can i rotate an object based on the finger position?

I am using Lens Studio to build an AR effect and trying to use the position of the hand tracker fingertip to make a cube rotate. For example, as I move my finger on the x-axis the cube rotates in the ...
0 votes
2 answers
248 views

How to create global function for all .JSLIB files?

I can't understand how to work with .jslib files. I don't understand the syntax of this type of file. Also I couldn't find any easy explanation of it The problem ...
0 votes
1 answer
40 views

Adding requestAnimationFrame in isometric Tile grid Code is not working

Hi There this is my first Post on gamedev, and i hope everyone understand what i want :) First of all my Code is an very Personal Version from one Github Isometric Map. I Tryd now 2 Days to Add the ...
8 votes
2 answers
2k views

Collision detection between draggable object and world objects?

I have a game I'm making in Javascript that will involve combining items by dragging and dropping them onto each other. Think Alchemy or similar. So far, so good, but I hit a snag while trying to ...
1 vote
1 answer
53 views

How to instantly break method call?

I'm making 2d Mobile game using JavaScript. I have method that controls every character (Dumb AI) on battleground. It using recursion to call another action. I want to add debuff system and had little ...
1 vote
1 answer
576 views

Resizing a tiledmap when using phaser

...
1 vote
3 answers
3k views

Object goes straight through game object without colliding

The "shot" is supposed to collide with the left bumper and then be destroyed, but the shot goes right through it. Both objects have a box collider. The following is the code I am using: ...
0 votes
1 answer
31 views

Why is this code keeping the listener which should be removed instead?

I am having some issues figuring out why this code still lets btn_1 call the function setstate3(). There is a function ...
0 votes
1 answer
14 views

why does my button lose the changed cursor and mouseover behaviour as soon as I attach a class to my file?

Using adobe animate cc - exporting to HTML5 and coding in JS (or at least trying to) If I just hit cntrl+enter in adobe animate the button works as expected. If I run the app from a web server using ...
0 votes
0 answers
57 views

How can I seamlessly loop a video (webm since it has transparencies) in javascript canvas?

I am trying to play a video from beginning to 10 seconds, then loop the video from second 3 to 10 untill a key "c" is pressed. if it is pressed once, play the video from where it is ...
0 votes
0 answers
45 views

How to distribute values in a grid based system

Context: I'm working on a simple environmental simulation in Javascript. I created some simple plants that grow, reproduce, and pass along their traits to their offspring. The simulation was pretty ...
0 votes
1 answer
100 views

How to stop player when they hit an axis aligned bounding box?

I'm in the process of creating a game using electron and HTML5. It's going to be a pretty basic story-based platformer, but I'm ...
0 votes
0 answers
34 views

How do i get this web app to use the up joystick button as an input

There is this reaction time test app that calculates the reaction time from the time you press a button, it works with the joystick buttons except for the directional buttons, this is the app: https://...
1 vote
1 answer
126 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 ...
29 votes
4 answers
24k views

Simple noise generation

I'm looking to generate noise that looks like this: (images courtesy of Understanding Perlin Noise) I'm basically looking for noise with lots of small "ripples". The following is undesirable: Are ...
0 votes
0 answers
61 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 ...
1 vote
1 answer
238 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
260 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 ...
2 votes
1 answer
540 views

Algorithms for positioning rectangles evenly spaced with unknown connecting lines

I'm new to game development, but I'm trying to figure out a good algorithm for positioning rectangles (of any width and height) in a given surface area, and connecting them with any variation of lines....
0 votes
1 answer
98 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: ...
2 votes
2 answers
425 views

Cocos2d JS - Getting vector reflection

I'm working on a small Breakout clone using Cocos2D-JS, without the use of a physics engine. One of the things that baffles me was how the ball bounces. My friend came up with this: inputVector - ...
6 votes
1 answer
2k views

How to draw a global day night curve

I see many applications which have world-clock map, and I would like to make my own to enhance some of my mobile apps. I wonder if anybody has any knowledge where to start, how to draw a curved shadow ...
0 votes
1 answer
126 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
1 answer
796 views

How to rotate an image around its center point in a JavaScript canvas?

I have this function to get the rotation angle from my sprite and a target: ...
1 vote
1 answer
486 views

Character Movement - Canvas Character - Javascript

How do I change the arrowkey movement so that is based off of the click of the buttons instead? Cheers ...
3 votes
2 answers
489 views

Diamond square texture: too-diamond-ish?

I wrote a small JavaScript implementation of the Diamond-Square height map/texture algorithm and the result is much more industrial-looking than I expected. I can trace a diamond pattern throughout (...
0 votes
1 answer
429 views

Detect how much mouse has rotated in a circle around an XY point

How can I detect if the mouse cursor is moving in a circle around a target, and calculate how many turns it's done? For example, if I rotate the mouse 4 times around a specific XY point on the screen, ...
1 vote
2 answers
1k views

How can I publish a Python game on itch.io as html?

I'm making a game with Python, using Pygame. I want to publish my game on itch.io so that it's playable in the browser. Is there a way to do this? If so, how?
0 votes
0 answers
59 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 ...
0 votes
1 answer
97 views

Using a JS Query to work as an HTML Anticheat?

So, I have a project, its a "cookie clicker" by definition, and I wish to work out how I can protect the game from users being able to edit ...
0 votes
1 answer
58 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
2 3 4 5
28