Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411512 Posts in 69376 Topics- by 58430 Members - Latest Member: Jesse Webb

April 26, 2024, 04:50:59 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperPlaytestingThe MarioToo Flash/Wiimote API
Pages: [1]
Print
Author Topic: The MarioToo Flash/Wiimote API  (Read 7055 times)
AdamAtomic
*BARF*
Level 9
*


hostess w/ the mostest


View Profile WWW
« on: April 01, 2007, 02:41:35 PM »

Hey guys!  I wanted to show you my new project, and maybe have some people beta test it for free?  This stuff is always browser-sensitive, so I want to make sure I have this junk workin right.  Also, I am not really a flash or javascript guru, I just do what I can to get stuff to work!  Ok, here we go!

MarioToo is a WiiMote API, like the one that seems so popular over at Wiicade, only I'm not squirreling away all my javascript, and I think I've got a much more redundant implementation anyways.  My API, like Wiicade's, is based heavily off of Mario Klingemann's demo from I think December.  Unlike Wiicade, he also made the javascript available for download, and I spent most of last night reengineering it to get the kinks out and make it easier for people to work with.  The result is 'MarioToo', what I hope will become the standard for great Wii Flash games to come!  The best part is its very easy to use, and you can deploy it on ANY website, not just wiicade's ad-fest!

MarioToo is very, very easy to use if you know any flash at all.  It includes a full-featured javascript library that handles all of the HTML and reflector hacks for you; all you have to do is plug it into your flash game, and include my javascript library and flash reflector on your website.  Here is the example site I am currently hosting:

http://www.lastchancemedia.com/mariotoo/

This is a flash file running at 720x480, and all it does is echo button presses, very simple.  It also demonstrates the smart 'classic' mode and the PC-friendly keyboard bindings a la Wiicade's closed library.  Heavy redundancy and a better javascript setup mean I can handle upwards of 7 or 8 simultaneous button presses with no missed events to screw up your game state.  Here is the HTML for that webpage:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 strict//EN">
<html>
    <head>
        <title>MarioToo: A WiiMote Flash API</title>
        <script type="text/javascript" src="wiimote.js"></script>
    </head>
    <body>
        <script type="text/javascript">
            CreateHTML('MarioToo_Demo.swf',720,480,'#FFFFFF','#CCCCCC');
        </script>
    </body>
</html>

Very very simple as you can see.  The CreateHTML call does all the heavy lifting for you, setting up and hiding the reflector, bla bla bla.  It takes params for the flash file URL, width, height, page color, and flash background color.  Moving on, here is all the code from the demo actionscript:

Code:
// MarioToo Wii Flash API Demo
//
// Version 1.0
// Author: Adam Saltsman <[email protected]>
//
// A simple app to show how the MarioToo WiiMote API functions.

import mx.core.UIObject;
import com.lastchance.mariotoo.WiiMote;

class com.lastchance.mariotoo.MarioToo_Demo extends UIObject
{
var status:TextField;
var txtfmt:TextFormat;
function MarioToo_Demo()
{
WiiMote.init(); //initialize the wiimote
WiiMote.setClassic(true); //rotate the d-pad on the wii
WiiMote.bindDefaults(); //arrow keys, z, x, shift + ctrl
WiiMote.bind(WiiMote.BUTTON_A,65); //the 'a' key on the keyboard

txtfmt = new TextFormat();
txtfmt.size = 72;
txtfmt.color = 0xffffff;
txtfmt.align = "center";

createTextField("status", getNextHighestDepth(), 0, 200, 720, 100);
status.multiline = false;
status.selectable = false;
status.text = "";
}
function draw()
{
        if(!this.onEnterFrame)
            this.onEnterFrame = this.updateImage;
    }
function updateImage()
{
status.text = "";
if(WiiMote.isDown(WiiMote.BUTTON_A))
status.text = "A";
if(WiiMote.isDown(WiiMote.BUTTON_B))
status.text += " B";
if(WiiMote.isDown(WiiMote.BUTTON_1))
status.text += " 1";
if(WiiMote.isDown(WiiMote.BUTTON_2))
status.text += " 2";
if(WiiMote.isDown(WiiMote.BUTTON_PLUS))
status.text += " +";
if(WiiMote.isDown(WiiMote.BUTTON_MINUS))
status.text += " -";
if(WiiMote.isDown(WiiMote.BUTTON_UP))
status.text += " ^";
if(WiiMote.isDown(WiiMote.BUTTON_DOWN))
status.text += " v";
if(WiiMote.isDown(WiiMote.BUTTON_LEFT))
status.text += " <";
if(WiiMote.isDown(WiiMote.BUTTON_RIGHT))
status.text += " >";
if(status.text != "")
status.setTextFormat(txtfmt);
}
}

