Skip to main content
4 votes
Accepted

ForEach vs For loop in JavaScript | Which is more efficient?

You should not micro-optimize code at this level, unless you have good reason to believe it is a bottleneck in your code. This is for a number of reasons: 1) optimization depends on the particulars ...
Jimmy's user avatar
  • 9,059
3 votes
Accepted

Besides 3d, why would I need to use a canvas instead of using plain css and html?

The CanvasRenderingContext2D API is working in a way that is more familiar to game developers. Game developers who worked with other 2d graphics APIs before are used to having a function which says &...
Philipp's user avatar
  • 123k
3 votes
Accepted

How do you setup a scrollable overworld map on an HTML/JQuery based game?

Well, Jay's answer was technically correct, and gave me a good starting point. So +1 to him for that. However, I wanted to take the time to post a fuller answer for others who happen across this ...
Nicholas's user avatar
  • 141
3 votes
Accepted

How can I publish a Python game on itch.io as html?

Since mid-2022, pygame has partial support for WebAssembly as upcoming python3.11 and allows for running the same pygame code on desktops and mobile/web. To publish your game on itch.io as some people ...
Pmp P.'s user avatar
  • 156
2 votes

How can I publish a Python game on itch.io as html?

A game made with Pygame is not playable in the browser. Games made with that tool can be put on itch, but only as a downloadable desktop package, not as a web game. For completeness, I should mention ...
jhocking's user avatar
  • 15.8k
2 votes

ForEach vs For loop in JavaScript | Which is more efficient?

The indexed for loop is a bit faster (not much, but it is), since the js engine doesn't have to look the properties of the object up before looping through them. It basically does your job when it ...
Bálint's user avatar
  • 15.1k
2 votes
Accepted

Technology behind retrogames.cc video games

If you right-click on a game on this site, you get this pop-up menu: Clicking on "EmulatorJS v.0.4.24" takes you to this site explaining the JavaScript video game console emulator they use. ...
DMGregory's user avatar
  • 140k
1 vote

Web application for efficient placement of blocks

In your if statement: if (currentLeft + block.width > containerWidth) { currentTop += block.height + blockMargin; currentLeft = 0; } you're setting the ...
vanblart's user avatar
  • 111
1 vote
Accepted

Why wont my code work

If you want to increase the first 10 times the variable clicks + 1, and after 10, clicks + 2 you need to make sure that the names of the variables in the code are ...
p3tition's user avatar
1 vote
Accepted

How do I react to a variable having reached a certain value?

If you want to reward the player with additional click power, then it would make sense to make that a separate variable, and use that variable instead of the constant value of ...
Philipp's user avatar
  • 123k
1 vote
Accepted

2D moving objects in angle

The Simple Approach: Sin and Cos It looks like you're close. If you want to keep it simple, and assuming positive y is up and 90 degrees means go straight up and 0 degrees means go straight to the ...
bob's user avatar
  • 296
1 vote

How do you setup a scrollable overworld map on an HTML/JQuery based game?

What you are looking for is the HTML5 canvas element. From w3schools: The HTML <canvas> element is used to draw graphics on a web page.
Jay's user avatar
  • 822
1 vote

I keep coming across an error "Cannot read property 'innerHTML' of undefined"

You have written document.getElementsByTagName('missile')[0] and then later document.getElementById('missile') This looks ...
Jay's user avatar
  • 822
1 vote

Twine game animated blur effect

Generally speaking, the SugarCube format is more powerful, if you want to use Javascript. For your question, you just have to put ...
MyGamebooks's user avatar
1 vote
Accepted

Is reobfuscating javascript every time the page is loaded a valid option for a multiplayer game?

Summarizing the comment thread above: No amount of obfuscation will stop cheaters. The most it will do is slow them down by a little - and if your game gets popular, the amount it slows them down will ...
DMGregory's user avatar
  • 140k
1 vote

My HTML canvas keep flickering

Two things need to be improved in your code: Preload images Use requestAnimationFrame instead of setInterval Demo: ...
Lovro's user avatar
  • 31
1 vote
Accepted

Cap Framerate in the asynchronous world of Javascript

From the documentation: Ticker.framerate = 30; Hope that helps.
Engineer's user avatar
  • 30.4k
1 vote

Making a 2d shooting game. need a working shoot function

The array which contains your bullet (var bullets) is declared as a local variable within the shootGun() function. This already ...
Philipp's user avatar
  • 123k
1 vote

How to add a collision function to a game

So for collision detection and game development in general I suggest you start off with https://developer.mozilla.org/en-US/docs/Games/Techniques or https://www.w3schools.com/graphics/game_intro.asp ...
Ameer's user avatar
  • 151
1 vote

makeing a quest system in a html clicker. need help making repeatable quests and quests being done

You need an if statement to check against your variable. Such as: if (clickedTotal == questClickAmount){ questPoints++; } This will insure that you will only ...
Haley Mueller's user avatar
1 vote
Accepted

Problem with making camera follow player in Javascript

You just inverted the signs. The player's position should be the negative one and the canvas position, the positive one: ...
Danilo Souza Morães's user avatar
1 vote
Accepted

html/ javascript shop

To add onto @Xesenix's answer you probably want to make this generate it's own list, without you having to update the drop-down list each time. You do this by creating the drop-down through javascript....
Kitanga Nday's user avatar
1 vote

html/ javascript shop

To read current selected value from select drop down you need to modify is as follow: ...
Xesenix's user avatar
  • 148
1 vote

Is there a way to automatically group tiles in a A* pathfinding grid to find the largest areas?

I've heard this called "Room Generation" when used as an optimization to speed up A*. The only algorithm I know of is Rectangular Symmetry Reduction (though there are probably more) It is described in ...
BlueRaja - Danny Pflughoeft's user avatar
1 vote

Link CSS file with HTML file in Unity Power UI

The default href with PowerUI is resources:// so you don't need Resources/ just ...
user3211184's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible