Node.js

As a back-end for Solitaire and Mahjong games I’m using a separate VPS with Node.js, as a web server, and MySQL database, which I’m hoping to switch to MariaDB some day.
I really like Node.js, it can handle thousands of connections at once on a cheap VPS for ~$10/month.
On July 12 2013, All-in-One Mahjong was promoted on Amazon App Store as a Free App of the Day, and game had ~100k active players a day. But Node.js had absolutely no problems with that, even 512MB of memory was enough.

I’m very new to Node.js, so here are some links, that helped me to know it better:
Manual and Docs: http://nodejs.org/api/
Node.js driver for MySQL: https://npmjs.org/package/mysql
Some tuts: http://net.tutsplus.com/tutorials/javascript-ajax/node-js-for-beginners/
Forever: http://blog.nodejitsu.com/keep-a-nodejs-server-up-with-forever


Application Licensing ANE

I have published paid app on Google Play and Samsung Apps, so I have used there licensing services in order to protect the game from illegal copying (DRM).

In order to use these services with my current AIR apps, I have developed by own ANEs.
The source code along with extensions and some usage examples can be found on Github: ANE License Checker

I’m also going to publish the game on SlideME, so will add support of their licensing service later.

Luckily, Amazon and B&N has built-in protection, that is applied when you publish your app, no need to make extensions for them.


Mobile Market links

Here is how game can link to publisher’s page or another game in different mobile markets:

Google Play:
Publisher: market://search?q=pub:<publisher_name>
Game: market://details?id=<package_name>
More info: http://developer.android.com/distribute/googleplay/promote/linking.html

App Store (iOS):
Publisher: http://appstore.com/<publisher_name>
Game: http://appstore.com/<game_name>
itms:// and itms-apps:// didn’t work for me.
More info:
http://developer.apple.com/library/ios/#qa/qa1633/_index.html
http://stackoverflow.com/questions/433907/how-to-link-to-apps-on-the-app-store
http://itunes.apple.com/linkmaker/

Kindle Apps market:
Publisher: amzn://apps/android?s=<publisher_name>&showAll=1
Game: amzn://apps/android?s=<game_name>
More info: https://developer.amazon.com/sdk/in-app-purchasing/sample-code/deeplink.html

Samsung Apps market:
Publisher: samsungapps://SellerDetail/<selleer_id>
Game: samsungapps://ProductDetail/<package_name>

Blackberry App World:
Publisher: appworld://vendor/<vendor_id>
Game: appworld://content/<game_id>

SlideME App market:
Publisher: sam://search?q=pub:<publisher_name>
Game: sam://details?id=<package_name>
More info: http://slideme.org/blog/linking-your-apps-slideme

NOOK Apps market:
No market links, so just use regular web links or NOOK API.
Publisher: http://www.barnesandnoble.com/c/<publisher_name>
Game: http://www.barnesandnoble.com/w/<game_name>/<game_id>

Window Phone 8 store:
Game: http://windowsphone.com/s?appId=<game_id>
More info: https://msdn.microsoft.com/en-us/library/windows/apps/ff967553(v=vs.105).aspx


Adobe AIR In-app Purchase native extensions

I have spent some time searching for free extensions for all the possible platforms and would like to share my results.
Also, I made my own in-app purchase extension for Android, as I couldn’t find a good and free one.

1. In-app Purchase for Blackberry Playbook.
There is an extension that comes with BlackBerry SDK for Adobe AIR.
API docs: http://developer.blackberry.com/air/apis/playbook/net/rim/blackberry/payment/PaymentSystem.html

2. In-app Purchase for iOS.
In-app purchase extension comes with Adobe Gaming SDK

3. In-app Purchase for Amazon Kindle.
It comes with Amazon SDK: https://developer.amazon.com/sdk/in-app-purchasing/documentation/adobe.html

4. In-app Purchase for Android.
I have found two extensions:
First is free extension from Freshplanet, but it is outdated.
Second is from Milkman for $50.
So, I have decide to make my own. 🙂
You can find it here: Adobe AIR In-app Purchase native extension for Android

Hope, it will help someone in its mobile app development.
Continue reading “Adobe AIR In-app Purchase native extensions”


Adobe AIR for Blackberry Playbook

So, I have finally started to port Solitaire and Mahjong games to Blackberry Playbook and have some notes.
I would like to mention them here, mainly for myself, just as a reminder.

0. Latest Adobe AIR SDK supported by Playbook to date is 3.1.

1. blackberry-airpackager sometimes doesn’t pack all the files to .bar file, if they are not in the same directory as blackberry-airpackager. In my case, it didn’t pack .swf file. App will crash on start in that case.

2. In order to get your Author ID, you need to rename debug token .bar file to .zip, find it in manifest.mf file or execute the following command:

blackberry-airpackager -listManifest [your_debug_file.bar]

3. Description of bar-descriptor.xml file can be found here.

4. According to the link above, permission for the app can be set with <action> tag, while sample HelloWorld project from BB AIR SDK use <permission> tag. Which one is correct – have no idea.

