[Beginner] Javascript browser game from scratch

ciro64

Castlevania 64 apologist
Moderator
RGT Supporter
Level 5
22%
Joined
Dec 18, 2024
Messages
1,331
Level up in
1169 posts
Solutions
1
Reaction score
7,869
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

Support this Site

RGT relies on you to stay afloat. Help covering the site costs and get some pretty Level 7 perks too.

Featured Video

Latest Threads

Questions about DS save files and homebrew.

So, I want to play some of the Pokémon games I still have on this DS I just bought. I also don’t...
Read more

Looking for a specific 90s style anime

Don't think there's a thread for this, but I’m trying to track down an anime I watched as a kid...
Read more

WELLLLLLLLLLLLLLLLLLLLLLLLLLLLLL

HE AIN'T MY BOY BUT THE BROTHER IS HEAVY
1752591366681.png
Read more

Buying an NDS worth it?

"I'm going to buy a Nintendo DS, but I don't know if it's worth it. Can someone give me tips on...
Read more

sonic unleased 3ds port in the works

Online statistics

Members online
186
Guests online
216
Total visitors
402

Forum statistics

Threads
10,345
Messages
256,545
Members
824,923
Latest member
yemawor117

Advertisers

Back
Top