[Beginner] Javascript browser game from scratch

ciro64

Castlevania 64 apologist
RGT Supporter
Level 5
Joined
Dec 18, 2024
Messages
1,177
Reaction score
5,107
Points
3,477
Location
Brazil
I made a tutorial!


I introduce concepts one by one. Or rather, I throw them at you and you see immediately what it does. It's not a proper introduction to programming concepts in a more isolated way, so people who never touched code before might feel a little overwhelmed. For that reason, I intend to do another tutorial bridging that gap if my motivation keeps up, and then more advanced ones after that.

Let me know what you think of it, or if there's any problems or questions.

Thanks for reigniting my gamedev passion, RGT! ::terriermon-happy
 
I would have used requestAnimationFrame instead of setInterval

The frequency of calls to the callback function will generally match the displayrefresh rate.

For that specific reason

 
I would have used requestAnimationFrame instead of setInterval
I think the main goal in this tutorial is to provide a general idea about how things would work for beginners.

Using requestAnimationFrame is better, but i think it can be considered as a technical detail.

I think this tutorial is well designed overall, and fulfills its purpose. 👍
Also, ciro64 said he might create more tutorials to fill the gaps. ::coolstafy
 
I would have used requestAnimationFrame instead of setInterval



For that specific reason

Thank you for looking at the tutorial!

I decided to use setInterval for the sake of simplicity.

If I used requestAnimationFrame instead, I'd either have to:

  1. Multiply the movement with delta time. While it would have been fine for this game, I plan to make tutorials that build on top of this one, introducing concepts of acceleration, gravity and platforming. In those more complex cases, it's a bad idea to use delta time in the logic loop because it introduces instabilities in the game physics, which can affect the gameplay quite a lot.

    I don't think delta time is a bad thing on its own, but I've seen tutorials and even game engines in the past create a bad habit in developers by encouraging them to use it everywhere.
    .
  2. Handle the drawing at every requestAnimationFrame call and the game loop in some other way. A good way I found to do this is to calculate how much time has passed from the last animation frame and advance logic frames accordingly. This method also compensate for stutters unlike setInterval.

    But like @JustLooking123 said, I want to keep things simple by introducing them one by one. But in a future tutorial, I might introduce complex loop handling.
 
I think the main goal in this tutorial is to provide a general idea about how things would work for beginners.

Using requestAnimationFrame is better, but i think it can be considered as a technical detail.

I think this tutorial is well designed overall, and fulfills its purpose. 👍
Also, ciro64 said he might create more tutorials to fill the gaps. ::coolstafy
I understand that, setInterval is definitely the most concise and straight forward approach, however animation stuttering tends to ruin everything, no matter how well your sprites look, no matter how hard you tried to optimize the rest of the code, end result still is disappointing and there's nothing you can do about it, except sync with refresh rate...
 

Users who are viewing this thread

Connect with us

Featured Video

Gintama Rumble (VITA)

Latest Threads

JRPG's that you still can play after main story completition?

it's a rarity, but i think i have encountered a couple back then that offered that possibility...
Read more

What's your favourite sprite art from a video game?

Hi Everyone!

I'd love to see examples of people's favourite video game sprites from any era...
Read more

The theme of RGT-tan

1746762113150.png

What songs you feel like could her theme?


There's...
Read more

Godzilla: Monster of Monsters to me, is quite the enjoyable romp!

HOO-HOOT, greetings sons of man- nothing like a good game to stretch those talons over, right...
Read more

Story of my life

You knew the times when something bad happens and after some or a bunch of time is passed that...
Read more

Online statistics

Members online
140
Guests online
221
Total visitors
361

Forum statistics

Threads
7,673
Messages
190,977
Members
563,201
Latest member
Abelexposito266

Support us

Back
Top