Again, very very straightforward stuff.  Nice and state-based, and the keyboard bindings mask themselves as regular wiimote buttons.  The 'classic' mode, which tilts the d-pad for NES-style play, is automatically avoided if you are using a keyboard, so no multi-config setups for different browsers, etc etc.

Finally, here is the download for the beta version 1.0:

http://www.lastchancemedia.com/mariotoo/MarioToo_b10.rar

It includes all the actionscript, javascript, compiled .swfs, and all that junk.  To get it to run on YOUR site, all you have to do is make sure you include the WiiBounce.swf and wiimote.js files in the same directory as your HTML.  Then, call CreateHTML to have wiimote.js write out your flash containers for you!  If you want to use the wiimote API in your flash file, just make sure you import wiimote.as.  A final note, all flash files were compiled using free, open source software: mtasc and swfmill.  Special thanks to those guys for making projects like this possible!

I think that's about it!  I'm always open to hearing about new features people would like, but I don't want this thing to get too bloated.  If you find bugs please let me know ASAP and I will fix them if the wii browser lets me Smiley

Thanks!

EDIT - thanks for the move i wasn't quite sure what the right place for it was here!

DOUBLE EDIT - updated the links with the new page, thanks!
« Last Edit: April 02, 2007, 11:05:53 AM by AdamAtomic » Logged

cup full of magic charisma
AdamAtomic
*BARF*
Level 9
*


hostess w/ the mostest


View Profile WWW
« Reply #1 on: April 02, 2007, 11:05:28 AM »

Updated the javascript to support simple PC-side detection/warnings.  Just add a div called 'jswarning' to your HTML and the CreateHTML call in wiimote.js will automatically hide that div for you Smiley

http://www.lastchancemedia.com/mariotoo/MarioToo_b11.rar
Logged

cup full of magic charisma
AdamAtomic
*BARF*
Level 9
*


hostess w/ the mostest


View Profile WWW
« Reply #2 on: August 03, 2007, 02:43:49 PM »

With Robert Hine's help, we've got a new version of the API released finally:

http://www.lastchancemedia.com/mariotoo/

Lots of bug fixes, support for up to 4 wiimotes (hello flash party games!), and more...
Logged

cup full of magic charisma
Guert
Level 10
*****



View Profile WWW
« Reply #3 on: August 07, 2007, 05:50:47 PM »

Do we absolutly need a wii controller for it to do something? I tried to toy with it with the keyboard but nothing happenned...

Anyway, if I understand well, you're going to use this to create web-based wii games? Sounds quite interesting! Tell us more! Wink
Later!
Logged

AdamAtomic
*BARF*
Level 9
*


hostess w/ the mostest


View Profile WWW
« Reply #4 on: August 07, 2007, 07:32:41 PM »

That's the idea Smiley  it should do SOMEthing when you use the keyboard though - the default binding for the keyboard side of things is similar to most indie games - arrow keys, z, x, shift, and ctrl should all register as analogs to various wiimote buttons!
Logged

cup full of magic charisma
Guert
Level 10
*****



View Profile WWW
« Reply #5 on: August 08, 2007, 05:06:36 AM »

Well, I saw the label change, I thought at first you had a little game created for it...

Looks very interesting... As time goes, more and more factors are telling me to buy a Wii... Wink
Later!
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic