Tuesday, November 27, 2007

How to shuffle deck of cards


When making some Flash game there is sometimes need for Arrays manipulation. For example if you make game with cards, you want to find a way how to shuffle set of 52 cards. Let's say your array is:

a = Array("1h", "2h", ..., "14h", ..., "14d");

now, you can use next function to shuffle your cards array:

1.function shuffle( b:Array ) : Array{
2.     var temp:Array = new Array();
3.     var templen:Number;
4.     var take:Number;
5.     while (b.length > 0) {
6.         take = Math.floor(Math.random()*b.length);
7.         templen = temp.push(b[take]);
8.         b.splice(take,1);
9.     }
10.   return temp;
11.}


What this code means? I hope it is clear I only have to explain lines in while loop, because everything else is easy to understand. So, while loop will work until there are elements in start array, and do remember that we take one element from that array in every pass. With line 6 we choose randomly one element of start array. Then in 7, we push that element in first empty place in result array and than in line 8, we exclude same element from start array. In every while loop pass, start array is shorter for 1 element and result array is longer for 1 element. Since we choose element randomly in the end function returns shuffled array. Simply as that.

You can test this function with this code:

trace(a);
trace(a.length);

function onMouseUp() {
    var c:Array = new Array();
    c = shuffle(a);
    trace(c);
}


Download this function and few more here.
Enjoy!

Posted by flanture at 03:21:34 | Permanent Link | Comments (0) |

Wednesday, November 21, 2007

Charles Darwin's Beagle


Recently I spent several hours traveling by bus, without any source of fun except my Nokia mobile phone. I realized that I have to do something about it for such future trips. I enjoy reading, but carrying books around is not always an option.

Solution is mobile book or mBook, which is small Flash lite file I can transfer to my mobile phone. There are limitations, I know, but I'm not looking for perfection just something that can do the trick.

Check out my example - Charles Darwin's The Voyage of the Beagle preface. download here.

File is only 9 kb and has 14 pages. File dimensions are 176 x 208. First screen is "jump page" where you can enter page number where you wanna start reading. Press right button, then OK and enter number of page and then number 5 for jump. Navigation is done by pressing buttons up and down.

Now this mBook is just small experiment, but it allows any text book to be converted in a form that is suitable for reading on mobile devices that supports Flash Player. So, what should I read next?
Posted by flanture at 04:20:27 | Permanent Link | Comments (0) |

Friday, November 09, 2007

Snake Game Flash Tutorial


This one is a little bit old, but you can learn from it. Tutorials are written back in 2004, but you can see from comments that during those 3 years people have find tutorials helpful and fun.


Tutorial is written in ActionScript 1.0 for Flash MX. It has around 130+ lines explained in detals. Enjoy.
Digg!
Posted by flanture at 21:19:01 | Permanent Link | Comments (0) |

Wednesday, November 07, 2007

Where to sell your flash games


You have finished your Flash game, you like it a lot and you want others to play it. Have you consider to monetize your work besides giving others joy of playing? Here are some good places on web where you can make a buck or more.

Kongregate is maybe best place for you. If your game is chosen you can win some weekly cash or monthly top $1500 prize. Also, Kongregate shares ad revenues with developers.

Mochiads "is a no-hassle way for Flash game developers make money from every play. Their flexible system is easy to setup and gives you control over where and when advertisements show." You place ad inside your game and every time someone plays it you earn. No cost and no obligations. Payments are via PayPal after your earnings reach $100.

CrazyMonkeyGames will sponsor your Flash game, just ask for it on contact page.

Gamegecko is another website where you can ask for sponsorship request for your games.

NewGrounds is THE biggest flash portal on Internet with 500k visitors a day. Here you can find opportunity to be noticed by many and where is traffic, there is cash also.

Hope this quick list will help you in your money making online quest with your Flash games development skills. If you know any other good website do leave a comment. Thanks.

Digg!
Posted by flanture at 13:18:02 | Permanent Link | Comments (4) |

Thursday, November 01, 2007

Traffic report for 10 2007


First of all, Google page rank update is maybe over, but Flanture is still waiting for final results. Before this update Flanture was PR5 and now BLOGFLUX says Flanture is 6 and IWEBTOOL says it's 4. However, both of them say that new Flanture is PR7 ! Which is awesome!

This month traffic has increased by 50%, much more than I have expected and hope for, so I will not make any predictions for November. Flanture have posted 7 times with 3 reviews. Thanks all visitors. I will continue to try my best to write quality content here. I hope I will write more about flash lite, mobile gaming and flash games in general.



Posted by flanture at 21:21:12 | Permanent Link | Comments (0) |