x


Rotating a linear number - How?

I am currently writing code to construct a game for android devices, however part of my code requires rotating numbers to create random choices, missions, stars etc. However I am fairly new to coding and although I understand quite a bit of it, this has me completely stumped.

I am writing this in Javascript/Unityscript

Currently my code is as follows, at least where I am stuck that is...

var coordx_2;
var coordy_2;
var sysNum;
var dest;
var strcpy;
var strcat;


    coordx_2 += sysNum;
    coordy_2 += coordx_2;
    coordx_2 = rotate_some(coordx_2, 3);
    coordx_2 += coordy_2;
    coordy_2 = rotate_some(coordy_2, 5);
    coordy_2 += coordx_2;
    coordy_2 = rotate_some(coordy_2, 4);
    coordx_2 = rotate_some(coordx_2, sysNum);
    coordx_2 += coordy_2;

    strcpy (dest, namePart[(coordx_2>>2) & 31]);
    coordx = (coordx_2) 5; //This is the part that needs rotating, also says that ';' is expected
    strcat (dest, namePart[(coordx_2>>2) & 31]);
    coordx = (coordx_2) 5; //This is the part that needs rotating, also says that ';' is expected
    strcat (dest, namePart[(coordx_2>>2) &31]);
    dest[0] ^= 0x20;

I should also mention that I do not want to use the Rand keyword as that will create too many random elements, this is meant to be a controlled reaction, Think of it as rotating an object by so many degrees, but each time you do it, it changes shape slightly.

more ▼

asked Apr 24 '12 at 08:13 PM

Supershandy gravatar image

Supershandy
29 2 5 9

I am missing the random part here - what makes your result random?

You can control what random gives you. You could random between how many elements you'd like. Even 1 for that matter (which would practically result in nothing random of course).

Apr 24 '12 at 08:18 PM GuyTidhar
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3731
x295
x76
x55
x17

asked: Apr 24 '12 at 08:13 PM

Seen: 311 times

Last Updated: Apr 24 '12 at 08:18 PM