Skip to content

Given xy coordinates of snake head, calculate display buffer location so that it will display in proper location on screen #51

@natruffles

Description

@natruffles

Given x-coord, y-coord, and display buffer location, need to calculate where in the display buffer the pixel needs to be set, using these three steps:

  1. set the 5th-15th bits of x-coord all equal to 0 (so we get a value 0-15 instead of 0-31)
  2. perform exponentiation: x -> 2^x
    this will set, if value is 0, value will be 0....01, if value is 1 will be 0...10,
    if value is 2 will be 0...0100, and so on. setting xth bit equal to 1
  3. flip the bit orientation. because if x = 0 we need it to be 10...0, not 0...01

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions