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
1,331
questions
0
votes
1answer
35 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?
-2
votes
0answers
31 views
Poker hand evaluation
suits: [1, 1, 0, 3],
values: [0, 0, 0, 0, 1, 0, 2, 0, 1, 1, 0, 0, 0]
Given an array representing the suits and the values of the card, how do you numerically ...
1
vote
1answer
19 views
How to get all tiles along a straight vector path?
Let's say I have a 100x100 map of tiles where each tile is 16x16 pixels.
How would I get all tiles along a path? For example, let's say I wanted to get a list of all tiles along the shortest direct ...
0
votes
0answers
35 views
For drawing many layered 2D tiles, should one use the painter's algorithm, or Z-buffering?
Sorry if this question doesn't make sense, I'm still very new to WebGL / OpenGL.
Basically, I'm trying to draw a tilemap similar to the one in Stardew Valley. Here's a screenshot from that game: https:...
0
votes
2answers
39 views
Performance of many canvas drawImage calls is very slow
I'm developing a top-down 2D tile-based canvas game. I have a single sprite sheet of all my tiles, and then a JSON tile map array of where they're placed.
Previously I would render all the layers of ...
0
votes
0answers
28 views
How to draw the player standing behind a tree in an Entity Component System?
I'm making a top-down Javascript canvas game using the Entity Component System architecture.
For an entity to be drawn on the screen every frame, it needs a ...
0
votes
1answer
34 views
Should abilities have their state and functionality separated?
I'm developing a top-down game using Javascript and Canvas in an ECS architecture.
I'm wondering, which of these is better from a design / elegance point of view?
Method 1: Combining the ability ...
0
votes
0answers
12 views
Resizing the camera view in Phaser 3 just like in Unity
I started to work in Phaser 3 with a previous background in programming in Unity and I can't figure out how to zoom the camera view. In Unity, I can change this value, to resize the camera view:
Then,...
0
votes
0answers
17 views
Discrepancy in Box2D Flash applied impulse
I have two clients. Player A, and Player B. What Player B sees in his screen is a mirrored version of what Player A sees. This is a carrom game, hence the mirroring.
Does anyone know why even if I ...
0
votes
1answer
60 views
Isometric tilemap circle around object
I am developing an isometric game like Anno 1602.
I have an isometric tilemap. The default tilesize is 64x31.
My goal is to show the area a building has influence to. For that I want to show a circle ...
0
votes
0answers
26 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 ...
1
vote
0answers
19 views
Tagging “regions” in rot.js map generator
I'm working on a small roguelike and I'd like to be able to tag the various "regions" generated via the Map generators so that I can use it as a lookup to environment descriptions. I see ...
0
votes
0answers
22 views
Rendering efficiency for retro 2d grid chipset games. Draw by texture, or by row col?
This was the closest question on found here: Help with a Fast 2D Grid-Based world rendering technique
I'm doing a basic 2d grid where each box is filled with a texture pulled from a chipset. I'm ...
0
votes
1answer
14 views
What is the best approach to minimise the lag caused by ping when spawning predictable entities?
When the client clicks it spawns a unit on the client-side which moves in a predetermined path, it also emits an event to the server which indicates that the client has spawned a unit. Once received ...
0
votes
0answers
18 views
Having trouble swapping elements
I'm trying to visualize a simple Hanoi solver that uses an algorithm, and I'm swapping elements on array to visualize it.
Here's my code:
...
0
votes
1answer
51 views
Timers: check in game loop, or run independently?
Specifically talking in the context of JavaScript game development.
For example, I can use the language specific timeout mechanism:
...
0
votes
1answer
29 views
I do not understand the code version of time based sprite animation?
I'm Universo and for the longest time had coding issues around the concept of time-based sprite animation basically, do not know how to implement it and any code or explanation simple or complex that ...
0
votes
0answers
20 views
Draw Ordering with Glowing Objects
This is mostly a general design theory question, but for reference the bulk of my game is in JavaScript.
I can draw images to the screen that layer on top of each other in the order that I please. One ...
0
votes
0answers
24 views
solid color to sprite (javascript game)
Hi I recently created a javascript game, in this game, math random is used to pick a random shape.
The shapes are in strings, and the associated numbers within the string are then used to show a color....
0
votes
2answers
71 views
Is it a bad idea to store functions inside components in ECS?
Say I have three entities: Player, Spikes, and Zombie. All of them are just rectangles and ...
0
votes
1answer
52 views
Implementing Seperating Axis Theorem
I'm trying to implement the Seperating Axis Theorem by following this article I found on MDN.
Unfortunately, I'm not too geometry savvy and I wasn't able to find any good, simple implementation ...
0
votes
1answer
22 views
Line strokes also adding borders to other shapes?
When you run the project, you can see that the first circles have a black border around them. When I remove the Game.drawLines(), the circles don't have the border ...
0
votes
1answer
86 views
How to import three.module.js
I'm looking at this three.js cubemap example, and it runs fine in my browser when loaded from that page.
After much strain to find and download the files - it does not run?
What am I doing wrong, with ...
1
vote
1answer
56 views
Raycasting - weird lines on walls when ray is facing up or right
I am trying to make a raycasting game. Everything is rendered correctly except when the ray is facing up (angle > PI) or facing right(angle > 0.5PI and < 1.5PI) lines are drawn on walls. I am ...
0
votes
0answers
23 views
Top down four directional movement snap to tiles, not feel like crap
I want to make a topdown rpg movement, I need to update these parameters based on user input:
User input four directions: ā¬ļøā¬ļøā¬
ļøā”ļø .
Update parameters
Position: ...
0
votes
0answers
16 views
Check bounds in 2d platformer level transition
I have asked How camera works in 2d platformer in level transitions about camera transitions,
in the process I am stuck somewhere else.
I have a targetRoom that is 32 by 32 tiles:
...
1
vote
2answers
178 views
Optimizing a quadtree for circles and circular queries
I'm developing a 2D ant simulation in JavaScript. I'd like to implement a quadtree to store the positions of ants and other markers. I approximate all of these entities as circles, and I'm only ...
0
votes
1answer
72 views
How camera works in 2d platformer in level transitions
I want to know how Camera works in game of Celeste.
Currently what I have is, camera follows the player using interpolation:
...
1
vote
1answer
100 views
How can I implement a Boardgame.io project using Webpack?
I am following the boardgame.io tutorial, but I do not want to use either of the two implementation options covered in the tutorial (React and Parcel).
The tutorial requires a framework or bundling ...
0
votes
0answers
29 views
The elements of a perfect juicy jump
I have seen and implemented these ideas: Simple Physics based Movement SO answer. Building a Better Jump GDC Talk. And written a tutorial about it Making a Platformer in Pico 8.
Finally made a simple ...
0
votes
0answers
37 views
How to make a snake game where each snake tile follows it's connected tile
I want to make a basic snake game. It has a head and a series of tails that occupy a tile in a grid. The first tail in the series is adjacent to the head. and each tail that comes after is adjacent to ...
0
votes
1answer
22 views
Time-passed check with Pause functionality
I am working on a game that has a lot of time-passed checks of the following format. These work great, but there is a problem when the game is paused:
If paused for any meaningful amount of time, the ...
0
votes
0answers
22 views
The rule to scale pixel art non multiple of integer ratios [duplicate]
I have pixel art, I want to draw. When player jumping I want to animate the art to squash stretch to have a feeling. But when I scale the art it get's distorted, as demonstrated in the image.
In one ...
0
votes
1answer
28 views
How to leave trails that are equidistant apart from each other
I want bunch of circles to follow the player while keeping a distance apart.
So far I have this:
...
0
votes
0answers
26 views
Algorithm for simulating collision between circles of different mass
First of all, I'm not sure if this is the right site for this question, as it's actually a game I'm developing. However, I thought that this would be a common thing to need to know in games, so I put ...
0
votes
0answers
18 views
Saving Complex Data to File Javascript
My game uses lots of complex objects to store game data. (Each block and entity has its own instance of a class)
I am trying to create a saving and loading system, where the user can save game ...
0
votes
0answers
12 views
How to move a character from 1 to 3 squares on a grid?
I need to make a turn based game in js and jquery. The rules are :
The 2 characters, the 4 weapons and the 15 obstacles are randomly generated on a grid(made with HTML table and generated in a loop)
...
0
votes
0answers
14 views
Spider physics to patrol on platform smoothly when changing direction
I have a 3 tile wide platform. I want my spider to hang from the ceiling and patrol this platform left and right.
I have dx property for velocity. I want a physics code that shows how to achieve this.
...
0
votes
0answers
57 views
What are the parameters for a smooth wall jump
I want to make a platformer like Celeste and trying to implement wall jump.
When the player is on the air and near a wall, and presses jump, the player gains x velocity opposite the wall direction, ...
1
vote
1answer
94 views
Are spritesheets worth it? Is a zip a good alternative?
I was wondering if spritesheets are worth it.
I am making a game with pixi.js and was thinking about optimization, beginning with asset loading. I currently have an arraya of all files and use PIXI....
0
votes
2answers
79 views
Calling function every n second javascript game
I making a game and I want to call a function that runs every random second to spawn something every time. I've seen some posts that said to use the setInterval() ...
1
vote
1answer
46 views
Is reobfuscating javascript every time the page is loaded a valid option for a multiplayer game?
I am looking for ways to prevent cheating on a multiplayer browser game. I saw this answer where it was mentioned that obfuscation is not an effective technique.
My plan is not only to obfuscate the ...
0
votes
0answers
49 views
Bubble Shader in Babylon.js
Can anyone think of an approach to creating a bubble-like material in babylon.js? I imagine a good starting point would be with using the Fresnel shader.
0
votes
1answer
45 views
Particle Turbulence Effect in Babylon.js
Is there any way to implement a turbulence effect in a babylon.js Particle System? I know that its possible to use physics engines on mesh objects, but I've not seen any discussion of using them on a ...
0
votes
3answers
121 views
Finding all possible paths from one hexagon to another
I got a hexagonal grid (cube coords)
In hex (0,0,0) there is a soldier and in another (distance == 4 hexes) a target:
i need to find all possible pathes from soldier hex to a target :
1)Length of ...
1
vote
1answer
42 views
2D Grid-based Pathfinding with Elevation
I'm creating an isometric game which currently uses A* Pathfinding on a basic grid representation of the map.
Having elevations and allowing the Players to traverse up-and-down is an integral part of ...
0
votes
2answers
141 views
Default Game Window Size To Take While Making Games
I am planning to make a game for mobiles and tablets, I wanted to know what would be the default resolution that I should set for my game so that it covers all or most of the devices out there.
I read ...
0
votes
0answers
30 views
Hide Environment Texture in Babylon.js
Is it possible to hide an environment texture as to preserve the reflections/light it provides while keeping the background transparent (as seen in picture 2)? I know this is done in Blender by ...
0
votes
1answer
40 views
Player hitting bottom of tile when beside it?
So my player checks if it is colliding with tiles, and it works pretty good. However, when the player is against a wall, moving upwards and sideways, it detects it as hitting the bottom of the wall ...
0
votes
0answers
16 views
Use JS to grab values from a dynamic Lua Table
((BACKGROUND: I'm modding a game that runs using Lua and the Source2 Engine (Dota). Gameplay logic uses Lua and HUD uses JS))
I used Lua to create a global table. For instance:
...