October 8, 2009
October 7, 2009
October 1, 2009
jsc is awesome
Now that I got your attention:
There is a new release for jsc with two new screencasts. This time around you are able to omit [Script] attribute and ditch the tools/build.bat. The jsc solution now includes the jsc.meta compiler which will talk to the other compilers for you.
I am also experimenting with pre compilers. For example the Forms example makes use of TextualUserControl and TextComponent. Without getting too technical they generate a new assembly and add the reference to your csproj file. This opens up some really interesting possibilities. I will talk more about this in future posts.
Future pre compilers in jsc solution could include automatic stub generators for java jar files and for flash swf and swc files.
Open java version:
September 30, 2009
August 27, 2009
August 17, 2009
ScriptCoreLib.Net
The jsc compiler project is being supported by a number of ScriptCoreLib assemblies. Recently I have been playing with the idea of automatic network code generator. Think C# to IL and later IL to ActionScript. This would enable fast multiplayer game prototyping and programming.
If you are a game development shop and you find this interesting I would be more than happy to work out a business arrangement with you to secure funding to make it a solid offer.
This post is more about announcing a future feature which I plan to implement. In the recent year I have tried to write several multiplayer games, but each project has had too much details on how to set up the network and synchronization code. I want to make that easier and more intuitive while supporting multiple network provides.
The idea would be to develop and debug your network aware application on .net including client side and server side.
Update: Read about services here: http://geekspeak.creatrixgames.com/free-managed-flash-multiplayer-apis.html
July 17, 2009
Doom Platformer
Jens Winterstein finally made a Doom platformer! Cool!
In another studio the isometric doom is coming along nice and steady.
[...] The If Software website may not be around much longer due to lack of funds. The forums will stay however, and updates will be focused to the ModDB page rather than the website. It sucks, but what can you do. – intmain
June 29, 2009
Avalon Tycoon Mansion
Yet another WPF powered flash game is ready for you to play. The game is written in C#. Let me know if you’d also want to see the source.
June 21, 2009
Flash Indie Developer
Manfred Weber hat ein Talk gegeben, wo er ganz kurz alles, was mit dem Flash Gamez zu tu tun hat, zusammen genommen hat.
Nachdem Ihren Spiel fertig ist, passen sie auf für die rightige Reihenfolge:
- Mochiads
- Kongregate / Armorgames / Flash Gamez
- Premium Version auf eigener Webseite
- Lizenzen
Die folgende Artikkeln von Florian Wein sind auch ein Muss für lesen. Ich finde sie ech gut und interessant.
Flash Indie Developer Part 1: Skills und Fähigkeiten
Flash Indie Developer Part 2: Anforderungen und Idealismus
Flash Indie Developer Part 3: Gefahren
Flash Indie Developer Part 4: Unser Produktportfolio im Überblick
Flash Indie Developer Part 5: Geld verdienen mit Flash Games
Flash Indie Developer Part 6: Kleines Taschengeld durch Online Werbung
Flash Indie Developer Part 7: Querfinanzierung durch Schulungen
Flash Indie Developer Part 8: Verkaufe deine digitalen Produkte
June 10, 2009
May 29, 2009
Using FLINT particle system from jsc
Moristar asked how to use an external libray from within a c# flash project. The short answer is yes you can, but you’d have to define stubs.
The long anwser…
In .net when you are talking to COM an interop assembly is used. The interop assembly defines types which represent the actual types to be used. That assembly is generated automatically at the time you reference the COM assembly.
It would be nice to be able to simply add a reference to a SWC file and use the features it defines, but currently it is not supported. A tool could be created which would read the SWC file and create the stub library. Currently this needs to be done manually.
Previous example
| FlashGoogleMapsExample | ![]() |
(more…)
May 15, 2009
URLRequestHeader
The other day a developer named Carlo emailed me noted that currently URLRequestHeader is not exposed via ScriptCoreLib. In response to that I exposed those classes and created an example solution to demonstrate it. You would need to redownload jsc to get it ofcourse.
Before going into that I would like to show how one could add a native type that is not yet defined by other assemblies like ScriptCoreLib. In your assembly you would need to define a new type like this:
6 namespace ScriptCoreLib.ActionScript.flash.net
7 {
8 // http://livedocs.adobe.com/flex/3/langref/flash/net/URLRequestHeader.html
9 [Script(IsNative = true)]
10 public class URLRequestHeader
11 {
The compiler will later then assume that this type is provided by the platform itself or imported by some other means and use it as a native type.
The actionscript livedocs had a nice example which I translated to C#.
44 var loader = new URLLoader();
45
46 var header = new URLRequestHeader(“XMyHeader”, “got milk?”);
47
48 t.appendText(“\n” + this.loaderInfo.url);
49 t.appendText(“\nUsing relative path…”);
50
51 var request = new URLRequest(“../WebForm1.aspx”);
52 var data = new DynamicContainer { Subject = new URLVariables(“name=John+Doe”) };
53 data["age"] = 23;
54
55 request.data = data.Subject;
56 request.method = URLRequestMethod.POST;
57 request.requestHeaders.push(header);
58
59 loader.complete +=
60 args =>
61 {
62 t.appendText(“\n” + loader.data);
63 };
64
65 loader.load(request);
In this demo I am sending three elements of data to the server:
- header XMyHeader
- post parameter name
- post parameter age
As we need a server to echo something back for us to see it works I added a new ASP.NET Web Application to the solution. The flash file generated by the jsc compiler will be copied to a folder Generated. The generated files are not included in the svn. This is why the solution will show exclamation marks on the first build.
The WebForm1 implements the echo service like this:
10 public partial class WebForm1 : System.Web.UI.Page
11 {
12 protected void Page_Load(object sender, EventArgs e)
13 {
14 var data = new
15 {
16 XMyHeader = this.Request.Headers["XMyHeader"],
17 name = this.Request.Params["name"],
18 age = this.Request.Params["age"],
19
20 };
21
22 this.Response.Write(“hi! “ + data.ToString());
23 this.Response.End();
24 this.Response.Close();
25 }
26 }
Running it in the browser will give us the following view including the current URL and the text returned by the server.
The source code for this example is available here:
http://jsc.svn.sourceforge.net/viewvc/jsc/examples/actionscript/URLRequestHeaderExample/
As this is a dirty fast example – If anything needs clarification do let me know.
May 1, 2009
Mandelbrot
One single static C# class implementation to rule them all.
The other day I found an example of Mandelbrot implementation for Silverlight. I have created this example solution to serve as a reference implementation.
This single Mandelbrot implementation is reachable for these platforms:
- Windows Forms
- Windows Presentation Foundation
- Silverlight (3.0 beta)
- Java Applet
- Flash
- Javascript (Firefox, Safari)
For those of you who are new, jsc compiler is going to generate source code for you. While you write your algorithm in C# in current case it can be retranslated to java, actionscript, c and javascript to enable other platforms. Do leave a comment if you would like to know more about it.
April 7, 2009
Stratus + Nonoba + ? = Massive Multiplayer
Could stratus be used to connect multiple nonoba game instances? Here is the first diagram showing what I am thinking.
Every user client could be upgraded to admin client. By upgrading the client will act like a router, so it should be online for a while. Maybe we should give some stimulus to the player for that.
April 6, 2009
C# To ActionScript and Alchemy
Some years ago I added some minimal C source code generation support to my jsc compiler. This time I decided to polish it up a little bit and see what would it look like to develop a flash application with alchemy in c#.
This example is a port from this Alchemy plasma experiment. I made it in c#, changed the color and added the jsc logo.
| FlashPlasma |
|
Overview
Writing code in c#? That’s plain crazy. To make it easier to comprehend – here is an overview diagram of what is really happening.
Hand written C# sourcecode
As you can see, there are multiple compilers doing the hard work so you could have that final flash binary file. The C# code that will be converted by jsc compiler looks like this:
14 static int width;
15 static int height;
16
17 static uint[] palette;
18 static uint[] plasma;
19 static uint[] newPlasma;
20
21
22 static AS3_Val generatePlasma(object self, AS3_Val args)
23 {
24 AS3_h.AS3_ArrayValue(args, "IntType, IntType", __arglist(ref width, ref height));
25
26 palette = new uint[256];
27 plasma = new uint[width * height];
28 newPlasma = new uint[width * height];
29
30 for (var x = 0; x < 256; x++)
31 {
32 var b = (int)(128.0 + 128 * Math.Sin(Math.PI * x / 16.0));
33 var g = (int)(128.0 + 128 * Math.Sin(Math.PI * x / 128.0));
34 var r = 0;
35
36 uint color = (uint)(r << 16 | g << 8 | b);
37
38 color |= 0xff000000u;
39
40 palette[x] = color;
41 }
42
43 int index = 0;
44
45 for (var x = 0; x < width; x++)
46 {
47 for (var y = 0; y < height; y++)
48 {
49 uint color = (uint)((
50 128.0 + (128.0 * Math.Sin(x / 16.0)) +
51 128.0 + (128.0 * Math.Sin(y / 8.0)) +
52 128.0 + (128.0 * Math.Sin((x + y) / 16.0)) +
53 128.0 + (128.0 * Math.Sin(math_h.sqrt(x * x + y * y) / 8.0))
54 ) / 4);
55
56
57 color |= 0xff000000u;
58
59 plasma[index++] = color;
60 }
61 }
62
63
64 return AS3_h.AS3_Ptr(plasma);
65 }
66
67 static AS3_Val shiftPlasma(object self, AS3_Val args)
68 {
69 var shift = 0;
70 var index = 0;
71
72 AS3_h.AS3_ArrayValue(args, "IntType", __arglist( ref shift));
73
74 for (var x = 0; x < width; x++)
75 {
76 for (var y = 0; y < height; y++)
77 {
78 var paletteIndex = (int)( (uint)(plasma[index] + shift) % 256);
79 newPlasma[index] = palette[paletteIndex];
80 index++;
81 }
82 }
83
84 return AS3_h.AS3_Ptr(newPlasma);
85 }
Generated C source code for Alchemy
After jsc compiler has converted it to asni c it will look like this:
30
31 int FlashPlasma_Alchemy_Program_width;
32 int FlashPlasma_Alchemy_Program_height;
33 unsigned int* FlashPlasma_Alchemy_Program_palette;
34 unsigned int* FlashPlasma_Alchemy_Program_plasma;
35 unsigned int* FlashPlasma_Alchemy_Program_newPlasma;
36
37 AS3_Val FlashPlasma_Alchemy_Program_generatePlasma(void* self, AS3_Val args)
38 {
39 int x;
40 int b;
41 int g;
42 int r;
43 unsigned int color;
44 int index;
45 int y;
46
47 AS3_ArrayValue((AS3_Val)args, (char*)"IntType, IntType", &FlashPlasma_Alchemy_Program_width, &FlashPlasma_Alchemy_Program_height);
48 FlashPlasma_Alchemy_Program_palette = (unsigned int*) malloc(sizeof(unsigned int) * 256);
49 FlashPlasma_Alchemy_Program_plasma = (unsigned int*) malloc(sizeof(unsigned int) * (FlashPlasma_Alchemy_Program_width * FlashPlasma_Alchemy_Program_height));
50 FlashPlasma_Alchemy_Program_newPlasma = (unsigned int*) malloc(sizeof(unsigned int) * (FlashPlasma_Alchemy_Program_width * FlashPlasma_Alchemy_Program_height));
51
52 for (x = ((int)0); (x < 256); x++)
53 {
54 b = ((int)((signed int)((128 + (128 * FlashPlasma_Alchemy_BCLImplementation_System___Math_Sin((double)((3.14159265358979 * ((double)(x))) / 16)))))));
55 g = ((int)((signed int)((128 + (128 * FlashPlasma_Alchemy_BCLImplementation_System___Math_Sin((double)((3.14159265358979 * ((double)(x))) / 128)))))));
56 r = ((int)0);
57 color = ((unsigned int)(((r << 16) | (g << 8)) | b));
58 color = ((unsigned int)(color | -16777216));
59 FlashPlasma_Alchemy_Program_palette[x] = color;
60 }
61
62 index = ((int)0);
63
64 for (x = ((int)0); (x < FlashPlasma_Alchemy_Program_width); x++)
65 {
66
67 for (y = ((int)0); (y < FlashPlasma_Alchemy_Program_height); y++)
68 {
69 color = ((unsigned int)((unsigned int)(((((((((128 + (128 * FlashPlasma_Alchemy_BCLImplementation_System___Math_Sin((double)(((double)(x)) / 16)))) + 128) + (128 * FlashPlasma_Alchemy_BCLImplementation_System___Math_Sin((double)(((double)(y)) / 8)))) + 128) + (128 * FlashPlasma_Alchemy_BCLImplementation_System___Math_Sin((double)(((double)((x + y))) / 16)))) + 128) + (128 * FlashPlasma_Alchemy_BCLImplementation_System___Math_Sin((double)(sqrt((double)((double)(((x * x) + (y * y))))) / 8)))) / 4))));
70 color = ((unsigned int)(color | -16777216));
71 FlashPlasma_Alchemy_Program_plasma[index++] = color;
72 }
73
74 }
75
76 return (AS3_Val)AS3_Ptr((void*)FlashPlasma_Alchemy_Program_plasma);
77 }
78
79 AS3_Val FlashPlasma_Alchemy_Program_shiftPlasma(void* self, AS3_Val args)
80 {
81 int shift;
82 int index;
83 int x;
84 int y;
85 int paletteIndex;
86
87 shift = ((int)0);
88 index = ((int)0);
89 AS3_ArrayValue((AS3_Val)args, (char*)"IntType", &shift);
90
91 for (x = ((int)0); (x < FlashPlasma_Alchemy_Program_width); x++)
92 {
93
94 for (y = ((int)0); (y < FlashPlasma_Alchemy_Program_height); y++)
95 {
96 paletteIndex = ((int)(((unsigned int)((((unsigned long)(FlashPlasma_Alchemy_Program_plasma[index])) + ((signed long)(shift))))) % 256));
97 FlashPlasma_Alchemy_Program_newPlasma[index] = FlashPlasma_Alchemy_Program_palette[paletteIndex];
98 index++;
99 }
100
101 }
102
103 return (AS3_Val)AS3_Ptr((void*)FlashPlasma_Alchemy_Program_newPlasma);
104 }
Generated ActionScript by Alchemy
Now that was the basic ansi C source code. Alchemy will convert it to special actionscript which will look like good old assambler:
9002 i0 = ((__xasm<int>(push((mstate.ebp+8)), op(0x37))))
9003 i1 = ((__xasm<int>(push((mstate.ebp+12)), op(0x37))))
9004 i2 = ((__xasm<int>(push((i0+16)), op(0x37))))
9005 i3 = ((__xasm<int>(push((i1+16)), op(0x37))))
Summary
At this time it is quite hard to set up such an environment due to cygwin quirks, but it does enable some interesting scenarios. If you would like to know more about writing for flash alchemy in C# just let me know.



































