GameMakerHelpBlog

Sunday, January 6, 2008

fibonacci

I was looking at fibonacci sequences and i thought, was this GM compatiable. And of course it was. There are better scripts for this but this one doesn't use sqrt or power, but it does require variables!

[code = create event]

last_number = 0
new_number = 1

[/code]

Last_number is the last number which is 0, this won't be found unforunately without calling it first.
new_number is our first number

Don't put this in STEP event
[code]
//usuage: fibonacci(num) - num is the number of figures to find
repeat(argument0)
{
i = new_number + last_number
last_number = new_number
new_number = i
}

i is the finding of the last two figures


that is it. I am not sure how this would help with your games but it is here

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home