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
2
votes
0answers
57 views

Game runs at different speeds in Chrome versus Firefox

I am using Box2D for physics on the server side. Player position is updated on the server, so there is nothing the client can do except give input. But running game in Chrome only, the player moves ...
0
votes
1answer
8 views

Determine when a PIXI texture is loaded to clone it

I'm in the latest PIXI v5, where my texture is made like let texture = PIXI.Texture.from(TEXTURE_URL). The texture isn't loaded synchronously- Pixi just covers ...
0
votes
0answers
18 views

Account for scale offset?

I have an odd situation where I know the position of an item on a mouse click and I know the panning state of a 2D camera pointing at it. So what I do is render an object at the point in which the ...
0
votes
1answer
34 views

how to calculate resulting velocity and angular velocity rocket has on center of mass

The issue i am having is that i can't seem to figure out how to apply force from a rocket to a bodies center of mass. *Edit This is in 2D e.g. Let's call the body 'ship' the 'ship' is 1000 (...
0
votes
0answers
8 views

Using three.js, how can I set up a headless version of a game state on a node server like the babylon.js-NullEngine?

I have been working towards creating a multiplayer three.js fps game and am planning to only do client-side prediction in the browser. On the other hand, I am using Node.js, Express.js and Socket.io ...
0
votes
0answers
12 views

How to go to the next level when a model hits a certain spot

I'm trying to make the ball go to the next level automatically, without pressing a button.
0
votes
1answer
22 views

Fixed vs Fixed Collision on ImpactJS

I'm trying to implement a collision on ImpactJS entities that both will be stopped when collided and being pushed. This will be exactly similar to player to player collision on top down games such as ...
1
vote
2answers
77 views

How can I adjust the speed my character jumps at?

I've applied this method How to make a character jump?, like: ...
0
votes
0answers
10 views

How do I scale a group in Phaser 3

In Phaser 2 we scale a simple by setting the scale property as explained in docs: https://phaser.io/examples/v2/groups/group-scale But there is no equivalent in Phaser v3. The possible url https:...
0
votes
1answer
66 views

How to encode a save game / game state as a string?

I'm building an HTML game. For this game I want to implement a save-feature that should work like in some already existing games: The user can chose export, this ...
1
vote
1answer
38 views

Same scroll speed across devices with different DPI

I am creating a simple game in JS, something like the flappy bird :) For pipe scroll, I am using a linear tween. I noticed that the speed of the pipes are different across different smartphone ...
0
votes
1answer
54 views

2d Tiled Map with images in Javascript

I'm trying to create a tile map with simple 2d images (30x30). I restarted the project from my previous post, and instead of using someone else's code, i though I would learn more to start from ...
1
vote
2answers
85 views

How to create a map array with multiple layers?

I’m trying to create a map array without using JSON because I want to dynamically generate the map: ...
1
vote
0answers
37 views

Problem with collisions detection on canvas platformer

Having a lot of trouble with my collision detection in my platformer. If you go straight to the right the block will float. Also the corners let the block sink right through and the walls are sticky. ...
0
votes
2answers
57 views

How can I delete an object when it's not stored in an array?

I have a boss appearing in my game, but since it's only one character I didn't put it in an array. Now I'm trying to make disappear if its health is less or equal to 0 but I don't know how to do that. ...
-1
votes
2answers
51 views

I need help with calculating the angle my character is aiming at

So im doing this program where i want my hero to shoot to the direction its facing , but for this job to get done i need to calculate the angle my hero is facing with Math.atan2() , atleasts thats ...
1
vote
1answer
44 views

Collision detection between two arrays with nested loops: why do I get a crash?

I'm creating a game where waves of enemies are coming to me and I have to kill them. So far, I'm doing great: it took me hours to come up with this nested loop to check for collision detection and ...
0
votes
0answers
29 views

Car physics: incorporating lateral forces for high-speed steering

I'm making a car simulation in Javascript and I am using this website to help me with the physics: http://www.asawicki.info/Mirror/Car%20Physics%20for%20Games/Car%20Physics%20for%20Games.html The ...
0
votes
0answers
16 views

Javascript or Animation in general tween, spring, mouse tracking, mixing

Back story. I am a web developer and i can pretty much do anything on the web. When i first started doing some programming it was in flash actionscript 3, and i was 14 and now i am 29 and still i ...
0
votes
1answer
54 views

frame rate drop in html5 game

i have Incorporated gravity mechanics and collision mechanics to my game. the game works fine for some period of time after that i am getting significant amount of frame rate drop.i am doing some ...
1
vote
1answer
45 views

2d array with empty elements

I am working on a game with a number of different grid components. Each grid would be about 15 squares wide by 15 squares tall. Each of the squares may either contain an item or not. Is there any way ...
0
votes
0answers
61 views

Moving player one tile at a time (Javascript)

I've been watching this tutorial and found the code works flawlessly. Although, there is something he doesn't cover in the video. How to move the player one tile at a time. Every tutorial I've found (...
0
votes
0answers
42 views

Cant get my tabs to hide in my game

So I have tried alot https://codepen.io/tmanrocks999/project/editor/DKNEEv heres the gist of it. i want on launch for the game to only have the home tab available. after 1 rebirth hometab and ...
0
votes
1answer
45 views

makeing a quest system in a html clicker. need help making repeatable quests and quests being done

So i have a pretty good clicker quest system in place( click/ use spells/collect stuff etc) but im having a hard to making it a reward system. The reward should only go off once then the quest should ...
1
vote
1answer
47 views

