Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    292
  • comments
    557
  • views
    154113

And, as usual, I blame John Hattan

Sign in to follow this  
TANSTAAFL

98 views

For reference



So, yeah. There's a C# compiler that'll make SWFs. Rather than talking about how it has great potential and may indeed be the holy grail, I figured I'd just show you how easy it is to make something.

I made a simplistic app that allows you to move a hexagon (which blinks red and blue) with the keyboard. As with other SWF files, you need to click on the application window before you will get keystrokes. I imagine I will later find something somewhere in the libs to automate the process(or somebody'll just tell me), but I focus on results here, and the docs ATM aren't much good.

So, it works. I first tried the VS.NET 2003 plugin, and it borked. The stand-alone Windows XP tool works fine, however.

This is my first foray into C# (not a single line of it written before today). Seems an okay language- tastes like java.


My favorite part of this tool: I no longer have to pretend that my program is a movie. (which requires a number of interesting work arounds when making flash games)



The Source Code

The test application

The Code:
using System;
using System.Drawing;
using System.Windows.Forms;

public class Form1 : System.Windows.Forms.Form
{
Movie m_Movie= null;
public Form1()
{
}
protected override void OnCreateControl()
{
m_Movie=new Movie(this.Visual,"hex");
m_Movie.X = 320;
m_Movie.Y = 240;
Focus();
}
protected override void OnKeyDown(KeyEventArgs e)
{
if(e.KeyCode==Keys.Up&&m_Movie.Y>0)
m_Movie.Y-=1;
if(e.KeyCode==Keys.Down&&m_Movie.Y<480)
m_Movie.Y+=1;
if(e.KeyCode==Keys.Left&&m_Movie.X>0)
m_Movie.X-=1;
if(e.KeyCode==Keys.Right&&m_Movie.X<480)
m_Movie.X+=1;
}
static void Main()
{
Application.Run( new Form1() );
}
}


Sign in to follow this  


4 Comments


Recommended Comments

My only worry at this point is that the generated SWF files are a bit fat because of some form base classes that are linked in. For example, your SWF is 24k, but I could do the same thing in plain old Flash in less than 1k.

According to the Flashcoders, this is a one-time hit. Given that this new compiler obfuscates function names, inlines, and deletes dead code, there's probably a breakeven point somewhere when your app gets more sophisticated.

It also explains why, if you double-click the bubbles SWF and resize it, you get scroll bars rather than the usual Flashesque behavior of resizing the movie to fit the window. That's where the overhead's going.

Just to test for compatibility, I made a Zinc-ified version at http://www.thecodezone.com/delme/Test.exe.

Share this comment


Link to comment
You guys have got me impressed for sure... do you even need flash installed to run this compiler?

Share this comment


Link to comment
well, part of the trick is that most of my art assets are still going to wind up being flash movies, and Flash MX 2004 is still the best tool for that job. In my little sample above, hex.swf is one such art asset.

Share this comment


Link to comment
You need the Flash player (which comes with Windows), but not the Flash development environment.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!