As of May 31, 2023, we have updated our Code of Conduct.

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
35 votes
7 answers
15k views

Anti-cheat Javascript for browser/HTML5 game

I'm planning on venturing on making a single player action rpg in js/html5, and I'd like to prevent cheating. I don't need 100% protection, since it's not going to be a multiplayer game, but I want ...
Billy Ninja's user avatar
57 votes
18 answers
35k views

What are good JS libraries for game dev? [closed]

If I decide to write a simple game both text and graphical (2d) what libraries would I use? (Assume we are using a HTML5 compatible browser) The main things I can think of Rendering text on screen ...
49 votes
12 answers
26k views

How do you prevent your JavaScript / HTML5 web game from being copied or altered?

I'm in the middle of planning a game built using JavaScript and HTML5. I'm having trouble understanding how you could prevent someone from simply copying the JavaScript from the web server and ...
Christian's user avatar
  • 593
34 votes
5 answers
11k views

How do I implement features in an entity system?

After asking two questions about entity systems (1, 2), and reading some articles on them, I think that I understand them much better than before. I still have some uncertainties, mainly about ...
jcora's user avatar
  • 7,877
30 votes
3 answers
9k views

How do I lerp between values that loop (such as hue or rotation)?

View Demo I'm trying to make the joint rotate smoothly around the center of the canvas, toward the angle of mouse pointer. What I have works, but I want it to animate the shortest distance possible ...
jackrugile's user avatar
12 votes
3 answers
5k views

How do I generate terrain like that of Scorched Earth?

I'm a web developer and I am keen to start writing my own games. For familiarity, I've chosen JavaScript and canvas element for now. I want to generate some ...
alex's user avatar
  • 763
29 votes
4 answers
24k views

Simple noise generation

I'm looking to generate noise that looks like this: (images courtesy of Understanding Perlin Noise) I'm basically looking for noise with lots of small "ripples". The following is undesirable: Are ...
Xeon06's user avatar
  • 1,162
17 votes
3 answers
14k views

Ledge grab and climb in Unity3D

I just started on a new project. In this project one of the main gameplay mechanics is that you can grab a ledge on certain points in a level and hang on to it. Now my question, since I've been ...
BallzOfSteel's user avatar
11 votes
3 answers
8k views

How do I implement branching dialogue in javascript?

I'm making a very basic visual novel type of game in JavaScript. I'm a beginner, so I'm just doing this for fun and learning, and due to bad planning I have run into a bit of a problem when you get to ...
The Silent Cartographer's user avatar
8 votes
4 answers
2k views

Securing HTTP data from a JavaScript game to server

Suppose I am doing a JavaScript game, and I wish the game to update the server if the user has successfully completes the game and his outcome. How should I ensure that the request came from the ...
Extrakun's user avatar
  • 2,742
2 votes
1 answer
228 views

Find ID from Spiral x, y positions. Hard programming formula

I have a formula, which gets coordinates from user_id (see below). I give User_id, and I get back coordinates. But now I need to get User_id from coordinates. For example: ...
mansim's user avatar
  • 169
2 votes
1 answer
805 views

cron jobs for MMO browser game

I have to implement cron jobs in to my MMO browser game. Its like in Travian game - you build something, and wait few minutes or hours.. But the problem is, that cron job shedulers made to be sheduled ...
mansim's user avatar
  • 169
1 vote
1 answer
2k views

Camera movement, Draw grid

If I have a 20x10 grid (640x320) where tiles are 32x32 The grid are rendered: ...
Mike's user avatar
  • 11
21 votes
5 answers
9k views

Prevent cheating in html Javascript game [duplicate]

I have made a Javascript/html game. Now the problem I have is anyone can edit the client code and cheat in game for example there is a man shooting a enemy. Man HP:      &...
Ohmyholy's user avatar
  • 321
14 votes
5 answers
9k views

How do I protect sending scores from HTML5 games to my server

On backend I am using java. I have a game in HTML5; when user completes it I sends an Ajax call to save the score to database. Now, someone can easily use tools like Fiddler and firebug to modify this ...
Deepak Singhal's user avatar
13 votes
4 answers
9k views

Staggered Isometric Map: Calculate map coordinates for point on screen

I know there are already a lot of resources about this, but I haven't found one that matches my coordinate system and I'm having massive trouble adjusting any of those solutions to my needs. What I ...
Chris's user avatar
  • 243
11 votes
2 answers
801 views

How do I make good guy attacks only hit bad guys and vice versa?

