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
0
votes
0answers
24 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. ...
-1
votes
0answers
17 views

How can i make my character shoot to the direction he is facing? [duplicate]

Im trying to make a game where a wave of enemies is coming towards a character and im trying to make my character , when i move up and press the shoot button , the character to shoot the bullets up , ...
0
votes
2answers
54 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
45 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
41 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
20 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
13 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
34 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
44 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
43 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
38 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
43 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
42 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
26 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
30 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
39 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
16 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
72 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
28 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
44 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
85 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
18 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
48 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
57 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
21 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
109 views
0
votes
0answers
30 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
33 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
43 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
66 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
38 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
0answers
15 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
131 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
83 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, ...
0
votes
1answer
52 views

Detecting collision between 2 rotated rectangles with limited parameters

Are there any function that can detect collisions between 2 rotated rectangles in javascript with this kind of information: ...
-1
votes
1answer
32 views

Converting Javascript to C# [closed]

I am trying to convert the following JavaScript code: ...
0
votes
0answers
25 views

Storing entities in a multiplayer socket.io/node.js game

Let's say the server stores each particle as its constituent information (i.e. a JSON of attributes like 'position') and the client stores each particle as a sprite for rendering. How should the ...
0
votes
0answers
51 views

Handling multiple resolution

I have been trying to handle different mobile phones resolutions for my game. But the scene is not fitting accordingly in some screen its perfect but in some other screens it is shrinking. My question ...
0
votes
2answers
51 views

Javascript Jumping Physics

I have asked questions for this project before, but the jumping physics are a bit messed up. I cannot jump unless I hold down the W key, and then it just teleports me upwards. Does anybody know how to ...
1
vote
0answers
56 views

Junk movement with steady 60fps on Web canvas

I'm new to building games on canvas, and I'm trying to create one. But I encountered a problem with sprite movements. My sprites move is smooth, but sometimes it starts to "jump". FPS is stable 60 ...
1
vote
1answer
41 views

How can I convert screen coordinates from a click to 2D scaled world coordinates?

I need a way to convert screen coordinates obtained from mouse clicks to world coordinates in my 2D game. To create a zoom effect controlled by the user, before drawing a model I will scale all of it'...
0
votes
0answers
35 views

How to apply toastr notifications when user get leveled up? [duplicate]

This question is about when user get leveled up the toastr will pop up. What I want to do is i want to put the toastr.js inside my script but I don't have idea how to implement. ** Link and Script **...
1
vote
1answer
35 views

How can I draw lines and curves on a canvas that's not rendered?

I need to draw lines and curves on a canvas that is not rendered on the screen but just updates the array of pixels that would otherwise be rendered. I need this to separate my game engine from my ...
2
votes
1answer
61 views

Issues with AABB on a platformer game

i'm facing an issue at the moment in my javascript/html platformer game that despite searching for this issue i can't solve. The problem is this: When i place two platforms next to each other and the ...
0
votes
2answers
56 views

Player fly's off of canvas when key pressed

I am fairly new to game development. I am programming a basic JavaScript canvas game. Whenever I press a key my player goes flying off of the canvas. Here is the controller code ...
0
votes
0answers
32 views

Full energy transfer between two identical objects

I'm trying to simulate a game like billiards / shuffleboard / curling where two objects collide and under a perfect direct hit all energy is transferred to the second object. Both ...