Using a setTimeout to Jump

I am trying to make a jump function. I am making a game in html5 canvas with Javascript. I have gotten the player to move. When making the jump function I decided to use a timeout to reverse the ...
0
votes
0answers
32 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 ...
1
vote
1answer
37 views

Problem with making camera follow player in Javascript

So I'm testing a few things in Javascript and something I was testing was making the camera follow the player. When I move the player, instead of the dots going away from the player, they follow the ...
0
votes
1answer
56 views

Hideing tabs in a clicker game

So i think i have a good system for this but its only working on the first tab. its really confusing me i tried a bit of ways to fix this. https://jsfiddle.net/h3fo7rL9/10/ scuffed fiddle with my css ...
1
vote
1answer
17 views

Changing JavaScript Player Object based on keypress

I'm currently working on a basic JavaScript top-down shooter and I've run into a dilemma. I'm trying to implement a basic toggle weapon system however when I press the key it changes the weapon ...
1
vote
1answer
93 views

Making a way to fight monsters in my clicker game

I want a working next and previous button for killing monsters http://prntscr.com/o375y7 http://prntscr.com/o37609 Im new to this concept so i don't know how to go about doing this. html code(all i ...
0
votes
0answers
37 views

Client side prediction in 2D rigid-body physics

I'm currently working on 2D rigid-body physics multiplayer game using Matter.js for physics (both the client and server side) and Phaser3 for rendering. Both the server and the client run the ...
1
vote
2answers
52 views

Select Neighboring X or Y Tiles

I have a randomly generated set of tiles, and I am trying to select neighboring x or y tiles to perform functions on them based on if they are a certain value of tile, like so: ...
1
vote
2answers
89 views

html/ javascript shop

Im new to drop down menus. How can I make a working shop in html/javascript. I have this so far http://prntscr.com/o15oj7 . I want help with the selling of a material part. i know i should use if ...
1
vote
0answers
21 views

Where to store constantly changing game data such as duels data?

I'm making a discord bot which allows players to collect and duel cards. All the cards, players and other data is stored in MongoDB but where should I store duels data? Duels data will keep changing ...
0
votes
2answers
56 views

How to get projectile direction vector in a 2d grid?

I am having trouble figuring out how to trace the path of my projectiles in an Asteroids clone. Currently the ship is locked to the center of the screen and can be rotated a full 360 degrees. I know ...
2
votes
1answer
68 views

How do I rotate individual shapes on an html5 canvas?

So I am doing a basic Asteroids clone as an intro to HTML5 canvas. I want to be able to rotate the main player while leaving the other objects on screen alone. Currently I am using transform and ...
1
vote
1answer
40 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
2answers
111 views
0
votes
1answer
84 views

How to move an object in a heart shape pattern in javascript?

How can I move an object in a heart shaped pattern? I have a move(x, y) function that I can use to move the object, but how to I make a function that will move the object in a heart shaped pattern, ...
1
vote
0answers
30 views

Get return of asynchronous callback since module export- Nodejs

Server: require('./MovimientoJugador')(); var camino4=MoverJugador(startX,startY,endX,endY,mapa2); console.log("Camino: " + camino4); MovimientoJugador: ...
0
votes
0answers
22 views

Make players Rigibody move in direction its going?

I have my snowboard character which I am trying to fix the movement for. At the moment, The player is using transform.forward on the rigidbody to move forward. If my player turns around and faces up ...
0
votes
1answer
40 views

How to handle a scrollable map and player coordinates

I have a large map that a player will navigate over. Currently, it is just a single background image, but I would like to make it tiled map. How do I properly keep track of player coordinates? ...
0
votes
0answers
48 views

Using dom elements for game interaction - slow performance

I have a need for my html5 game (using melonjs) to allow users to click tile areas on the map. The idea is it will show a css styled hover area. The browser tested is chrome. I could do this natively ...
1
vote
2answers
68 views

How to get the Javascript equivalent of GameMaker's `hspeed` and `vspeed` given only `direction` and `speed`?

I'm using a NodeJS server to control NPC movement in a multiplayer game, and when they get too close to the edge of the room I need to reverse either the horizontal or vertical components of their ...
0
votes
1answer
57 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
1answer
27 views

Camera Sensitivity in PointerLockControls to match actual games

I am creating a FPS game online. I want the user to be able to use a sensitivity they are familiar with from games they've played. In this case, I want them to use their Fortnite sensitivity. I am ...
1
vote
0answers
39 views

How can I get my player's character to slide along a rail?

I am creating a snowboarding game and would like my player to be able to jump on a rail and move along it if it lands on it. I have no idea how to approach this. I have already tried using ray casts ...
1
vote
1answer
135 views

Is this a reasonable method of detecting JS memory hacks?

I'm working on a single-player browser-based RPG in my free time. I do allow for saving the user's game on the server, but the game is largely going to run locally and I therefore acknowledge that it ...
0
votes
0answers
41 views

Stuck at Goomba's speed and cancelling animation at game over

I'll try to be as precise as possible. First Issue: If you look in the code, I have a drawObjects function which calls collisionDetection function. Inside collisionDetection if player(mario) touches ...
2
votes
1answer
90 views

Click on an isometric plane and obtain normal coordinates

I have photos distributed as cells. When I click, I get the corresponding row and column. console.log("Col:" + X + "Row:" + Y); When applying an isometric view conversion like this: ctx.translate(0, ...