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

Spawning objects inside rectangle JS

I'm making a JS game "Monopoly", where I spawning players in random position inside a rectangle. I need a formula that spawns circles INSIDE a rectangle, without being outside. Here what I have tried:...
1
vote
1answer
19 views

Completely Pixelated Font in JavaScript Canvas?

I'm making a game with a canvas scaled up such that each pixel is pretty big. I want to display some pixelated text without anti-aliasing but I have idea how I would accomplish this. Is there I way ...
0
votes
1answer
31 views

My HTML Canvas went blank

I tried to draw Mario Sprites in my HTML Canvas, but it always went blank. Anybody knows why? ...
0
votes
1answer
19 views

I can't clear the paint image in my Canvas

I'm trying to make the Mario move, but somehow it leaves traces behind, can anybody help??? ...
0
votes
0answers
29 views

Jumping a image in javascript

Which is the most efficient way to animate an HTML <img> element in vanilla javascript so that it jumps and falls back with acceleration. Edit: Im adding ...
0
votes
0answers
12 views

How to move 2D obstacle on Z axis in Javascript and HTML canvas?

I am trying to make a 3D-ish game where the player must dodge obstacles coming at them on the z axis. I have been trying for a long time to find a way to make it look like an object is moving on the Z ...
0
votes
0answers
18 views

Unity WebGL Canvas only loads on select machines

https://herbertjoseph.com There is a WebGL build in the background of this site, and it doesn't seem to laod on my iPad. I've asked a few people to visit and check it out, and some have said that the ...
2
votes
1answer
38 views

My HTML canvas keep flickering

I'm trying to create a game in HTML canvas, but somehow it keeps flickering, I've taken a look at the tutorial and I perceived that my code is more or less similar. Can anybody help me fix this? <...
-3
votes
1answer
62 views

What does this all mean for the enemy?

This enemy JS file in a space shooting game was part of tutorial but there was no explanation to what is does and more importantly Why. Can you please help me explain what the following mean in the ...
1
vote
1answer
39 views

How do I set bullets to shoot from the correct position on the sprite?

How can I set the bullets start position to shoot from the front right of the sprite? It is currently shooting from the top of the sprite. P.S. I'm doing a tutorial online with the sprite shooting ...
2
votes
0answers
556 views

Idle game: calculating resource generation/consumption

I'm making an idle game in the vein of Melvor Idle and I've run into a problem calculating the yield and consumption of resources while the user is away. For those who don't know, many idle games have ...
0
votes
1answer
20 views

Client Side Game Local Storage

I'm coding (or at least trying to code) a single player game in pure JS. I was wondering how I was gonna be able to write data without having the user setting up a server or a database, only way I ...
0
votes
1answer
28 views

how to join the body of snake in 2D snake game

i'm making a snake game in javaScript from scratch. The problem is that the snake looks disjoint(see image). How can I connect the body(rectangles) of the snake? here is the code of drawing snake: <...
0
votes
1answer
33 views

Phaser 3 - How to trigger an event every 1 second?

I have just started learning Phaser 3 and making a simple idle game, where you would gain x resources per second. What is the best/recommended way to do something like this? The two main ways I have ...
0
votes
1answer
118 views

Wall sliding in JavaScript; works, but gets stuck at corners

this is a follow up to this other question: How do I handle player collision with corners of a wall In inspiration of the code given in its answer, I tried to write some new code. Basically, in the ...
0
votes
0answers
38 views

html5 canvas isometric tile map

i need a help i have an Isometric Staggered tile map in Tiled (mapeditor.org). 100x100 tiles, 94x54px, 9447x2727px. total. How can i make this in html5 canvas ? var context = document....
0
votes
1answer
28 views

Implement spherical mapping for texture coordinates

I am using a texture of a world map and I am trying to put that image on a sphere made up of many triangles. Each triangle has points a,b,c with their own (x,y,z) coordinates. I am trying to use the ...
0
votes
1answer
131 views

Cap Framerate in the asynchronous world of Javascript

I'm developing a game in JavaScript & HTML5 with CreateJS. (I doubt you'll need CreateJS experience to answer this question, though) My main game loop function is initialized and run using the ...
0
votes
0answers
19 views

Making a radial gradient visual range

I am currently working on a project in p5JS. So lets say i've got a texture and top of it, i've got a radial gradient that is overlapping on the texture. I want to make this like a cool vision range ...
0
votes
1answer
37 views

How to make controlled exchanges in an online-game?

There is an online game in which you can collect things of different values: ordinary, epic, legendary. The cheapest things are ordinary, the more expensive are epic, and the most expensive are ...
0
votes
0answers
16 views

Playcanvas with CSG

I want to use library csg.js with Playcanvas game engine to make some curves but don't know how to implement CSG (constructive solid geometry) in Playcanvas
0
votes
0answers
16 views

How do i Shoot a Projectile towards the Cursor? [duplicate]

I'm making a game and just wanted to know the easiest way to setup spawning projectiles that head in the direction of the cursor relative to the player.
0
votes
1answer
55 views

2D engine design/architecture: transformations

Hello! I'm working on this hobby little 2D engine in JavaScript because I want to learn how all this things are implemented and architectured in general. Internet is full of resources but most things ...
0
votes
0answers
20 views

conversion between world space and screen space

I am making a multiplayer game with gravity mechanics and planetary motion. I started by hard coding coordinates according to canvas size but now I am realizing that for different resolution planet ...
0
votes
0answers
17 views

Planck (rewritten of Box 2D) - Two sensor collide

I want to print "on" when two sensors collide. This code is printing "on" in any fixture collide. I just want for 2 sensors. ...
0
votes
0answers
55 views

