"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
1answer
38 views

Understanding Javascript Variable Initialization [closed]

I saw this piece of code while doing research for an idle game I am making: var minions = new Object; minions = { 0: { name: "Mole", description: "...", price: 10, ...
4
votes
7answers
813 views

How to avoid cost comparison each and every frame?

I'm toying around with a ticker(incremental game) for JavaScript. The basic idea is that you have buttons that represent buildings, each building provides a certain amount of resource per 'tick'. ...
6
votes
1answer
461 views

Walking on a sphere

I'm working on a game which involves walking your character on the surface of a sphere. Using the answer to Arbitrary Rotation about a Sphere, I've written my code as: if (game.isKeyDown(37)) { // ...
1
vote
0answers
26 views

align local Y to be parallel with global Y during or after slerp

I am using the following function to have a globe rotate a point on its surface to face the global Z toward the camera. This works fine, but after each rotation the Y axis seen as a green line is not ...
0
votes
2answers
122 views

How do I keep a PHP server running forever?

I'm making a web game RTS, it's mostly create units, manage resources, attack with army, and level up factories. I have created the basics of the game using Javascript, PHP, and MySQL databases. I use ...
5
votes
2answers
78 views

Create.js CPU High load

I'm new in Create.js and I'm trying to make countdown progress bar. I have this simple code: var stage = new createjs.Stage("timerCanvas"); stage.canvas.width = ...
0
votes
2answers
68 views

Progress bar for EXP in javascript

So I am making an incremental game with Javascript, HTML5, and CSS, I need to have this bar that is esentialy a div with a p element in it "fill up" as the player earns more points through sacrifice. ...
0
votes
0answers
43 views

How to get the angle an object is travelling at

I'm trying to figure out how to get the angle an object is moving at, but have ran into a few problems. My player object is moved by rotating the entity left and right by using the left and right ...
2
votes
2answers
106 views

How do I find the set of regions that are fully enclosed by a color?

How do I get all areas surrounded by a certain color in a multidimensional array? For example, this map has three regions that are fully enclosed by red tiles. They are highlighted enclosed in pink. ...
1
vote
1answer
110 views

How to post player´s score on Facebook (with js)

I have my game made with Phaser (and compiled with cocoon.io) and on the leadersboard state I want to let the user to post his score on Facebook. Well, I created an App on Facebook and I´m not ...
0
votes
0answers
25 views

How to get the absolute position of the sprite in the renderview regardless of the pos of PIXI.Container?

I implementing panning on an infinite platforming game I developing but this is messing up with my current setup and structure of the game world (collisions, player location, etc.). Though I figured ...
2
votes
1answer
54 views

Particles to Denote Movement in Space

I'm currently working on a WebGL project to realise an idea I've had for some years. On my desk is book on making a space sim written 15 years ago. There I found some algorithm for particles in ...
1
vote
1answer
42 views

Javascript canvas check if all recs on the screen overlap a new one

So I know the AABB collision detection formula, however, this code does not work. Whenever I press space, a new square pops up. But this new square can spawn inside another, something that I do not ...
1
vote
1answer
45 views

Click counting and actions based off count

So I have a button that is the 'mine' for my incremental game. I would like to track the number of times that it is clicked and be able to do two things: Have events happen say every 5 clicks. ...
1
vote
1answer
27 views

Separating .js elements/ .js element communication

So I have 2 questions regarding the code below: function goldClick(number){ gold = gold + number; document.getElementById("gold").innerHTML = gold; }; function buyMiner(){ ...
1
vote
0answers
31 views

Arrow buttons not functioning properly [closed]

I have been cobbling something together from different examples that I have seen online I would like to know why is it not just showing 1 button per page and instead showing them all and decreasing ...
0
votes
0answers
26 views

Tweening back from arbitrary 3D rotation in javascript

I'm using a 3D javascript library to rotate the vertex of a 3D object with a classic 3x3 matrix, to an arbitrary angle in the 3D space, as depicted in the image below. For example, a first ...
2
votes
1answer
46 views

p2.js body position is NaN when spawned inside of each other

I'm working on a project for which I need a physics engine. At the moment I'm playing around with p2.js but I'm running into a problem: When I try to create multiple bodies (circles and/or boxes) ...
1
vote
3answers
155 views

Cube goes through objects

I have Unity Pro 4.6.1 and I am trying to make a cube move with the arrow keys. Here are the barriers before I move the cube: And here's when I move the cube (the problem): I don't want the ...
2
votes
4answers
334 views

How can I scale up sprites but maintain visual quality?

I am using WebGL. I have an isometric grid which contains tiles. Some have 'tree' sprites on them. If I have my tree sprite loaded from a texture with a fixed resolution, when I zoom into the grid ...
1
vote
0answers
49 views

Error with Cocos2d-JS when using Skeletal animation from Cocos Studio

Here is the JavaScript code: var size = cc.winSize; ccs.ArmatureDataManager.getInstance().addArmatureFileInfo(res.skeleton); // The error comes from the following line var armature = ...
1
vote
2answers
48 views

Where could i find 3d items in 3d points array?

I've been reading a lot but i can't find any answer, evenmore, English is not my main language so i don't even know how to ask it correctly. I'm currently working on a 3D render engine on JS and ...
4
votes
1answer
165 views

How do splines work?

I've been beginning to work with different kinds of splines (e.g. Bezier, Hermite, B-splines) in some of my work with computer graphics and I am trying to get a grasp of how they work (mathematically ...
1
vote
1answer
93 views

How do I check if one square is overlapping another in HTML5 canvas

I have a little program that goes like this: Whenever somebody presses space, a blue square appears. The blue square shouldn't overlap with any other blue square. But the function that is checking ...
6
votes
3answers
2k views

How to implement AI for fighting game

I built a 2D fighter yesterday. The second 'player' does hardly anything. Actually, nothing. To be honest, I have never made a game before that had an opponent like this. So my question is, how ...
1
vote
1answer
48 views

How would I load a new scene when a score that is stored in a string is reached?

This is a code that I am working on for a space shooter. Part of it works and my score does increase by 7 every second while being loaded into a GUI box, but my script does not load my scene when the ...
1
vote
1answer
66 views

Peer to Peer world download

I am creating a multiplayer JavaScript game with a PHP central server. Each user will be able to move around in a 3D world, with other users and NPCs. It came to my attention that SQL is not going to ...
3
votes
2answers
70 views

One big Instance or One instance for every moving entity?

I am creating a multiplayer JavaScript game with a PHP central server. Each user will be able to move around in a 3D world, with other users and NPCs. These NPCs will be controlled by the central ...
2
votes
0answers
42 views

My collision detection is not working when I rotate my mesh in three.js

I am trying to move a ball mesh through a maze. The maze belongs to a parent object3d. My issue is that when I move the ball I can't detect collision right well because in the rotation, the axis ...
2
votes
0answers
36 views

How do I display an image after pressing an UI button in unity3d? [duplicate]

I am working on a game in unity3d in which I want to display the details about the players when a button is being pressed. Suppose there are 12 players so for that I will have to make 12 UI buttons as ...
3
votes
1answer
42 views

Play Audio After Countdown In JavaScript

Is there a way I can have an audio sample play after a certain amount of time, like 3 seconds in JavaScript? I've looked everywhere and can't seem to find what I'm looking for! I'm very new to this ...
-1
votes
1answer
170 views

How to use custom font in Phaser ?

I am trying to load webfont in Phaser, I have seen the Phaser example but I cant understand, what asset do I need,what function I have to call....,what exactly look like the javascript file?. I am new ...
2
votes
2answers
105 views

How I can count how many time gameOver scene is loaded?

I'm building a game using unity 3d and I want to add an interstitial ads to it, but I want it to appear after the player lost every 3 times. So when the player loses for the first time the ads will ...
2
votes
0answers
72 views

SignalR For Multiplayer Game Development [closed]

I've been working with SignalR for live chat and notifications in .NET platform and was wondering how much is it worth for working on games development? I've made some jQuery browser games and I want ...
1
vote
1answer
127 views

Unity3D WWW get HTML displayed in browser

I currently have in a web page, on a localhost server, some information that I want to use in Unity. My problem is that this information are stored in some js variables. I tried to use the WWW class ...
0
votes
1answer
64 views

Is it bad practice to for the server to request data for a client from another client?

I'm making a collaborative whiteboard app so that when someone is drawing and uses a rectangle for example, a rectangle packet is sent to the server with parameters like x, y, width, height, color and ...
2
votes
0answers
30 views

Combining Two Sets of JavaScript

So I am fairly new to programming and I am trying to learn by making a simple game. I watched to different videos on ray cast shooting and one of them has code for bullet hole decals that I wanted to ...
1
vote
2answers
139 views

Why does player still leave map?

I'm making a simple HTML5 RPG in pure JavaScript likened after Nox, Diablo or Titan Quest, with the character centered on the screen and the map moving around it. TL;DR: My character, when colliding ...
3
votes
1answer
39 views

Timers and performance for mobile JS

I'm using the Three.js JavaScript library to do some things in WebGL, and I wonder how the graphic aspects of timers are done on mobile. I was creating numbers with geometries and just replacing them ...
2
votes
0answers
37 views

How would I add a sound variable to my code?

I am writing some code in JavaScript for a ray cast shooting program. I have all the variables I need except for sound, and I'm not too sure on how to add that variable into my code. I would really ...
1
vote
2answers
61 views

How can I minimise memory thrashing when doing vector math in JavaScript or ActionScript?

Please note that a similar question has been asked before in the context of C#. Say I'm building a 3D game in Javascript or Actionscript, and doing a lot of 3D vector math. In current libraries, ...
-1
votes
1answer
65 views

How do I show the ranking images at winning post?

I am working on a racing game in Unity3d and I have to show the rank as the winners touch the winning point. As the winners reach at the winning point the image of the winner number should pop up for ...
0
votes
0answers
27 views

Canvas - Cache large curves

Is there any way to cache large curves in javascript or a faster way than the native? I'm already caching scalable shapes, and it gives really huge performance benefits. They only get redrawn if they ...
2
votes
0answers
52 views

Phaser: Shader Chain

I want to implement lighting via shadowmaps. I see process as: 1) render something to RenderTexture1(size as game) 2) create RenderTexture2 (custom size) 3) add it to Image2 (custom size) 4) apply ...
1
vote
1answer
62 views

