The Daily Click ::. Forums ::. Klik Coding Help ::. Question about using Random in coding
 

Post Reply  Post Oekaki 
 

Posted By Message

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
4th January, 2011 at 21:10:11 -

So for example lets say i have an object that has none of the default animations used, so all 12 of them are blank. lets say i have 4 more animations after that, lets call them animation A, B, C, and D.
from what i understand from looking at other peoples coding, in order to skip those first empty frames you have to put set animation to Random(12)+4 (12 being the first animations, and 4 being the last 4 you actually want to display)

am i correct? or does the first animation count as animation 0? therefor making the coding Random(11)+4?
or am i completely misunderstanding these lines of coding?

 
[Game design makes my brain feel like its gonna explode.]

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
4th January, 2011 at 21:25:32 -

Random(4)+13 should do it.

Random() generates a number between 0 and the number you enter (including 0). So the possibilities for Random(4) are 0, 1, 2, and 3. If you add 13 to each of these, the possibilities are 13, 14, 15, and 16.

That should do it... Seems complicated, but at least you're not dealing with a system that always generates a decimal number between 0 and 1 no matter what!

Edited by OMC

 

  		
  		

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
4th January, 2011 at 21:32:33 -

oooooooooooh! that makes plenty of sense! thank you sir, i think you may have just aided me in fixing a glitch ive been trying to fix for about a week strait. Its been driving me crazy lol.

 
[Game design makes my brain feel like its gonna explode.]

Mark McCauley



Registered
  18/02/2009
Points
  291

Has Donated, Thank You!VIP Member
5th January, 2011 at 10:25:50 -

be a good idea to do

set value to 13+random(4)
rather than random(4)+13

because (I think ) the computer will treat the latter as random(17)

 
http://www.reddwarf.co.uk/forum/messages.cfm?threadid=44227736-C46F-AC56-02EBA05285818C14

Jon Lambert

Administrator
Vaporware Master

Registered
  19/12/2004
Points
  8235

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
5th January, 2011 at 13:31:08 -


Originally Posted by Mark McCauley
be a good idea to do

set value to 13+random(4)
rather than random(4)+13

because (I think ) the computer will treat the latter as random(17)

No, it won't, because the +13 is outside of the parentheses.

 
Sandwich Time!Whoo!

JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364

Hagar

Administrator
Old klik fart

Registered
  20/02/2002
Points
  1692

You've Been Circy'd!Teddy Bear
5th January, 2011 at 14:06:48 -

A+B = B+A

 
n/a

Mark McCauley



Registered
  18/02/2009
Points
  291

Has Donated, Thank You!VIP Member
6th January, 2011 at 12:20:07 -

OBVIOUSLY, it is outside the brackets ,
but I could've sworn the computer has treated the number as a whole before , maybe its just my schizophrenic pc.anyone ever have this happen to them?
but thanks for the correction.

 
http://www.reddwarf.co.uk/forum/messages.cfm?threadid=44227736-C46F-AC56-02EBA05285818C14
   

Post Reply



 



Advertisement

Worth A Click