"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

0
votes
1answer
106 views

Why does my HTML5 game loop (with masking) run slowly?

I have a game loop like so: setInterval(function() { context.save(); context.rect(26, 144, 745, 400); context.clip(); context.drawImage(myImage, 100, 100, 900, 900); ...
1
vote
3answers
93 views

Canvas setTransform function clarification

I'm currently building some kind of fake-3D dungeon, and I'm facing some difficulties understanding the behavior of the setTransform() function. Here's my simplified code: var can = ...
2
votes
2answers
146 views

How do I maintain an online users list?

In a multiplayer JavaScript game client, is it a good idea to poll the server periodically to refresh online user list, or keep track of joined/left users? Is there a better option?
2
votes
1answer
164 views

2d grappling hook for platformer?

What are the options and mechanics for creating a grappling hook in a 2D game? In the prototype for this feature, the person runs around in a platformer world and can throw the hook at any wall, ...
3
votes
1answer
122 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 ...
1
vote
1answer
92 views

How to draw many identical quads in WebGL efficiently?

I have recently been trying to develop a more basic one of those 'falling sand'/'powder game' style games (See here) the past few months, and after prototyping on a plain canvas, then trying PIXI.js, ...
1
vote
1answer
206 views

Implementing fog of war on HTML5 canvas

I have been wrestling with creating fog of war for a while now. I actually did create it, but I consider the implementation too resource-heavy to be usefull. For initial information: I use createjs / ...
0
votes
1answer
37 views

How would one outline an alpha transparency layer in javscript and/or php? [duplicate]

I simply want an outline/edge detection of the character/item/object that is selected or doing something. I'm seeing lots of versions of this question for different languages, but I would appreciate ...
0
votes
1answer
138 views

Movement / aiming algorithm in 2d / tiled based game

I'm trying to create simple 2D / tiled base game in JavaScript. Entities are able to move by any number of pixels, but only in one direction at once (can't go in diagonal way). AI for enemies is ...
0
votes
0answers
55 views

detection of a circle inside a rectangle in html5 canvas

I've created this game where the player can hit space to make the circle float in certain way. the main goal of the game is let the circle enter the rectangle .I did this code to create a collision ...
1
vote
1answer
179 views

JavaScript - 2D Top-down Collision Detection issue

I'm developing a 2D Top-down Game using HTML5 Canvas and a custom Game Engine. I'm implementing the Quad-intersection detection (Function below, if it helps) on different areas of the Sprites (As ...
1
vote
2answers
112 views

How can I list files in a folder from JavaScript in cocos2d-x?

I need to list all the files in the res folder from a JavaScript script in cocos2d-x. What would be the most efficient way to do this? To keep compatibility with Cocos2d-html5 a JavaScript-only ...
0
votes
1answer
91 views

Card Game Complex Hand Holder [duplicate]

I've been working on a card game project for a while and have just got into the hand holder. What is stopping me now is how to spread the cards linearly in a complex way. By complex, I mean it changes ...
0
votes
1answer
81 views

How to change the start position of my 2D game

I am trying to create a game where you have to move a ball on a platform. At the start of the game, the ball is dropped on the platform and then you can move it around. This is al working, no problems ...
1
vote
1answer
236 views

Is it possible to rotate an image on an HTML5 canvas, without rotating the whole canvas?

So I basically want to rotate single sprites on the canvas without rotating the whole canvas, is that someway possible. I also don't want to create a new canvas for each object I have. Also, it ...
1
vote
1answer
134 views

Storing a Quadtree

I have a quadtree which organize my terrain chunks (heightmap) and all the static objects of my 3D world. I use Axially Aligned Bounding Box as a volume for each node of the quadtree. Due to the ...
1
vote
1answer
162 views

Replace a div (with a ball picture in it) with a 3D canvas ball [closed]

I am trying to make a game where you have to keep the ball on a green platform. At this point the ball is a div with a ball image. You can move the ball over the field, all works great. See it in ...
0
votes
3answers
69 views

calculating step length with dividing a number that returns digits after the decimal point

Question: How can i get rounded numbers from calculations that returns digits after the decimal point. And all the numbers together will be the number that is divided from. Explanation: I am ...
0
votes
0answers
36 views

Sprite rotation algorithm [duplicate]

I'm making a game where you have to plot a function to hit certain objectives. I already made the plotting function and the animation to display a tiny missile that travels above the function. My ...
0
votes
2answers
227 views

How to properly handle attacks in an 2D Platformer?

I am building an 2D Engine in JavaScript and if my actor attacks an enemy, a hitbox appears for a certain amount of time and then disappears. If the target keeps standing inside of the hitbox he gets ...
1
vote
1answer
189 views

How to continuously create objects in front of the camera when moving forward?

I have created a scene in Unity3D that's filled with spheres. I want to be able to move forward forever and still be passing through the spheres. I was thinking I'd keep the player in one spot and ...
1
vote
2answers
247 views

Shop and Inventory System

I'm creating a JavaScript game, and I'm getting stuck. When the player obtains X amount of gold, a middle column appears (you've unlocked the shop, yay!), and when you obtain more gold than an item ...
0
votes
2answers
62 views

Unity3D JavaScript/.NET code throwing compilation error with a List-thingy [closed]

So, I do this: var intlist:List.<System.Int32>; intlist.Add(1); And where I say intlist.Add(1) I get: NullReferenceException: Object reference not set to an instance of an object Weird, ...
0
votes
1answer
79 views

Console vulnerabilities in javascript-based game [closed]

Been toying around with a basic browser-based game for a while now, and getting deep into the vulnerabilities of client-side script. I know enough to understand that no client-side script is ever ...
0
votes
1answer
138 views

Isometric Movement in Javascript In the DOM

I am creating a game using Javascript. I am not using the HTML5 Canvas Element. The game requires both side view controlles, and Isometric controls, hence the movementMode variable. I have got the ...
1
vote
2answers
120 views

Bouncing off a circular Boundary with multiple balls?

I am making a game like this : Yellow Smiley has to escape from red smileys, when yellow smiley hits the boundary game is over, when red smileys hit the boundary they should bounce back with the ...
0
votes
1answer
81 views

How can I ensure reasonably spaced out enemies

I have a simple javascript game and I'm initializing their positions on the y axis using random numbers. How can I ensure that they are reasonably spaced apart? My simple algorithm is: y = ...
2
votes
2answers
150 views

Testing HTML5 canvas games on low resource computers

I've made a game in HTML5 & JS and want to test it on varying types of user setups as I've heard it doesn't perform too well on older MacBooks. How can I accomplish this? I'm thinking of ...
1
vote
2answers
190 views

Best way to do “cutscenes” [closed]

I'm curious about the best way to display cutscenes in canvas. When I say cutscene I mean something like a static image fading from one to the other. Would it be best to use a timeout for a certain ...
0
votes
1answer
85 views

Variable number of GUI Buttons

I have a generic HTML5 Canvas GUI Button class and a Scene class. The Scene class has a method called createButton(), which will create a new Button with onclick parameter and store it in a list of ...
0
votes
0answers
195 views

JavaScript 3D space ship rotation

I am working with a fairly low-level JavaScript 3D API (not Three.js) which uses euler angles for rotation. In most cases, euler angles work quite well for doing things like aligning buildings, ...
0
votes
1answer
123 views

Why does my goblin only choose a walk direction once? [closed]

I'm working on a simpe 2d canvas game that has a small goblin sprite who I want to get pathing around the screen. What I originally tried was a random roll that would choose a direction, the goblin ...
0
votes
1answer
135 views

Isometric displaying two different images in different positions

I'm creating a simple Isometric game using HTML5 and Javascript, but I can't seem to get the display to work, at the moment i have 9 tiles that have X and Y positions and the player has a X and Y ...
6
votes
1answer
207 views

How Do Shapes (Rectangles) Work in Quad Trees?

I've been told that a quad tree is the ideal data structure for my game, but I'm having trouble understanding how exactly shapes work within quad trees. I'm doing this in JavaScript, but I think ...
0
votes
2answers
189 views

HTML5 Canvas Parsing image into tileset while preserving transparency

I'm trying to import a Tiled Map Editor JSON file into my HTML5 canvas game but I'm having trouble with separating out the tileset image into separate images while preserving the transparency. ...
1
vote
1answer
121 views

How can I structure my ASCII terrain object?

So I have this object which represents a simple ASCII "overworld". Note the code is broken, but it's for demonstration purposes... var TerrainObj = { w: { name: 'water', glyph: 'w' }, g: { ...
1
vote
1answer
168 views

WebGL immediate mode

I know that WebGL is based on OpenGL ES 2.0 and that glBegin and glEnd have been removed and replaced with vertex buffer objects. I understand that VBOs are faster and use less code but is there a ...
0
votes
0answers
80 views

Bouncing objects against the side of the screen

I want to have certain circular objects bounce against all four sides of the screen. After searching a lot on the internet, I found the following formula: Vout = Vin - ((1+e) *dot(Vnormal, Vin) * ...
0
votes
4answers
309 views

HTML5 Jump and Run Game Performance issues

we're developing a HTML5/Javascript jump and run game and therefore we have developed our own gameframework. It consists of following most important structures: Stage/Scene/Layer: divs ...
0
votes
0answers
105 views

Impact js Multibody entities with animations

I have a simple impactjs project working with box2d. just a "car" that can run over some rough terrain. I would like to have the wheels spin though. I know I could accomplish this with a sprite sheet ...
2
votes
2answers
1k views

ImpactJS and Construct 2

I'm interested in HTML5 game development and I found about this 2 game engines, I already know ImpactJS requires more programming experience and that Construct 2 has its own event and action system ...
3
votes
1answer
304 views

Javascript tile map -> bitmap or JSON

I would like to know which idea is better in terms of performance. The map is 5000x5000 tiles and I plan to expand it even more. It is split into 50x50 regions and camera doesn't move with player, ...
2
votes
3answers
401 views

Colouring greyscale images/sprites for HTML canvas

What is the best method to colour in sprites at runtime using the canvas element and javascript? I know there are various blending modes using globalCompositeOperation, but I don't know how best to ...
0
votes
3answers
218 views

timezone independant Date.now() for node.js game

I have a game I'm working on using node.js and socket.io. The issue I'm having, is I'm trying to have it so that players execute whatever actions they inputed about 50ms in the future, giving everyone ...
1
vote
0answers
294 views

Retrieving JSON return value from function and parsing in Construct 2

I would like to know how to parse a JSON object and parse each value into either an array, or something that I can use to set values of several global variables in my project file. I want to avoid ...
-1
votes
2answers
415 views

Control sprite animation speed using Create JS

How can I control the animation speed of a sprite using create JS? When you press right and left, the sprite will run through the frames... I'd like to leave the fps at 60, but alter how fast the ...
0
votes
1answer
189 views

“Painting” elements in html5 canvas

I'm making a game in coffeescript (although for the sake of this problem that's probably not all that relevant) and html5's canvas. It's a game that involves a paint cannon, that fires circular ...
1
vote
2answers
145 views

What ways are there for making vector types available in scripting?

I use Google V8 engine to embed Javascript into my game for scripting. As interface to my native code, I already registered some C++ functions to the scripting context. In the native code, I make ...
3
votes
1answer
317 views

Web single player 2d top-down RPG - background image, sprites, and new level loading

I'm making a web single player 2D top-down rpg using JavaScript (create js library) and have a couple questions. For the background image, I've currently loaded a 1000x1000 bitmap to represent the ...
1
vote
2answers
191 views

Bullet entry Point around Player Object

I have a player rotating by the mouse and want the bullets line up with the player's gun. Right now they simply come from the point of the player and shoot in the direction of mouse. I just need the ...