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 7573897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:17:52+00:00 2026-05-30T16:17:52+00:00

I am making a game and I am trying to create a game end

  • 0

I am making a game and I am trying to create a game end function. How would I go about resetting all images to their starting positions?

  • 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-30T16:17:53+00:00Added an answer on May 30, 2026 at 4:17 pm

    You can programaticly store all positions of a image class inside a Object inside a array.
    And after you can loop the array restoring theirs positions back.

    var positions = new Array(0); //positions array
    
    function objPos(obj){
    
        return({
            'obj':obj,
            'x':obj.style.left,
            'y':obj.style.top
        });
    }
    
    
    function savePositions(imgContainer){
    
        var imgs = imgContainer.getElementsByTagName('IMG');
    
        for(var i=0; i<imgs.length; i++){
    
            positions[i]=objPos( imgs[i] );
    
        }
    }
    
    function restoreStoredPositions(){
    
        for(var i=0; i<positions.length; i++){
    
            var img=positions[i];
            img.style.top=positions[i].y;
            img.style.left=positions[i].x;
        }
    }
    

    Call the savePositions function on the initial state, and you can call restoreStoredPositions later. If you want persistent data, stringy the array to JSON and you can store it to a Cookie or HTML5 LocalStorage.

    I know this is pure JS but this is just a concept that I wrote now.
    You can adapt this to use the each() and the jquery selector on place of the getElementBy…
    I used the style.top and left just for readability, computedStyles is the correct path.

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

Sidebar

Related Questions

Im making a program about the game Go and im trying to write some
I'm making this game where I'm trying to pair people. So I have this
I built a slideshow/decision-making game in Flash but would like to try to redo
I'm trying to write a little CLI Hangman game, just to create something in
I am making a game and I am trying to decide what is the
Context I'm making a game engine using SDL and OpenGL. I'm trying to find
So I'm trying to create a simple multi-threaded game engine for the game I
I'm making a turned based poker game and trying to figure out the best
I am currently trying to create a menu system for a game and cannot
OK so at the moment I am trying to create an Android Game, I

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.