all day i've been thinking about javascript on and off and coming to the conclusion that i'm not good at javascript

"if everything is asynchronous, it seems unnecessarily hard to do things synchronously??" <- this is what hollies actually believe

like i know roughly how i'm going to poll for gamepad inputs once a frame, but i'm just having a hard time wrapping my mind around how to do anything useful with that

this is a me problem, i'll have to figure something out

actually i guess i can "fake" synchronous code if, instead of having gamepad polling act as like a clock that ticks everything else (this is what i was thinking of and it's hard if it's even possible) i just have my main loop run once a frame and poll for gamepad input as part of it

@monorail yes with the caveat that with javascript generally you want to separate logic "frames" (which you run with setTimeout every N milliseconds) and rendering "frames" (which you run with requestAnimationFrame) [if applicable]

logic code can/should check input as a part of that

Follow

@monorail generally when i do games stuff in JS i have:

- event listeners, which write to a object which tracks input states

- logic loop, which reads input states and read/writes game state

- rendering loop, which reads (but does not write!!) game state and updates the page

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.