My game has many different type of good guys and many different type of bad guys. They will all be firing projectiles at each other but I don't want any accidental collateral damage to occur for ...
Daniel Kaplan's user avatar
10 votes
0 answers
991 views

How to create 2D shadows [duplicate]

I'd like to create lights and shadows in a 2D environment, like in the image below: I did several searches but got no results. Do you have any hint?
user24310's user avatar
  • 201
9 votes
4 answers
5k views

Is there a way to increase the collision check efficiency of a system of n objects?

I'm making a game that consists of many onscreen objects, one of which is the player. I need to know which objects are colliding every iteration. I made something like this: ...
jcora's user avatar
  • 7,877
9 votes
3 answers
7k views

Entity Component System based engine

Note: I'm programming this in Javascript, but it should be language agnostic in the most part. I am thinking about converting my engine to an ECS based one. I get the basic idea (note: this is wrong,...
jcora's user avatar
  • 7,877
4 votes
1 answer
3k views

Shoot a bullet towards cursor - top down 2d

I am making a 2D topdown shooter game, in which the player's movement is controlled with WASD and gun with the mouse. I'm having a hard time figuring out how to update the position of the bullet as it ...
Sam's user avatar
  • 53
4 votes
2 answers
3k views

canvas ball physics animation

I want to animate ball in html canvas like this. ctx.beginPath(); ctx.arc(75, 75, 10, 0, Math.PI*2, true); ctx.closePath(); ctx.fill(); start position is left ...
Nick Sanders's user avatar
4 votes
7 answers
587 views

Is there a fundamental technical reason for Flash being a more popular game platform than JavaScript?

Both Javascript and AS3 are implementations of ECMAScript. Is there a fundamental technical reason for Flash being so much more prevalent as a game-publishing platform, when compared to Javascript?
blueberryfields's user avatar
3 votes
1 answer
2k views

How can I detect mouse events on sprites in a canvas?

I'm making an HTML 5 game. I want mouse clicks on sprites drawn in a canvas element cause events that my code can react to. At the moment, I'm doing it by checking through all of my sprites in a for-...
aaa111's user avatar
  • 163
3 votes
3 answers
3k views

Collectible card game, cards and effects

Based on Design of a turn-based game where actions have side-effects I am building a card-game where cards can have side-effects be triggered under different circumstances. I was given a good idea ...
Salex's user avatar
  • 31
3 votes
3 answers
2k views

OOP implementation of BUFFS and Stats. Suggestion

I am developing an MMORPG server using NodeJS. I am not sure how to implement Buffs, i mean, equipped objects or used skills have effects on the Player() which has many Stats(), some of them have a ...
Mattia Manzo Manzati's user avatar
1 vote
1 answer
431 views

Efficiently calculate 2d world position based on parent(s) recursively

I am writing a small 2d html5 game engine in javascript that relies on the concept of a hierarchy. The scene is the root node or entity, and its children make up the game objects. These children can ...
clabe45's user avatar
  • 408
1 vote
1 answer
868 views

Problem when animating MD5 model (GPU Skinning)

I'm trying to implement a GPU skinning version of the md5mesh.js by @tojiro (demo with CPU skinning) in WebGL (live demo of the project here, use WASD to move the camera around). The main concept is ...
mikidelux's user avatar
  • 304
1 vote
4 answers
15k views

Transform coordinates from 3d to 2d without matrix or built in methods

Not to long ago i started to create a small 3D engine in javascript to combine this with an html5 canvas. One of the issues I run into is how can you transform 3d to 2d coords. Since I cannot use ...
Thomas's user avatar
  • 836
1 vote
1 answer
2k views

Using copyrighted sprites [duplicate]

Possible Duplicate: How closely can a game resemble another game without legal problems I was thinking about making a pacman clone, I know there is a similar question here Using Copyrighted ...
Zertalx's user avatar
  • 31
1 vote
2 answers
1k 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?
Devin Little's user avatar
0 votes
2 answers
1k views

How legal would it be to use some elements of the Half Life universe in my non comercial, indie game?

I'm planning to make a simple, HTML5 game, that would use some elements of the Half Life universe. Basically, it would be a 2D Portal clone, but it would have it's own story, and portals would be ...
jcora's user avatar
  • 7,877
0 votes
3 answers
2k views

How to optimize collisions

I'm building a 2D MORPG using JavaScript, Node JS and socket.io To prevent cheating, I have to run all collisions for all players on my server. I'm currently doing fairly simple square collisions ...
Pascal Claes's user avatar
-2 votes
1 answer
940 views

