"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. ...

learn more… | top users | synonyms

2
votes
2answers
415 views

How do I calculate consistent frame timings at 60fps?

I'm writing an HTML canvas game that uses requestAnimationFrame and therefore runs at 60fps, although this is more of a question about failing arithmetic than about JavaScript. If I measure the time ...
1
vote
1answer
586 views

PNG image as a level map for 2d game

I've been using a tilemap editor for making levels, but I was wondering if there was a way to use PNG images as the level map, as maps created in tiled editor are graphically uninteresting. ...
6
votes
3answers
870 views

Basic isometric projection in Javascript

I've been working on porting an old closed source game to Javascript with Canvas and I've come to a slight problem. Right now, to display the land, I just have a pretty basic loop that just draws the ...
1
vote
2answers
962 views

How do I generate a 2d grid-based map without screwing it up?

I'm relatively new to the mechanics of game development - catching up fast, but there are still some things that escape me. For example: generating a fully-accessible map on a 2d grid. See the ...
2
votes
3answers
181 views

Instantiate objects that share same variable

I'm just wondering how to instantiate the same objects that all share the same variables, except their positions. I'm basically working on the scene of my HTML5 game, and I've build a streetlamp post ...
2
votes
2answers
380 views

Best way to store NPCs, Monsters, Shops, etc for JavaScript game? [closed]

OK, let's say I have a JavaScript game (preferably on jQuery framework) and its using HTML5 Canvas. What would be your way of storing data to map out shops, monsters, and NPCs? I was thinking maybe ...
0
votes
1answer
302 views

Saving Scores Using Cookies

I've recently created a small galiga like game recently using JavaScript and HTML5. I've run into a bit of trouble saving cookies, the cookie saves, but then resets itself when the page is refreshed, ...
-2
votes
1answer
80 views

Why do I get “Undefined” only on the “Vertical” Grid? [closed]