How to make a minimap in javascript (p5.js)

So i have a game and i want to add a minimap on the bottom right corner. I have seen how to do it with html javascript, which has the ode written in index.html, but i want to write the code in a .js ...
0
votes
0answers
10 views

Planck.js (rewritten of Box2D.js) - 8 direction box movement

I have a box in Planck.js. I want to move this box with some keys. How can I do that? My code: ...
0
votes
0answers
22 views

is there any way to disable the obnoxious native iOS safari scroll to url bar and notifications behavior?

I have a feeling what I am about to will not be possible, because well... Apple. I am making a full-screen web based game, and I have a 8-directional virtual joystick on screen (a circle divided into ...
0
votes
1answer
65 views

How can I fix sprite vibrating randomly which is moving towards the mouse while using camera.position set to the sprite as the center?

So, when I use camera.position.x = player.x; camera.position.y = player.y; to set the center of camera to my sprite, the code doesn't work as intended to. It's ...
0
votes
1answer
47 views

Launch event at the end of an animation with phaser 3

I'm starting to develop in Phaser 3, and I'm really a begginer. I'm trying to make an attack move of an archer sprite, but I cannot make it work right... This is how I have defined the things ...
0
votes
0answers
32 views

Make 2d camera rotate around the player

I'm making a simple 2d javascript engine based on a scene graph (all game objects are containers whose children live inside their parent's coordinate space). My camera implementation works by setting ...
0
votes
0answers
24 views

Platformer collision detection problem - player snapping onto sides [duplicate]

I am having problems with collision detection. I am trying to make a simple platformer but when the player is falling or moving too fast it sometimes detects the wrong collision side. I am getting the ...
0
votes
1answer
98 views

How to get the address of a nearby square on a chess board?

I'm making a chess game from scratch and I got stuck. So far I have all my figures placed, I have the positions set, I've already done the collision detection and everything. When I click the figure ...
2
votes
0answers
18 views

Javascript: Eventlistener 'keydown' not registering all keys pressed when holding down other keys [duplicate]

Sollution provided in the comments. The issue is that my keyboard has what is called ghosting issues, this means it doesn't support some key combinations when pressed together. When the user holds 's'...
0
votes
1answer
22 views

Any way to set drag events on a phaser 3 group?

I'm trying to set a drag event on a phaser 3 group, but I wasn't able to achieve what I want. I was reading some phaser 2 blogs, and they said that it isn't possible to set a group a drag event. Can ...
0
votes
1answer
42 views

setTint() on half image

I'm developing a game where I need to paint half of a image when the user is either wrong or right. To paint the image, I'm using setTint() to paint the image the ...
2
votes
2answers
84 views

Same noise generator for C# and Javascript

I'm writing a 2D web racing game with procedural generated maps using perlin noise(as a university project). The server is written using C# and the client using Javascript. I've developed procedural ...
0
votes
1answer
151 views

How to get the overlap volume of OBB and or ABB?

The following code is a current attempt at a function I have to determine if two bounding boxes overlap. The bounding box structures are [min[x,y,z], max[x,y,z]] ...
0
votes
1answer
117 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
0answers
26 views

Libnoise bounding box - from spherical to planar

I'm trying to convert a bounding box inside a spherical map (equirectangular image as a result of Libnoise/c++) into a planar projection, but I can't find the correct algorithm for it and I'm not good ...
0
votes
0answers
58 views

How to open box item animation?

I want make 2d open box animation. Like cs-go open keys or other random box. I need the basics of implementation it and i want get more information about it. Thanks. Upd: Steps. I have array of ...
0
votes
0answers
22 views

Map an equirectangular square slice inside cubemap

I'm trying to map a square slice of an equirectangular image inside a cubemap with 6 faces, without distortion. The point is that I'm dealing with huge array sizes if I try to project the whole ...
0
votes
0answers
38 views

Catch blocks while dodging other elements game

I'm working on this game where the user gets points for catching the right falling colour block. If the user catches the wrong colour block they will loose the game. For ex: I assign the user to ...
4
votes
1answer
213 views

Representation of trains on a simplified rail grid

I'm working on a hobby game, basically about train dispatcher's job. (stack: Typescript, phaser.js) My map is based on a grid, each tile can hold 1 rail tile (well, except junctions, but we can ...
0
votes
0answers
56 views

Convert Flat World Angle into Isometric Angle?

My game is isometric 30 degrees (think Diablo 2), I'm looking to convert the angle A1 from the player tile A to the destination tile B into the appropriate angle A2 in the isometric view. For the ...
0
votes
2answers
145 views

How to use local-storage

So I have this game and I would like to have a save function. Here is my code below: ...
0
votes
1answer
46 views

I'm trying to work with setInterval inside a loop and it doesn't work the i want it to

I am making a 2d canvas game in Javascript. I am trying to make the enemies that are coming to my hero to shoot a bullet every 3 seconds. ...
0
votes
1answer
56 views

Making an enemy shoot every few seconds

so I am making a 2d canvas game in Javascript and I want the enemy mobs to shoot a bullet every let's say 3 seconds. I'm almost done with the code , i made everything i just don't know how to make the ...
0
votes
1answer
66 views

How do I change the level of my game by changing the file loaded?

I am making this 2d canvas game in JavaScript and I want to switch to file level2/level2.html when the boss of level 1 (...
0
votes
1answer
201 views

Making a 2d shooting game. need a working shoot function

I tried to follow some guides but couldn't get their functions to work in my program. What i tried is commented out in my code(the for loop). I want a working function on space press create a bullet ...

1
2 3 4 5
26