Energy Bar in Unity [closed]

I want to display a debug message when the progress bar is loaded fully and I have a button "refresh", when I click this it should reload the progress bar. Here is the code I have tried: ...
user1509674's user avatar
17 votes
6 answers
2k views

Essential knowledge for making HTML/JavaScript-based games [closed]

I was wondering if any experts out there could share the knowledge and resources of what is necessary to start making games with the latest HTML standards and JavaScript (or what some like to call ...
edmundito's user avatar
  • 312
13 votes
3 answers
21k views

Javascript and PHP for real-time multiplayer? [closed]

I'm wondering if combining Javascript clientside with PHP/mysql serverside is a good idea for HTML5 real-time multiplayer (small scale) browser games? My technical knowledge is very limited, and even ...
justanotherhobbyist's user avatar
13 votes
3 answers
6k views

What is the best way to handle simultaneous collisions in a physics engine?

I'm writing a 2d physics engine in javascript so that I can learn more about physics in video games. I have it working correctly for rigid body collisions, except for if any body collides with two or ...
Cam's user avatar
  • 263
12 votes
3 answers
7k views

Realtime multi-player game design principles for Node.js

I've been reading the Valve article on multi-player networking which has been adapted from Yahn Bernier's 2001 paper called Latency Compensating Methods in Client/Server In-game Protocol Design and ...
Yoshima's user avatar
  • 223
12 votes
8 answers
8k views

HTML5 mobile game development vs. native game apps [closed]

What is the current state of game engines, frameworks, libraries and conversions related to the HTML5 set of technologies (including CSS3 and JavaScript libraries such as RaphaelJS, Impact, gameQuery);...
Vic Goldfeld's user avatar
12 votes
3 answers
18k views

Get points on a line between two points

I'm making a simple space game in JavaScript, but now I've hit a wall regarding vectors. The game view is top-down on a 2d grid. When the user clicks on the grid, the space ship will fly to that ...
Stephen's user avatar
  • 460
12 votes
3 answers
4k views

How often to update a Game Client about the World?

Using socket.io, I have a communication similar to that of other MMORPGs, a steady connection with messages. In my design so far, the client sends the player's position and animation frame with every ...
Lanbo's user avatar
  • 997
8 votes
3 answers
31k 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 ...
JustGoscha's user avatar
8 votes
1 answer
528 views

Javascript keyDown - no event approach

I'm making game in JavaScript. I have canvas for drawings and game loop. I'd like to make method readKeyboard, in game loop, to check if there is any pressed key. I don't want to attach event to ...
Piotr Łużecki's user avatar
7 votes
3 answers
2k views

Determining the end location for AI movement in groups in a 2D RTS

I have written an RTS game (a demo for a game engine of sorts, actually) in which the user's basic interaction with the game is to select a bunch of soldiers and then right-click on the map to move ...
IceCreamYou's user avatar
7 votes
1 answer
4k views

Jump handling and gravity

I'm new to game development and am looking for some help on improving my jump handling for a simple side scrolling game I've made. I would like to make the jump last longer if the key is held down ...
opes's user avatar
  • 173
7 votes
2 answers
3k views

UV texture mapping with perspective correct interpolation

I am working on a software rasterizer for educational purposes and I am having issues with the texturing. The problem is, only one face of the cube gets correctly textured. The rest are stretched ...
Spectraljump's user avatar
7 votes
3 answers
5k views

Tips for communication between JS browser game and node.js server? [closed]

I am tinkering around with some simple Canvas based cave flyer game and I would like to make it multiplayer eventually. The plan is to use Node.js on the server side. The data sent over would ...
Petteri H's user avatar
  • 1,753
7 votes
2 answers
981 views

Capitalizing on JavaScript's prototypal inheritance

JavaScript has a class-free object system in which objects inherit properties directly from other objects. This is really powerful, but it is unfamiliar to classically trained programmers. If you ...
keithjgrant's user avatar
7 votes
5 answers
7k views

Why do I need a local server for HTML5 game development?

I'm new to HTML5 game development. I'm trying to make something using Pixi.js, but when I tried to view it in a browser, I saw a blank page. According to the tutorial I'm following, I need to set up a ...
Question-Everything's user avatar
6 votes
2 answers
37k views

How to ignore collision between two objects

I have a player that shoots in the direction that it is facing. However, the shot that is created when I click, also destroys the player (example). How would I make the shot ignore collision with the ...
eren_tetik's user avatar