Problem: When I get to the end of the Grid it gives me an Error :-/ The X axis is fine, the problems occur then I move "over the end" of TOP and BOTTOM. This code works: if(new_data[1] == ...
5
votes
1answer
667 views

box2d with lines

I have a very simple platform game builder and I've specified the ceilings, walls and floor as line segments. A line has a winding, or normal; you can determine the direction that a line should be ...
5
votes
1answer
795 views

Canvas animation drops to 30fps every 3-4 seconds

Ok! I solved the problem. Chapter One - Multiple Canvases I started to make pong utilizing requestAnimationFrame and I noticed that the ball was stuttering and slowing down every 3-4 seconds. So I ...
2
votes
2answers
199 views

Approaches for storing grid-like information

I am drawing this simple grid on my NodeJS server: var grid = []; for(var x = 0; x < 20; x++){ grid[x] = []; for(var y = 0; y < 20; y++){ grid[x][y] = 0; } } ...
1
vote
2answers
1k views

How to make an infinite map

I was wondering if someone could explain to me how to implement a seemingly dynamic infinite map like the one at http://wordsquared.com/ My main issue is really generating new tiles in any direction ...
2
votes
1answer
294 views

mat3x4 in webGL shaders

I am porting the IQM bone animation format to Javascript and have run into a problem... The vertex shader is failing to compile and the only error message I get out is 'mat3x4' : syntax error on the ...
0
votes
1answer
304 views

Player movement behind objects

I was playing around on RPG JS and Browser Quest, and the player, when moving, can give the effect of walking behind the trees or houses etc, so the player effectively disappears while it is "behind" ...
-5
votes
2answers
556 views

A* mouse movement javascript top-down game

Im trying to implement a* path finding for my character movement in my game. The game is written in javaScript along with jQuery in a canvas. I have read up on A* so i believe i understand what it ...
-2
votes
1answer
3k views

How to make background to stage in kineticjs

var stage = new Kinetic.Stage({ container: 'container', width: 490, height: 300, }); var layer = new Kinetic.Layer(); I want to make a default image to a stage to be the ...
-4
votes
2answers
203 views

enemy shooting towards FPS [closed]

WELL first of all I want you to see my game (its deployed on heroku cloud) : http://still-escarpment-3701.herokuapp.com (It takes almost 10 sec to load so please wait for couple of sec) I have ...
-1
votes
1answer
224 views

problem with bullets shooting in FPS game

Please check out my game here: http://still-escarpment-3701.herokuapp.com The problem is with shooting. The bullets keep on moving with the First person controller instead of moving from the same ...
1
vote
0answers
460 views

shader-based particle systems

I have a classic particle system where each particle is represented by a quad and, each time step, I move each particle. My target is webGL which means I don't have instancing, attribute divisors nor ...
0
votes
1answer
851 views

Unity - Code is fine in the editor, has error on android

Right. Im running into some weird issue with android unity. I have this bit of code function OnTriggerStay (other : Collider) { if(die.GetComponent(DieScript).sideUp ==6 ...
10
votes
0answers
909 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?
5
votes
3answers
977 views

How should I implement parallax scrolling with pan and zoom in HTML5?

I'm writing a planetary motion simulator with the HTML5 canvas element and I want to put one or more layers of stars in the background. The user can click and drag the screen to navigate around the ...
0
votes
1answer
488 views

Am I doing this node.js game loop wrong?

I have 2 arrays of JSON objects, actions and game objects. At any time a user can make a request from the client which can add an action to the actions array. I have a setInterval(function(){ }, ...
0
votes
2answers
65 views

In an asynchronous server environment where player input and timed events modify data is using an in-memory array problematic?

So let's say I have a server running on node.js, and there is an array of player objects... At an interval, all of these player objects are looped and processed for events and changes that are based ...
-1
votes
1answer
350 views

Drawing polygons in 3D

I have recently been working on a 3D engine from scratch, using JavaScript and HTML5. I've successfully created lines (although slightly buggy) and points, but I can't figure out faces. My current ...
0
votes
0answers
383 views

Swept sphere to line segment intersection in 2D

How can you determine when a moving sphere intersects a line segment, and the normal of that intersection? Ideally Javascript, but anything that's tidy, simple and self-contained and easy to port to ...
3
votes
2answers
987 views

HTML5/JS - Choppy Game Loop

I have been experimenting with HTML5/JS, trying to create a simple game when I hit a wall. My choice of game loop is too choppy to be actually of any use in a game. I'm trying for a fixed time step ...
-1
votes
2answers
331 views

Remove enemy when bullet hits enemy

For my education I have to make a basic game in HTML5 canvas. The game is a shooter game. When you can move left -> right and space is shoot. When I shoot the bullets will move up. The enemy moves ...
2
votes
1answer
316 views

Collision detection problems - Javascript/Canvas game

What I want to do: I simply want the have a 2D array to represent my game map. I want a player sprite and I want that sprite to be able to move around my map freely using the keyboard and also have ...
2
votes
2answers
1k views

Efficient collision detection - tile based HTML5/Javascript game

I'm building a basic RPG game and I'm looking at collisions/pickups etc now. It's tile based and I'm using HTML5 and Javascript. I use a 2D array to create my tilemap. I'm currently using a switch ...
0
votes
1answer
856 views

HTML5 platformer collision detection problem

I'm working on a 2D platformer game, and I'm having a lot of trouble with collision detection. I've looked trough some tutorials, questions asked here and Stackoverflow, but I guess I'm just too dumb ...
1
vote
1answer
212 views

Adapting Javascript game for mobile

I'm currently developing a Javascript web game for desktop users. It is a sort of tower-defense game that relies on mouse input only, developed on canvas using EaselJS. In the future, or perhaps ...
8
votes
4answers
3k 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 ...
2
votes
1answer
278 views

How can I detect and compensate for system related lag?

The best example I can think of is Doom 3. It seemed to me that if there was any kind if lag the game would pause and then resume without "fast forwarding" to catch up. I'm trying to figure out a good ...
1
vote
1answer
444 views

Architectural advice - websockets javascript/php integration

Myself and a friend have started making a game, he's likely to be using impact.js for the user interaction etc, but we need multiplayer functionality so some form of websockets for TCP connections ...
0
votes
2answers
567 views

Animating sprites in HTML5 canvas

I'm creating a 2D platformer game with HTML5 canvas and javascript. I'm having a bit of a struggle with animations. Currently I animate by getting preloaded images from an array, and the code is ...
4
votes
1answer
381 views

Glenn Fiedler's fixed timestep with fake threads

I've implemented Glenn Fiedler's Fix Your Timestep! quite a few times in single-threaded games. Now I'm facing a different situation: I'm trying to do this in JavaScript. I know JS is ...
0
votes
1answer
107 views

Questions for QueryAABB

I'm currently having trouble getting my head around QueryAABB, and hope to find some answers here. The LowerBound of an AABB the upper-left corner (and vice versa). Why is that and what idea is ...
4
votes
1answer
112 views

How to detect whether an Object came to sleep at a specific position?

I'm currently writing a small game with box2dweb and I need some direction for this: I'm throwing a Box and have to hit a specific place and trigger an event when the object that's been thrown isn't ...
15
votes
7answers
657 views

Do I need a Point and a Vector object? Or just using a Vector object to represent a Point is ok?

Structuring the components of an engine that I am developing along with a friend (learning purposes), I came to this doubt. Initially we had a Point constructor, like the following: var Point = ...
-2
votes
1answer
162 views

How do I set an event off when player is on certain tile?

Here is the code I use to create and print my map to the canvas: var board = []; function loadMap(map) { if (map == 1) { return [ ...
2
votes
2answers
253 views

Stop a rotating object at a specified angle?

I'm working in JavaScript with HTML5 and the canvas. I have an object which is rotating at a certain speed, and I need the object's rotation to slow down gradually and the front of the object to stop ...
-1
votes
1answer
465 views

Camera game 2d Javascript using box2d

I'm cloningg, i'm doing camera 2d in angry bird game using javascript html5 game and box2d.js . I'm using context.translate(x,y) to move canvas, but i meet an error like this : many image of birds ...
2
votes
3answers
680 views

Issues with shooting in a HTML5 platformer game

I'm coding a 2D sidescroller using only JavaScript and HTML5 canvas, and in my game I have two problems with shooting: 1) Player shoots continous stream of bullets. I want that player can shoot only ...
2
votes
2answers
407 views

Help w/ iPad 1 performance for tile-based DOM Javascript game

I've made a 2D tile-based game with DOM/Javascript. For each level, the map data is loaded and parsed, then lots of tiles ( elements) are drawn onto a larger "map" element. The map is inside of a ...
2
votes
1answer
2k views

HTML5 point and click adventure game code structure with CreateJS

I'm a programming beginner. I made a tiny one scene point and click adventure game to try to understand simple game logic and came up with this: CreateJS features prototypes for creating bitmap ...
0
votes
2answers
313 views

HTML5 as application for tablets?

I'm looking at creating a tablet application (iPad, Nexus, Surface...). I've heard it's possible to create it using HTML5 canvas. I was wondering if it was limited to canvas, if div/input/table can ...
0
votes
1answer
365 views

how to devise a scoring algorithm based on elapsed time and number of moves [closed]

I want to devise an score algo for my game. I want to award high scores to players who achieve the goal in minimum time and least number of moves. I did this but its not going correctly: var score = ...
2
votes
2answers
441 views

Making an interactive 2D map

So recently I have been working on a Legend of Zelda: A Link to the Past clone, and I am wondering how I could handle certain map interactions (like cutting grass, lifting rocks, etc). The way I am ...
7
votes
1answer
310 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 ...