Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6946033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:30:47+00:00 2026-05-27T13:30:47+00:00

I have a relativly simply problem which is driving me up the wall. The

  • 0

I have a relativly simply problem which is driving me up the wall.

The Problem:
I need an algorithm to calculate the coordinates of a frame on a sprite sheet.

I have textures which can be 128×128 or 256×256 or 512×512 (pixels). These can have frames of 32 or 64. When loading a texture i tell my game what size the frames will be, therefore i can divide the frame size by the texture width/height and get my number of rows and collumns. And if neccessary i can multiply these to find the total frames in a texture.

Example:
I have a loaded a texture which is 256×256 with a frame of 64. Giving me four rows and four columns. I need to draw frame 12 to screen so my program must find the grid coordinates on the texture, (0, 3).

I hope this image clarifys what i mean:

https://i.stack.imgur.com/sF6GJ.png

Its annoying me how simple the algorithm should be but i suppose thats what clouding me from finding the right answer, any help is greatly appriciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:30:47+00:00Added an answer on May 27, 2026 at 1:30 pm

    You already have the size of the sprite sheet (which is 128*128, 256*256 or 512*512), you also have the size of each frame, says 64*64).

    Then you could get the value of frame’s origin by multiplying frame number to the frame width, and then divide the results with the texture width. the division’s results is the row and the remainder is the origin’s x. then simply multiply the row to the frame’s height to get the frame origin’s y.

    eg. frame size is 64*64, sprite sheet is 256*256. Suppose we are getting frame number 7.

    frameNo*frameSize.width = 448.
    row = 448/spritesheet.width = 448/256 = 1
    origin.y = column*frame.height = 1*64 = 64.
    origin.x = 448 % 256 = 192
    

    so the origin is (192,64).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a relatively simple application which I need to make native Mac OSX
I have a relatively simple problem. I have a model named Item which I've
I have a computational geometry problem that I feel should have a relatively simple
I have a relatively simple class which deletes a post: function delete_post($postid, $reason){ //Stuff
I have a problem with a relatively simple query and the execution plan Access
I need a method of inserting javascript which is controller/action specific into a layout.
I have a relatively simple problem bat as yet I haven found the most
I've recently set some coursework for some undergraduate students for which they have to
Does anyone have any good references for equations which can be implemented relatively easily
I'm writing a relatively big project in C++ and have a problem with object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.