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

Javascript is a scripting language used to make both client side (browser) and server side (node.js) applications. As of the introduction of HTML5, it is getting increasingly more popular as a choice for game development, usually utilizing the <canvas> tag.

Characteristics:

  • object oriented
  • prototype based
  • C-style syntax

Typing:

  • dynamic
  • weak
  • duck

Game programming in Javascript:

Good resources for JavaScript 2D game programming?

1424 questions
11
votes
1 answer

Implement Fast Inverse Square Root in Javascript?

The Fast Inverse Square Root from Quake III seems to use a floating-point trick. As I understand, floating-point representation can have some different implementations. So is it possible to implement the Fast Inverse Square Root in Javascript?…
Atav32
  • 219
  • 2
  • 11
8
votes
3 answers

Y and X - Am I doing it wrong?

I sometimes run into small issues when doing my JavaScript projects. That is because most build in functions of JavaScript run X,Y if positions are needed. (In that order). But when I build a 2D Array I start out with Y, it seems more logical for…
Oliver Schöning
  • 452
  • 3
  • 15
8
votes
4 answers

How do I play audio with Javascript?

I want to add a short audio track to a game of concentration I'm coding. I want the sound to occur when the user has won the game. How do I go about doing this? I would really appreciate the help, thank you.
Sarah Ashleigh
  • 81
  • 1
  • 1
  • 3
6
votes
2 answers

Am I on the right track with Pong?

I'm a web developer who is trying to know more about game development. I've started trying to make Pong using canvas, just to see how far I can go (and what I can learn along the way). I have heard a lot about the game loop but being a novice was…
alex
  • 763
  • 1
  • 9
  • 17
4
votes
3 answers

How to get the center of a rotated rectangle regardless of point of rotation

I need help working out the centre coordinate of a rotated rectangle regardless of the point of rotation (i.e. the rectangle doesn't rotate around its center). I do not know the coordinates of the corners, so it's not a simple case of dividing…
PhotonStorm
  • 521
  • 3
  • 9
4
votes
2 answers

Will setInterval give me Delay?

I am setting up a JavaScript Server for my Game. Am I understanding this correctly: If I use setInterval to call a function every second, and takes 2 seconds to process. Then I am going to "stack up" requests indefinetly the Client will become more…
Oliver Schöning
  • 452
  • 3
  • 15
4
votes
3 answers

How do I prevent loop that moves character to run twice? (Javascript)

I managed to make a simple loop to move my character, onmousedown I move the character diagonally to where the user clicked. It's working but my problem is that I don't know how to prevent more loops to start over the first if the user clicks more…
Lisandro
  • 79
  • 3
2
votes
1 answer

How would one create a "start button" on a website similar to some Korean games?

Some games have buttons that would actually let you click them and you'd log right into the game. How does the web browser get permission to do this without plugins? Perhaps the client registers a custom protocol URL? They used to be popular a few…
Vaughan Hilts
  • 5,439
  • 1
  • 32
  • 57
2
votes
1 answer

Is there any opensource game frameworks in browser?

I have been looking for and found any.
user2951
  • 105
  • 1
2
votes
2 answers

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

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 JSON txt files on the website? Or maybe simple text…
test
  • 477
  • 4
  • 11
2
votes
1 answer

Selecting objects on a 2D map

I have a object selection function by checking the mouse click and getting the relevant object. How ever there is a rare situation where if one object is partially behind the other then both objects are in the given area so im wondering how I can…
Dave
  • 480
  • 8
  • 20
2
votes
1 answer

how can i make an object in a canvas always look at the mouse cursor

this is my code var myGamePiece; function startGame() { myGamePiece = new component(30, 30, "red", 10, 120); myGameArea.start(); } var myGameArea = { canvas : document.createElement("canvas"); start : function() { …
user118955
  • 21
  • 2
2
votes
0 answers

how to detect if a line is crossing another shape in javascript?

given the situation here http://jsfiddle.net/h902cLpy/ is it possible to detect that a line going from A to B does cross another shape while A to C doesn't?
topcat
  • 21
  • 1
1
vote
1 answer

If fixed timesteps are unreliable across web platforms, what can I use in my game loop?

As I have found out in my previous question, window.setInterval is not the best choice for a cross-platform game loop. What is my alternative for a game loop in Javascript that will (attempt to) run at the same speed on all devices?
user25855
1
vote
1 answer

using delta timing is causing shake

I am using delta timing to account for potential drop in frame rate. Only trouble being when I do this, I can notice an ever so slight wobble. I checked out the following JSFiddle coming from a tutorial on the subject and I can even see the wobble…
Warren
  • 11
  • 1
1
2 3 4