Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Islandranger · Nov 29, 2012 at 09:23 PM · arrayimagescramble

How to make a scrambled image using arrays?

I'm working on a project where I took a image, cut it up into little bits and now I need to get those bits into an array in a mess up order. The objective is for the player(s) to unscrambled the image. Here is the code for what i have now.

 public var symbolPrefab:GameObject;
 private var gridWidth: int = 8;
 private var gridHeight: int = 8;
 var gridArray:Array;
 var offset:float = .2;
 var imageArray:Array;
 
 
 
 
 
 function Start () 
 {
     createGrid();
     //imageArray = [pic11,pic,12,pic13,pic14,pic15,pic16,pic17,pic18];
     
 }
 
 
 
 function Update () 
 {
     
 }
 
 
 
 
 function createGrid()
 {
     gridArray=[];
     for(var i:int = 0; i < gridHeight; i++){
         var row:Array=[];
         for( var j:int = 0; j < gridWidth; j++){
             var x:float = j*(1+offset);
             var y:float = i*(1+offset);
             var pos:Vector3 = Vector3(x,y,0);
             var rot:Quaternion = new Quaternion();
             //setImageArray();
             var symbol:GameObject = Instantiate( symbolPrefab, pos, rot);
             symbol.transform.parent = transform;
 
             row.Push(symbol);
         }
         gridArray.Push(row);
     }
     transform.position.x = -4;
     transform.position.y = -3;
 }
 function setImageArray (){
     //var rNum:int = Random.Range(0, imageArray.length);
     //var image
 }

I'm aware that I need a septare function to get the image bits into the array but how do I do so? Do I need to have each image to be giving a number that will be randomized as the array is being bult? What do I do? Also I would like if I could get it so that it will understand that the sections are where they need to be.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ThePunisher · Nov 29, 2012 at 11:18 PM 0
Share

For a moment I thought you asked how to make scrambled eggs using arrays. :(

avatar image Bunny83 · Nov 29, 2012 at 11:39 PM 0
Share

I'm a bit confused about that question. You instantiate always the same prefab, do you change the texture somewhere? Anyway is there a good reason why you use "jagged arrays"? I would also recommend to use either native arrays or a typed container like a generic List.

Oh and btw, you asked like 3 or 4 questions at once. The answer to all of them with code examples would be your whole game, so i will not do that. You should have asked a seperate question for each part. Read the FAQs

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to scramble image pieces? 1 Answer

Load image file into pixel data array? 0 Answers

Positioning groups of clones into specific shapes/patterns 0 Answers

How to create an image gallery with previous and next button with C#? 6 Answers

How to add all sequence images at once in array. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges