Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic platforms #1

Merged
merged 7 commits into from
Apr 16, 2022
Merged

basic platforms #1

merged 7 commits into from
Apr 16, 2022

Conversation

rebecca-millerr
Copy link
Owner

@rebecca-millerr rebecca-millerr commented Apr 10, 2022

Basic platform setup

Finished

  • HTML canvas representation of map
  • Canvas with adjustable dimensions and scroll speed
  • Map infinitely scrolls to the left (as runners run to the right)
  • For MVP, always have a default map with just a floor and nothing else

Still TODO

  • Map magically will receive updates from server every frame for single source of truth
  • Make canvas clickable by builders, and then...
  • ...map magically will send updates to server every time a builder adds a block
  • Add physics to blocks

Lingering thoughts

Right now the new column gets added on the front end, i.e. individually for each client (which is the only way to get this PR to work with no Erlang server). Even though every user does get the same right column every time, I'm thinking this could cause issues with this updating the server a bunch of times (once for each client), so maybe in the future we want this to actually happen on the server and then update each client...

To test

Run the app, then go to /game. Voila! It doesn't look like much right now because it just creates the same map infinitely, but see video below for more obvious example of this in action. I changed it temporarily so the new columns come in with red blocks instead of blue, which makes it clearer that new columns are actually being added as older ones are deleted.

Screen.Recording.2022-04-10.at.2.38.16.PM.mov

Super appreciate any thoughts <3

@tylerjcalabrese
Copy link
Collaborator

tylerjcalabrese commented Apr 12, 2022

Probably j me being stupid but I'm getting this when I try to run it at localhost:3000 and localhost:3000/game . Have done npm ci
image

@rebecca-millerr
Copy link
Owner Author

Probably j me being stupid but I'm getting this when I try to run it at localhost:3000 and localhost:3000/game . Have done npm ci image

Hmmm weird. I recognize the error but I didn't have it when I ran. Try getting rid of import 'styles/global.css'; in index.jsx? (Theoretically it'll get rid of the error but the styles will still apply.... it should have a yellow-ish background if it worked...) You know Next better than I do @controversial any ideas?

@tylerjcalabrese
Copy link
Collaborator

looks great!

@tylerjcalabrese
Copy link
Collaborator

Screen.Recording.2022-04-15.at.7.37.07.PM.mov

On my end (Firefox):

@rebecca-millerr rebecca-millerr merged commit 61d753b into main Apr 16, 2022
@rebecca-millerr rebecca-millerr deleted the becca.basic-platforms branch April 16, 2022 20:20
Copy link
Collaborator

@controversial controversial left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a couple specific comments even though this is already merged

return row * VISIBLE_BLOCKS_ACROSS + col;
}

// TODO: have this run once total, not once per client - not sure how to do this
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we will probably have this for free because the server will send the “initial” map state to clients when they join; it won’t be clients’ responsibility to come up with the map by themselves.

}

// if entering brand new col
if (adjustedX === 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaict this is not guaranteed to run every time - if a computer is under some graphical load (e.g. from another program running) it's entirely possible that the time between requestAnimationFrames is such that adjustedX jumps from BLOCK_SIZE - 1 (or less) to 1 (or greater) without passing 0 (since it’s a function of the time)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants