Hot answers tagged

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
  • 119k
11 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 follows our quality guidelines. One thing that ...
Pikalek's user avatar
  • 12.2k
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
5 votes
Accepted

Security concerns related to HTML 5 games

I would like to know if people could modify an HTML 5 game's code Yes. Like all web technologies, the client has full access to the local code; they can browse the source, modify it and send ...
Vaillancourt's user avatar
  • 16.3k
4 votes
Accepted

HTML5 realtime MMO games, should I do server side physics update or client side?

Unless you want players to be able to teleport through walls using their browsers build-in JavaScript debugger, you will have to implement any game mechanics worth manipulating on the server. This ...
Philipp's user avatar
  • 119k
3 votes
Accepted

How do I make an HTML5 canvas tiled map with tiles which have other than squared edges?

You need to create some transitional tiles like these: Image source: http://opengameart.org/content/lpc-more-water-transitions (licensed under CC-BY-SA 3.0) As you can see there are tiles in this ...
Philipp's user avatar
  • 119k
3 votes
Accepted

How should I efficiently clear and redraw my canvas with lots of animated sprites?

The first thing you should do is figure out if you actually have a problem. Is the way you're clearing the canvas now slow? Are you dropping frames because of how you clear the canvas? Regardless of ...
drhayes's user avatar
  • 3,912
3 votes

What JavaScript and or Html should engine I should use?

I am using BabylonJS a lot. If you want to go into 3D Games, it is as of right now the best engine you can get and it's free. In the HTML5 Game Devs Forum the whole community is gathered. They are ...
Jodo's user avatar
  • 151
3 votes
Accepted

Maths ? coordinates rotating around coordinates

You don't need matrices at all. Just take the rotation angle in radians, get its cosine and sine, multiply them by the distance you want between the two objects and add the x and y values of the fixed ...
user6245072's user avatar
3 votes
Accepted

HTML Canvas Makes Everything Bolder On Right Side

context.clearRect() has a method signature of: context.clearRect(x, y, width, height) In your code, however, you are passing ...
XNargaHuntress's user avatar
3 votes
Accepted

How to draw an image on canvas without html

Philip's suggested improvement to DMGregory's answer is important. ...
Jose_X's user avatar
  • 146
3 votes

How can I convert an Android game to HTML5?

There are some frameworks (like PhoneGap) which can build an application for multiple build targets. But only if you developed the application from scratch with that framework. When it is a native ...
Philipp's user avatar
  • 119k
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
  • 119k
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
  • 119k
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
  • 119k
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
  • 29.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
  • 119k
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,151
2 votes
Accepted

Unity WebGL not loading on chrome

I believe the issue is occuring because you are running it locally rather than on a webserver or an emulated webserver. Basically: You need it to say http:// or https:// or whatever rather than file:/...
HappyGuyDK's user avatar
2 votes

Fastest way to render isometric world with moving entities?

From my own experience, I've found that using the sum of components (x + y + z) is a very good measure for sorting entities in an isometric scene. It doesn't perfectly represent the distance your ...
Bartvbl's user avatar
  • 121
2 votes

Updating bots/AI behavior after a fixed elapsed timestamp in game loop?

The easiest way is to use counters. If you want your bots to do something in X frames, you'll have: ...
congusbongus's user avatar
  • 14.8k
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
  • 119k
2 votes

Is it possible to write a game with a HTML5+REST service architecture?

The problem with REST is that it is based on HTTP, which is not a protocol designed for low latencies or minimizing traffic. When you just want to send a few bytes, the HTTP header will generate huge ...
Philipp's user avatar
  • 119k
2 votes
Accepted

2d game with 3d js. game engine

2d rendering is easily possible with 3d rendering engines, even when there is no explicit support for it. How it would work: Just put your two-dimensional geometry parallel to the xy-plane (or any ...
LukeG's user avatar
  • 1,537
2 votes
Accepted

requestAnimationFrame handles game ticks weird when tab isn't viewed

Indeed, that's one of the "features" of requestAnimationFrame, it frees resources from not-focused tabs. To use this animation method you should use deltatime to keep track of the time elapsed ...
PRDeving's user avatar
  • 755
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
  • 840
2 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
  • 131
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
  • 259
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
  • 26.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
  • 134k

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