Javascript - How and where to put game initialization data

I'm new to JS game programming. In the past, when coding games (in Java), I tend to make separate files for configuration and game data (maps, character stats, etc). This is for separation of code and ...
0
votes
1answer
175 views

How can I export a model from Unity to three.js?

I want to buy some assets from the Unity asset store and use them in my three.js project, but I am not sure what the best way to go about this is. Some cursory googling got me this, but Collada ...
4
votes
1answer
254 views

How can I set 3d sound to my game in unity5?

I have been working on a racing game in unity5. Now I want to set 3d sound so that if the game objects are far away from and coming towards the camera then it sounds like began to attenuate and then ...
3
votes
1answer
793 views

Detect mouse click on a bezier curve's neighborhood

I'm developing a game in HTML5 and JavaScript using Canvas API for drawing graphics. I want to detect if the user has clicked on a bezier curve which has the line width of 20 pixels (something like ...
6
votes
4answers
209 views

Interpolation using cubic Bezier curves

I am trying to create an interpolate function for an animation library to achieve a tweening effect between frames. I want this to work with Bezier curves. I have created a jsFiddle (here) of my ...
0
votes
2answers
115 views

Rotate coordinates back after rotating game context (geometry)

To achieve something similar to the image below using HTML5 canvas one can simply write the following: var TO_RADIANS = 0.0174532925; context.translate(30, 20); context.rotate(30 * TO_RADIANS); ...