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

Padding in a vec3f array in WebGPU memory layout

I'm trying to write a WGSL structs parser (sort of webgpu-utils thing). In order to better understand the memory layout, I'm using wgsl offset computer as a helper. Having the next struct: ...
0 votes
0 answers
26 views

Looking for simple gravity + collision Javascript library for platformer game [closed]

I've been looking all over, but all the libraries I've found seem to fall into two categories: "Everything and the kitchen sink," or "We detect collisions, but don't actually resolve ...
-1 votes
0 answers
54 views

other objects are moving with player [closed]

I was trying to locate other objects in world space but they where moving with camera and I couldn't able to locate them, Camera is moving with Player Car but other Obstacle cars are also moving ...
-1 votes
0 answers
41 views

Spawning of enemies seems to be broken

I am working on a small video game in HTML, CSS, and JavaScript. The game is almost finished, but I am having a problem with the manner in which my enemies spawn. The following code is in the ...
21 votes
2 answers
7k views

What is a "normal" in game development

I'm new in Game development and probably this is a silly question. I had a look online but haven't found a clear answer, I did it bit quick but enough to evaluate that this is a confusing topic ...
0 votes
0 answers
26 views

How to trigger a local file download for a screenshot from a Unity WebGL game?

Is it possible for a Unity WebGL app to trigger a local file download - binary data generated in the app, somehow triggering a browser download?
-4 votes
1 answer
94 views

Why wont my code work

I have just started on a new short game and i am trying to figure out how to make a reward when i reach a certain value I expect that the counter starts at zero, and each time the button is clicked it ...
1 vote
1 answer
139 views

How do I react to a variable having reached a certain value?

I am a new coder and im trying to learn html. i have started working on a clicker game but im trying to figure out how to give a reward when my total clicks var has reached a certain value. the reward ...
0 votes
1 answer
68 views

Improve performance of server updating game state

I have a Node.js game that sends update packets to players every 30ms. The code I currently use works this way: Get the entities within each player's vision. Create a temporary object that stores ...
1 vote
0 answers
53 views

How to set pivot point for rotating a sprite?

Is there a way to set the pivot point for rotating a sprite? The default option seems to be arbitrarily chosen point on the sprite or the mid point. ...
0 votes
0 answers
74 views

How to properly overlay HTML over canvas with scaling?

If I have <div container> <my html overlay> <my game canvas> </div> The canvas has ...
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 ...
1 vote
1 answer
765 views

Help solving Uncaught Abort on HTML5 Build [closed]

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

Camera movement with player

I'm developing a game using the html5 canvas, but I've never used it before and I'm having difficulty creating a camera. The intention is that it is the same as agar.io, where the player is centered ...
0 votes
0 answers
37 views

How to implement 2D rigid body motion?

I'm already depending on two NPM packages for 2D collision and differential equations: sat rungeKutta I've a basic simulation structure, but don't know where to start with to use these two packages ...
0 votes
1 answer
347 views

How to prevent blurry pixel art when the camera is following a character?

I'm developing a top-down pixel-art game and previously I was having the camera follow the player like this in the camera's update function (called every frame): ...
1 vote
1 answer
675 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
2 answers
1k views

How to make 2D lighting in JavaScript

I am making a recreation of the 2D voxel game Terraria in JavaScript. Like most sandbox games, Terraria has lighting, but because I am using JavaScript, performance is going to be an issue. I have ...
0 votes
1 answer
51 views

Is it safe to store the state of a game in Javascripts localStorage?

I am going to be completely honest, this is not 100% about storing a game state in Javascript's localStorage, it is more to do with a utility program storing statistics. Since it can be related to ...
1 vote
1 answer
580 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
407 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 ...
0 votes
0 answers
18 views

Game character in the browser game appears on Android, but not on iOS

I have a problem with rendering the game on mobile platforms (the game is written on the Impact.js), the problem is only with the iOS actually, the screenshot below shows that the characters are ...
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 ...
1 vote
2 answers
344 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
160 views

Would it be possible to make a Game Genie like program in Javascript?

Game Genie was a tool for the NES that allowed users to input codes that were able to drastically able to change the mechanics of a game by getting CPU reads and replacing the game's response with its ...
0 votes
1 answer
87 views

Trying to calculate hitbox vertices for my game and adding SAT collision

I am currently working on a basic HTML, CSS, and JavaScript game as a freshman high school summer project. I am currently trying to implement separating axis theorem (I spent a lot of time learning ...
1 vote
1 answer
588 views

Resizing a tiledmap when using phaser

...
2 votes
1 answer
117 views

Where is the illusion of a moving camera perspective coming from in this rotatable cube model?

Just for fun, I had been attempting to build a model cube in vanilla JS that can be moved and/or rotated. What I was going for was the simplest possible representation (so, no adjusting for ...
0 votes
2 answers
477 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 ...
0 votes
0 answers
49 views

Handle roads following in a javascript game

In a browser game made in HTML5/Javascript, I would like to handle the move of units in real-time. But units would have to follow some predefined roads... Canvas seems better than svg to handle ...
10 votes
2 answers
4k views

Wondering if there is a more efficient way to store level data in my game?

I am trying to remake Super Mario Bros. in JavaScript and I am trying to figure out if there is a more efficient way to create and store the level data. I have created 1-1 and here's what the code ...
-1 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. ...
0 votes
0 answers
174 views

three.js shader to keep moving vertices of points cloud inside sphere

I am trying to achieve the effect of having a points cloud with moving points while also keeping them confined within a sphere of radius X. I have managed to do it without using shaders but I want to ...
0 votes
0 answers
21 views

How is it possible to create a texture atlas from a list of images? [duplicate]

Given a list of images how is it possible to place them on a square image, so they take up the least amount of space?
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
734 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
448 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
803 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 ...
0 votes
0 answers
34 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
0 answers
92 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
154 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 ...
9 votes
3 answers
32k 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
107 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
0 answers
32 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
89 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
602 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
48 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 ...
1 vote
1 answer
57 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
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: ...

1
2 3 4 5
29