Tuesday, August 3, 2010

kit-kat-toe: mochiads with haxe

I recently tried out Viktor Hesselbom Haxe Instructions for MochiAds and they work just fine.

Something like this...

% wget https://www.mochimedia.com/dl/MochiAPI_v3_8.zip
% unzip MochiAPI_v3_8.zip
% cd MochiAPI_v3_8
% mkdir -p foo/mochi
% cp -r mochi/as3 foo/mochi
% cd foo
% compc -source-path . -output mochi.swc -include-sources .
% unzip mochi.swc library.swf
% haxe --gen-hx-classes library.swf

Then just get the game id from the nice folks over at mochi and jam in the little bit of ad code.

One problem I had was that I found I needed to add a new MovieClip to the flash.Lib.current, use that for the ad and remove it in the ad_finished callback.

I had some mixed luck with swfmill... The old version I had (0.2.12) didn't complain about the mp3 I having the wrong bitrate... But when I linked against the -swf-lib from the new version it produced a blank swf!

So... I have no sound...

LOL... it is a very silly proof of concept... check it out

I call it kit-tac-toe

gory swfmill detail

To compile swfmill under Hardy Heron (I know... it's old)... I had to modify swfmill.c and add: extern char *xslt_simple;

And it still didn't work... I may try to use a newer box to see if my horked environment is why it didn't work right....

Here is the handy message I got from it...

Sampling rate: 32000
Error: Flash only supports sampling rates of 44100, 22050 and 11025 Hz
WARNING: MP3 file sounds/cats/meow.mp3 has a wrong sampling rate

Saturday, January 30, 2010

28-days as the Witch in Magic Realm

The witch is all about spells, here was my setup:
  • Absorb Esssence: grab a big monster to rack up fame/notoriety killing monsters and natives
  • Control Octopus/Spider: always nice to have company!
  • Broomstick: get me out of here!
Amazingly, the Pool and the Lost City were in the tile right next to the Dark Valley where I started!

Grabbed a Giant and the Pool Monster conveniently showed up! Time to kick some @$$!

The very next turn, the Pool Monster found the pool and pulled out: the Cloven hoof, the Black Book and Bejeweled Crown (50g, yo!)... Unfortunately this trapped the Witch as a Giant and on the second go 'round (ahem). the Pool Monster went down.

Next day I looted the "Sacred Idol" and decided to make a run for it.

The nearest dwelling was the Chapel which I barely arrived at in time abandoning the Cloven hoof so I could carry the Crown in Giant-mode so as to sell it the next day (day 27!)

My bro had told me short games force you to focus and I'd have to agree, but ... day 28, there was the Witch sitting there with the Black Book, one tile away from the Cloven Hoof... and... the game is over!


Wednesday, September 2, 2009

fractal pinwheels

These are some little pinwheels made by a little fractal line drawing + you typical draw lines around a circle code:

You can see it in action here. Click anywhere to draw a random pinwheel... and hit space key to clear them

Here is the function to draw the lines:

public function funky_line( g:Graphics, x1:Float, y1:Float, x2:Float, y2:Float, depth:Int, max:Int ) {
if ( depth > max ) {
g.moveTo( x1, y1 );
g.lineTo( x2, y2 );
} else {
var nx = -1 * ( y2 - y1 ) * ( depth / ( depth * depth ) );
var ny = 1 * ( x2 - x1 ) * ( depth / ( depth * depth ) );
var xm = x1 + ( x2 - x1 ) / 2 + nx;
var ym = y1 + ( y2 - y1 ) / 2 + ny;
funky_line( g, x1, y1, xm, ym, depth, max );
funky_line( g, xm, ym, x2, y2, depth, max );

Max is the number of recursions and count is the number of lines to draw around the circle...


Monday, August 17, 2009

xquery script

The other day, I really wanted to be able to run an xquery expression over some xml and use it as some scripting input... I was really surprised to see there really doesn't appear to be a nice way to do this!

After all... xquery is the xml equivalent of grep. Imagine! Landing in an OS with no grep equivalent!

Oh, wait... I just described windoze...

I wrote a small piece of XLS wrapped in a script( xsnap.sh) the script got a slightly more complicated once I found out that if an input document has a namespace defined, you have to use it in your expression.

Now this is handled like magic, but can be turned off by uncommenting the line "XSNAP_SMARTY" then you can specify "xsnap:expression" to match the default ns of the document.

Here is the dealio: xsnap.sh "groupId/text()" pom.xml

And viola! A "grep-like" tool for xml!

This mechanism is more robust that just grepping xml since it uses the xquery standard junk.

Saturday, June 6, 2009

Voronoi diagrams as seamless tiles

Check out my groovy new seamless tiles.

I now have an easy way to use Voronoi diagrams to generate seamless tiles! Fun!

Feel free to get any sort of use out of them you can.