Skip to main content
14 votes

What to do when my game is rejected by CrazyGames?

From the CrazyGames Developer FAQ, under the heading Uploading my games: Can I submit a rejected game again? Only if you have improved your game and it complies to our requirements. One thing that ...
Pikalek's user avatar
  • 13.3k
11 votes
Accepted

HTML5 games: play() failed because the user didn't interact with the document first

There is a good reason for this precaution: Users usually don't expect audio from websites. They get really angry when they load a website, and an audio advertisement blares at them at full volume. ...
Philipp's user avatar
  • 123k
7 votes
Accepted

How can I use vibration of an iPhone for my HTML / Javascript game?

As you have found out, the W3C Vibration API is not supported in the iOS Safari browser (as reported here: https://caniuse.com/#feat=vibration). However, you've pointed out that you plan to package ...
Crumbledore's user avatar
6 votes

What to do when my game is rejected by CrazyGames?

I just saw your game, and no offense, but it looks like it is subpar quality compared to the other apps on the site. Off the top of my head, I can list several points that may be fundamentally wrong ...
Simon C's user avatar
  • 61
3 votes
Accepted

online game, NPC monster death and hit detection to gain experience points

When you want a cheating-proof client/server game, then you need to handle all game mechanics which are worth cheating on the server. Don't send "Player X hits enemy Y for Z damage". Just send "...
Philipp's user avatar
  • 123k
3 votes
Accepted

WWW request does not connect using webgl platform

When you look into your browsers error console, you will likely notice an error message like this: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http:/...
Philipp's user avatar
  • 123k
3 votes
Accepted

WEBGL antialias false to pixel art low resolution

Helped me in html5gamedevs forum. Solution: The scale mode of the texture needs to be set to nearest. You can either do that on a texture by texture basis via the scaleMode property, or change ...
salc2's user avatar
  • 141
3 votes

How to improve load times of audio files without loosing too much quality for HTML5 game?

When you take an audio clip which is already encoded in a lossy compression format and then re-encode it again with a different lossy compression, then any compression artifacts will accumulate and ...
Philipp's user avatar
  • 123k
3 votes
Accepted

How to get projectile direction vector in a 2d grid?

To find the unit vector from the angle you want to use cosine(angle) for the x-component and sin(angle) for the y-component. The angle must be in radians. You can convert from degrees to radians by ...
SquidJelly's user avatar
3 votes

How can I convert an html5 web game to an android app?

Your first step should typically be to simplify the app down to its simplest working version. Gut everything that is causing the app to fail to run on the new platform (comment it out OR put in mock/...
Engineer's user avatar
  • 30.4k
3 votes
Accepted

In regards to real time turn based games, where should the turn handler be?

The general rule of thumb for handling multiplayer games is that any game mechanics which can be handled on the server should be handled on the server. There are two reasons for that: The less the ...
Philipp's user avatar
  • 123k
3 votes
Accepted

How can I protect against a cheater changing variables on the client?

This won't prevent all cheating but at least will make it harder for the average cheat engine/ change variable hack. Follow the simple advise: Don't trust the client. Now what does that mean? Usually ...
Zibelas's user avatar
  • 4,692
2 votes

How to rotate an image on an HTML5 canvas, without rotating the whole canvas?

Based on Luis Estada's answer, I created rotateContext function to rotate images and other shapes: ...
anayarojo's user avatar
  • 121
2 votes
Accepted

unity webgl scale page on different sizes of internet browsers on pc or phone

change the HTML as documented here. You can choose either one of the defaults or create your own template. According to those docs you create folder in Assets ...
gman's user avatar
  • 850
2 votes

Implementing multiplayer aspect of a simple HTML5 game

I remember struggling with the same thing actually and here it is. I figured it out not long time ago. I will use the rotating triangle as an example. The server is the one that needs to figure out ...
Joza100's user avatar
  • 269
2 votes

HTML5 - check if font has loaded

The JavaScript FontFace class is (as of July 2020) still a working draft, but already supported by all browsers except (as usual) Internet Explorer. It can be used to load a font via JavaScript and ...
Philipp's user avatar
  • 123k
2 votes

How to improve load times of audio files without loosing too much quality for HTML5 game?

I will assume that you have exhausted all that may come from encoding and compression. First off, load only what you need next, use a load scene when appropriate. Now, what you probably want is to ...
Theraot's user avatar
  • 28.2k
2 votes
Accepted

How to get the address of a nearby square on a chess board?

It looks to me like what you really want is a 2D array for managing your board state, which in JavaScript you can accomplish with a nested array. Your x & y coordinates stay as plain integers ...
DMGregory's user avatar
  • 140k
2 votes

Why does my godot game not take input in the browser?

Cause of the problem: I have two scripts named p2.gd and p1.gd inheriting from a base player class. I had not named the base class. So, my p1 and p2 scripts contained references to player.gd in terms ...
ashir's user avatar
  • 31
2 votes
Accepted

What is the best way to store level data in HTML5

There is no "best" way. Only the way that works best for your game. But loading data from files via fetch at runtime is certainly not the worst idea. ...
Philipp's user avatar
  • 123k
2 votes

How to port a JavaScript game to Nintendo Switch and PlayStation 5?

"How to translate JavaScript to C++" is a bit of an X-Y Question so I'm going to answer what you are actually trying to do, how to run a JavaScript game on Nintendo Switch / PlayStation 5. I'...
Charanor's user avatar
  • 8,504
1 vote

HTML5 game pases when you go to another tab

Separate your game's code into logic code and drawing code. Put the logic code into a function which you execute at regular intervals with SetInterval. Intervals ...
Philipp's user avatar
  • 123k
1 vote
Accepted

Why can't I load images in processing.js and let them be dynamic?

You cannot load and use images from other domains with HTML5 canvas. Make sure to serve your images from the same domain/server as your processing code. Alternatively, enable cross origin access on ...
schteppe's user avatar
  • 251
1 vote

HTML5 games: play() failed because the user didn't interact with the document first

Please go through https://developers.google.com/web/updates/2017/06/play-request-was-interrupted if you need additional info. To load the track ...
N N K Teja's user avatar
1 vote

Javascript-How to create a moving bullet animation from canvas

You need to update the bullet's position each frame. So you should add an update function to the bullet constructor. And in it, update the ...
Kitanga Nday's user avatar
1 vote
Accepted

Draw the HUD just once on the canvas

Building on your answer, you definitely need to preload all your resources before even starting the game. So your process would be preload_assets ==> Start_game Here's an extract from this great ...
Kitanga Nday's user avatar
1 vote

Draw the HUD just once on the canvas

I found the error, the image was being called in drawImage() before it was loaded, unfortunately I did not receive any error that could inform me of this. But I did work by changing the function to: <...
PerduGames's user avatar
1 vote

Turning a simple HTML5/JS single-player game into a multi-player one

Turning a game developed for singleplayer into a multiplayer game when it was not designed for that from the start can be extremely difficult, both regarding software architecture and regarding game ...
Philipp's user avatar
  • 123k
1 vote

How does the double-buffered canvas know when to swap the buffer?

In HTML5, the browser lets you know when it's ready to paint the next frame via requestAnimationFrame. Usually, your "draw" calls happen within this callback. In ...
congusbongus's user avatar
  • 14.9k

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