5. Mochi doesn’t work with Adobe AIR Mobile, and I’m not talking about ads, nothing works and it’s been for a long time.

6. Some good guide to AIR apps for playbook.

7. Blacberry SDK for Adobe AIR API Reference.

8. App version for Playbook should be X.Y.Z, not just X.Y as it’s by default in AIR settings.

9. It is always good to verify your .bar file before submitting it to Blackberry with the following command:

blackberry-signer -verify [your_bar_file.bar]

10. Testing Playbook App, especially payments.

11. QNXStageWebView for showing ads inside your app. I’m going to try Leadbolt and Millennial Media for now.

12. Payment System for AIR on Playbook, quit easy to implement.

13. Regular payments (in games or in App World) might stop working after running you own application in development mode. So, you need to restart Playbook to get it working again.

14. Using native extensions for Adobe AIR.

15. If you need to get info (like expiration date) from your certificate file, you can do the following:

blackberry-keytool -exportcert -storepass [your password] -keystore [your_certificate_file.p12] -file output.crt
blackberry-keytool -printcert -file output.crt


Бесплатный Playbook от Blackberry и Marmalade

Пока работал над овечкой, выкроил время зарегистрироваться на спешл от Marmalade и Blakcberry: Marmalade for BlackBerry.
Этот офер уже закончился, было много желающих: “Thanks to everyone who has signed up to this fabulous offer so far. Due to unprecedented demand, we are closing the Marmalade for BlackBerry® offer”.
Но я таки успел получить свои бесплатный PlayBook и сделать маленькую игру на Marmalade: Balloon Shooter.
Пожалуй пора начинать разработку игр для мобильных платформ и этих ваших таблеток.


AS3 events

While working with Bloom Lite framework, I have discovered Native Signals – “a new approach for AS3 events, inspired by C# events and signals/slots in Qt.” I have read before, that Events in Flash was slow, but I have also read, that the fastest way to do events is just call required listener (function) directly.
And I’ve decided to make my own fast and ugly approach for AS3 events.
It has only one class and, I believe, works super fast.
It is available for download from GitHub: https://github.com/pozirk/misc, and it’s very easy to use, here is an example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
public class MyClass extends Eventer
{
  public static const MYEVENT:uint = 1;
  ...
  public function myFunc():void
  {
    if(...) //something happened
      fireEvent(MYEVENT, anyObjectHere);
  }
}
 
...
 
var my:MyClass = new MyClass();
my.addEvent(MyClass.MYEVENT, funcToCall);
 
...
 
public function funcToCall(obj:Object):void
{
  ...
}

So, any class can extends Eventer class, or just has it as a variable, and each class defines its own events (static IDs), which can be fired.

My approach doesn’t have anything like bubbling or capture phases, also there is only one listener possible for every event, but I was aiming for speed and I have thrown away everything and made it as fast as possible.
Hope, it will be useful for someone else, although there is nothing special here.


Alternative GUI for Flash

As I have decide to develop Cats’n’Rats game using FlashDevelop, I was required to find some kind of GUI framework for my buttons, listboxes, etc.
First, I have found Bloom & Bloom Lite – a lightweight and easy to use framework, but it was too basic for me and unintuitive.
Later, I have found AsWing, a great framework similar to Java Swing. But it was buggy, at least for me. 🙂 I could not make it work with absolute positions of controls.
Finally, I have found SPAS – Swing Package for ActionScript.
Another Swing-like framework, but, luckily, it works fine with absolute position by simply using AbsoluteLyout class. It has such features like GridControl and DropButton (still under development, but work great). The default design and colors don’t look very nice, but it’s ok for now.


Free traffic for your website

Are you a flash game developer?
Do you want to get free traffic to your website?
OK, I’ll teach you. Nothing illegal! 🙂

It’s all about site-lock version of the game.
Usually, code for locking the game looks like that:

1
2
3
4
5
6
7
8
9
10
if(...) //domain name is correct
{
  //let's play the game
  ...
}
else
{
  //show some angry message, or don't show anything at all
  ...
}

I do it the same way with one small change:

1
2
3
4
5
6
...
else
{
  //redirect to the page with the game at your website
  try {flash.net.navigateToURL(new URLRequest("http:// www.yourdoamin .com/your-flash-game/"), "_self");} catch(e:Error) {}
}

Now, if someone host the game somewhere, where it is not supposed to be hosted, it redirects player to your website.
And everyone is happy: player can play the game, you get +1 visitor.

All my games are available for download and host on other websites, but they come with ads or sponsor’s brandings. Same games can be played at my own website and they don’t have ads. Of course, ads-free version of the game is site-locked.

But there are some smart guys, like one from “jeux .com”, who grabbed ads-free version of the game, put it to his website and didn’t even check it.
Now, I have +1500 extra visitors per day, mainly from France.
Merci, mon cher ami! C’est très gentil. 🙂


WCK. Conveyor belt problem.

