R
R
Radiks Alijevs2019-09-12 12:23:19
Game development
Radiks Alijevs, 2019-09-12 12:23:19

Performance in a browser game, what to use Canvas or DOM rendering?

I decided to make a browser-based game, with the ability to play on mobile devices, and on the design plan I ran into the question of how to make a game using only canvas or canvas + html5, or html5 for rendering.
The question is what consumes more PC resources, mob. canvas devices or DOM rendering?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dollar, 2019-09-12
@dedalik

Warm and soft (Canvas vs HTML5) cannot be compared.
See what is Canvas and what is HTML5, exact definitions.

Clue
Canvas is an HTML5 element.
That is, it's like you can't use Canvas without using HTML5.

DOM elements are quite slow, because searchability requires sacrifice.
In addition, in game development there is the concept of the main game cycle, in which a new frame is formed. In this case, usually the entire frame is completely redrawn. This gives a lot of flexibility in terms of changing the appearance of objects, different effects, etc.
As a consequence, of course, Canvas is better to use. The state of the game, accordingly, needs to be stored in JavaScript variables, in objects, and the simpler the structure, the faster iteration and rendering of a new frame.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question