For Dolly The Sheep game I’m using WCK + Box2D Alchemy Port.
It’s a very handy framework, but unfortunately, it lacks documentation and has some bugs.
One of the bugs, I have recently discovered was with the build-in Conveyor belt.
Here is an example.
There are 3 boxes, they should move to the same direction, while they are lying on the conveyor, but… their behavior is unpredictable.

I’ve decided to make my own simple Conveyor Belt, by listening Contact Events.
Here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
...
public override function create():void
{
	friction = 0; //this is very important, otherwise objects on conveyor will be moving with different speed
	reportBeginContact = true;
	reportEndContact = true;
 
	super.create();
 
	listenWhileVisible(this, ContactEvent.BEGIN_CONTACT, onBeginContact);
	listenWhileVisible(this, ContactEvent.END_CONTACT, onEndContact);
}
 
public override function update(param:Param):void //your own update function, calls every frame
{
	//set velocity to objects lying on the conveyor belt, I'm only using horizontal velocity here
	//_dir - direction, where object on conveyor should move to
	//_shape._normal - only the "y" of the normal, when object has contacted conveyor, in my case it can be only 1(from above) or -1(from below)
	for each(_shape in _shapes) //go through all the objects, contacting conveyor
	{
		_shape2 = _shape._shape;
		_shape2.b2body.SetLinearVelocity(new V2(_dir*_shape._normal*_speed, 0));
	}
}
 
protected function onBeginContact(event:ContactEvent):void
{
	//add object and its contact normal to the list
	//event.other.m_userData - our object
	//event.normal - our normal of the contact, that points from conveyor belt to object
	//if event.normal.y &gt; 0, object has contacted conveyor from below
	//if event.normal.y  0 ? -1 : 1)));
}
 
protected function onEndContact(event:ContactEvent):void
{
	//remove object, that is not contacting with conveyor from the list
	...
}

Of course, my version has some problems too, mainly because of the zero friction.
Hope, new version of Box2D Alchemy Port with fixed bugs will be released soon.



Space Age. Report 2

Report #2, and I have something to show.
While working on project I have discovered some problems.
1. Away3DLite is “too lite”. 🙂 It doesn’t not support a lot of features, that Away3D supports, like Sprites. Although Away3DLite version from SVN (http://away3d.googlecode.com/svn/trunk) has Sprite3D, but it doesn’t work correctly with FastRenderer so far.
2. Away3DLite has horrible mouse behavior performance. FPS drops significantly on MouseEvent3D.MOUSE_DOWN event, so I’ve just turned it off for now. I still need to explore this problem.
3. Flash can’t draw dashed lines and circles. Fortunately there is a graphics.curveTo function.
Her is my code:

1
2
3
4
5
6
7
graphics.lineStyle(2, 0x00FFFF);
graphics.moveTo(_midX+_radius, _midY);
for(_i = 6; _i &lt;= 360; _i+=12)
{
  graphics.curveTo(_midX+(_radius)*Tools.cos(_i-3), _midY+(_radius)*Tools.sin(_i-3), _midX+(_radius)*Tools.cos(_i), _midY+(_radius)*Tools.sin(_i));
  graphics.moveTo(_midX+(_radius)*Tools.cos(_i+6), _midY+(_radius)*Tools.sin(_i+6));
}

It draws circle with dashes every 6 degrees.
_midX and _midY are the coordinates of the center of circle.
Tools.cos and Tools.sin are my own functions for cos and sin, they return values from a prefilled arrays.
4. Game is 800×600, but as I know that some sponsors don’t accept that.

Next week I’m planning to do a lot of coding and planning and game menus and logic.

Ok. Here is what I have for today:


AS3 String VS Number

I was accidentally storing numbers as a strings in my objects.
Something like that:

data = {x: "200", y: "100"};

instead of that:

data = {x: 200, y: 100};

So, the problem starts when you try to sum or deduct these “numbers”.
For example,

trace(data.x+90);
Output: 20090
trace(data.x-90);
Output: 110

Sell Flash Games

A small list of websites, where you can sell flash games as well as other flash applications.

1. Buy Stock Flash
You earn:50% – 75%

2. Flash Juggler
You earn: up to 50%

4. Flash Do
You earn:
Selling Exclusively: 50 – 70%
Selling Non-Exclusively: 50%

5. Stock Fuel
You earn:
Selling Exclusively: 55 – 70%
Selling Non-Exclusively: 50%

6. Flash Components
You earn:
Selling Exclusively: 40 – 60%
Selling Non-Exclusively: 30%

7. Active Den
You earn:
Selling Exclusively: 40 – 70%
Selling Non-Exclusively: 25%

8. BuySellArcade
They don’t charge fees, but you have to pay with their credits in order to create new auction.
New customers get free 10 credits upon registration.

9. FlashGameLicense
Auction. You pay 10% commission fee after successfully selling your game.

So, 9 websites so far.
You can also buy flash games and other flash widgets or components at these website!
But, wait! All the best games are selling here!