Monkey Flixel

Monkey Forums/Monkey Programming/Monkey Flixel

devolonter(Posted 2012) [#1]
In November 2011 I started to port Flixel to Monkey. I think that many game developers are familiar with this library. If you don't, follow the link flixel.org

I told nothing before, because I wasn't sure if I can handle it. Now I have some demos available, and I'm glad to provide it to the public.

At the moment following classes are fully ported: FlxPoint, FlxRect, FlxPath, FlxBasic, FlxGroup, FlxState, FlxCamera, FlxObject, FlxText, FlxTimer

Monkey Flixel will be distributed free for personal and commercial use. First public pre-alpha version will be ready by late January or early February. Up to this point I will periodically report about progress of development.

Now, I invite you to take a look at some simple demos:

1. FlxCamera: Monkey Flixel | Original Flixel

2. FlxText (following drivers are supported: Native, AngelFont, FontMachine): Monkey Flixel | Original Flixel

3. Camera FX Demo

4. Follow Path Demo

5. Camera Follow Demo

Also, current version of the port was used to implement game Stand Alone to participate in the Ludum Dare 22 contest

Update. Example of use:

AS3 code (original flixel):


Monkey code (Monkey Flixel):



frank(Posted 2012) [#2]
Cool! Great work. Any source code to check already?


Raz(Posted 2012) [#3]
Hey congratulations :) Always good to see new targets.


ziggy(Posted 2012) [#4]
Looks amazing! Glad to see FontMachine supported thed too :D


FelipeA(Posted 2012) [#5]
Nice! I was really hoping to see a flixel port to monkey, I actually recommended it on the flixel forum a while ago. They were to focused on making a port for each lenguage, but with this there is no need for that anymore.

I just hope we can see this soon.


slenkar(Posted 2012) [#6]
does it work on all platforms?


devolonter(Posted 2012) [#7]
Cool! Great work. Any source code to check already?

Right I don't want to open source code because I often submit changes that aren't compatible with previous versions. However, I can show you an example of use (see update to the post)

Looks amazing! Glad to see FontMachine supported thed too :D

Thanks for Jungle Ide! I wouldn't have done anything without it.

does it work on all platforms?

Yes it works on all platforms


Beaker(Posted 2012) [#8]
Looks really good!


TheRedFox(Posted 2012) [#9]
Wow, impressive.


Arthur(Posted 2012) [#10]
Great work!


pinete(Posted 2012) [#11]
correct me if I'm wrong but... shouldn't be this post into MONKEY CODE forum?? there's a lot of *BRILLIANT* libraries and snippets absolutely lost into the forums... I miss the code archives of Blitzbasic.com.. Looking for something around here is a complete mess :(

And regarding Flixel, impressive, no doubt, great work! that's the reason why I think it should be on Monkey Code, to get the most of it and allow people to find it easily.
;)

Thanks,


xzess(Posted 2012) [#12]
great stuff!

looking forward!

Thanks


Hima(Posted 2012) [#13]
This is awesome! Is it just me or the monkey version is a little bit faster/smoother? :D

Now that we have MonkeyFlixel here...Maybe I should port FlashPunk and call it MonkeyPunk!


devolonter(Posted 2012) [#14]
OK. Latest News - I've completed the class FlxSprite. Unfortunately, part of the functional of the class was lost because mojo is not able to work with source images.

The following methods are not available for FlxSprite on Monkey: stamp, drawLine, fill, replaceColor, pixelsOverlapPoint

loadRotatedGraphic will be supported, but images need to be prepared manually (perhaps I'll write a simple command-line utility). drawLine, fill, can be emulated, but I do not know if that make any sense? Looking forward for your suggestions about these two functions.

Also I've prepared a small demo (still in work) - http://lab.devolonter.ru/libs/monkey-flixel/flxinvaders/html5.html This video shows how it works on Android (sorry for low quality) - http://www.youtube.com/watch?v=yfkfS1s6gNg

This is awesome! Is it just me or the monkey version is a little bit faster / smoother? : D

So far it was impossible to test, but I expect the performance will be approximately equal. Perhaps a little smoother


slenkar(Posted 2012) [#15]
lookin good so far,
Im not so worried about the commands that arent available, im more interested in the other stuff


devolonter(Posted 2012) [#16]
Good news! Porting is almost completed and alpha-version will be available for download very soon. Estimated release date - February 12, 2012

Now, there are several issues that I would like to resolve before publishing the code:

1. Very unstable OnUpdate () call time . In some targets the delta time between two calls OnUpdate with update rate equal to 60 can range from 16 to 25 ms. And in XNA from 16 to 32 ms. Is there a solution to this problem? I tried to insert the logic update in OnRender method - it works very well, until FPS does not drop below the target FPS, but if FPS is too low, then the whole logic fails ... Therefore, this solution was rejected. I would appreciate any help or advice.

2. Port works correctly only with the latest Monkey versions (v52-53), but these versions are only available to registered users. It would be nice if demo users were able to test library. Mark, is it possible to update demo version up to v53? Thank you!

Now I would like to introduce some new demos:

- Split Screen
- Path Finding
- Replay
- Collisions
- Tilemap
- Particles
- Invaders Game (updated)

P.S. HTML5 and Flash versions are built with Monkey.
P.P.S. Probably this post should be moved to Monkey Projects section?


Paul - Taiphoz(Posted 2012) [#17]
the collision stuff is interesting. will follow this I think, although I am enjoying diddy at the moment.


TheRedFox(Posted 2012) [#18]
Can't wait :^p


Paul - Taiphoz(Posted 2012) [#19]
Are the collisions box, sphere or pixel ?

having pixel perfect collisions would be amazing, as long as its fast of course.


slenkar(Posted 2012) [#20]
good collision demo


muddy_shoes(Posted 2012) [#21]
if FPS is too low, then the whole logic fails


Without knowing what this means it's not possible to offer advice. I'll take a look when you release the code.


devolonter(Posted 2012) [#22]
Are the collisions box, sphere or pixel?

As in original flixel collision box is used, but you can redefine this behavior with callback function

Without knowing what this means it's not possible to offer advice. I'll take a look when you release the code.

For example, at falling FPS to 10 if logic update is placed in OnRender, physics calculation happens too rarely and the interaction with the playing field becomes very bad (objects begin to fly through walls, etc.). I can send you the source code before the release by email. I would be grateful for any help!


wiebow(Posted 2012) [#23]
Is Flixel not using fixed time steps?


muddy_shoes(Posted 2012) [#24]
Yes, as wiebo asked, are you using a fixed time-step?

Using a variable time-step for physics/collisions is always going to cause trouble if those systems only work on the state at the end of the frame. You should be using a fixed time-step or at least limiting the allowed variation within reasonable bounds.


devolonter(Posted 2012) [#25]
@wiebo, @muddy_shoes You're right! I've missed that point, *facepalm*. I'll try to use fixed time step now. Thanks!


devolonter(Posted 2012) [#26]
Fixed time step works very well. This question is closed!


wiebow(Posted 2012) [#27]
Great. I will send an invoice your way :)


devolonter(Posted 2012) [#28]
@wiebo ok :)

I'm sorry, but I have to move the release date for tomorrow. There are still a few bugs that I would like to fix before publish it.


Hima(Posted 2012) [#29]
Take your time. And thank you for your hard work! :)


thoast(Posted 2012) [#30]
Very nice, dont drop the development :)


Snader(Posted 2012) [#31]
Very nice work!


therevills(Posted 2012) [#32]
So I guess Monkey Fixel is an alternative for Mojo... Is that right?


Hima(Posted 2012) [#33]
I think it's more like Diddy, that is, it is a framework based on Mojo library. But the framework design is based on flixel framework for AS3 game programming.


devolonter(Posted 2012) [#34]
@therevills, Hima is right, it is a framework based on Mojo library


FelipeA(Posted 2012) [#35]
Any updates on when will this be released, I am really looking forward to test this.


therevills(Posted 2012) [#36]
it is a framework based on Mojo library

Hima is right, it is a framework based on Mojo library


Ah cool, thanks for the answers :) It looks interesting...


devolonter(Posted 2012) [#37]
Alpha version flixel for Monkey just released!
You can download the source code and get more information at the project page on GitHub. I will appreciate any feedback!

P.S. All previous demo were updated, and also added a new demo Mode Game


slenkar(Posted 2012) [#38]
nice game
downloading sources....


FelipeA(Posted 2012) [#39]
Amazing!, the mode port runs really smooth on html5.
downloading.


muddy_shoes(Posted 2012) [#40]
It's out? Great! Well done. I'm sure I'll be using bits of this at some point in the future.


DruggedBunny(Posted 2012) [#41]
Cool! The HTML5 demo runs really well. Will have to have a play with this soon...


dopeyrulz(Posted 2012) [#42]
devolonter,

Great work - demos look great!

So this runs on all Monkey targets?? Also conversion of original source code say from iOS is reasonably easy?


slenkar(Posted 2012) [#43]
I cant seem to run the demos, unittest cant be found,
the bananas folder seems empty.


devolonter(Posted 2012) [#44]
I cant seem to run the demos, unittest cant be found,
the bananas folder seems empty.

Yes, it works at all Monkey targets. Conversion should be simple, I think. Port API is nearly the same as the original API. The main difference from the AS3 version that flixel for Monkey uses Monkey naming conventions. This must be taken into account when porting. For example, where in the original we wrote FlxG.play('sound'), in Monkey version it should be - FlxG.Play('sound')

@slenkar you get sources with git or download it from https://github.com/devolonter/flixel-monkey/downloads ?
You can download all bananas here - https://github.com/devolonter/flixel-monkey-bananas/downloads


slenkar(Posted 2012) [#45]
thanks

do you use a particular map editor?


Neuro(Posted 2012) [#46]
This is fricken awesome. I believe you can use the Dame map editor with this?


slenkar(Posted 2012) [#47]
I think Dame exports LUA scripts only, so maybe not,


Neuro(Posted 2012) [#48]
I havent had the chance to verify yet until i get home later tonight, but i think Dame can export the maps to CSV format which Flixel can load..not sure though.


devolonter(Posted 2012) [#49]
do you use a particular map editor?

No. All maps were taken from the original AS3 demo. In the game Mode map is generated automatically. I plan to make a small utility, something like Flixel Monkey Studio, in which map editor will be integrated. But I don't know when I'll start doing this.


Hima(Posted 2012) [#50]
You can also use Ogmo Editor. It export to xml, I think, and we already have an xmlparser in the monkey example.


Skn3(Posted 2012) [#51]
Been using this at the weekend and noticed that it doesn't currently have a "FlxAnimationCallback" handling.

To get working change AddAnimationCallback to...


...in FlxSprite.monkey


devolonter(Posted 2012) [#52]
@Skn3 lt'll be fixed in beta. Thank you!


Skn3(Posted 2012) [#53]
Devolonter, great work on this port btw.

Check out http://monkeycoder.co.nz/Community/posts.php?topic=2504

Used this at the weekend and it is really very well done. Flixel is naturally very nice, but I especially liked the bits you ported over such as your method for callbacks as implementations!

Keep up the good work :D


devolonter(Posted 2012) [#54]
@Skn3 Thanks for link! Interesting.
Callbacks are implemented under influence of programming for Android. Glad you liked the implementation :)


Raz(Posted 2012) [#55]
Since seeing Skn's demo, I am now looking forward to using this myself :)

Devolonter, have you looked at the XNA version much? Any idea how much garbage is created during runtime (if any!)


devolonter(Posted 2012) [#56]
@raz while porting I've look throgh the original flixel code in detail and was impressed how much attention was paid to control garbage. I've tried to keep this feature and avoid the creation of unnecessary objects. There were no specific tests, but so far I didn't noticed any problems with garbage. In any case, if there are any in XNA, let me know and I'll try to fix it.

P.S. Since the beta release is unfortunately delayed, I've added to the downloads section the nightly build. This version is only for testing and demo most likely will not work with it. But I'll be grateful if you help me with testing. You can see here the milestone for the beta version.


Raz(Posted 2012) [#57]
Sure thing, I'll try to do some tests, if not tonight, this weekend :)


Raz(Posted 2012) [#58]
Hi Devolonter (using the full-stable release), I've just tried it and unfortunately quite a bit of garbage is created when run as XNA. For Windows this isn't a problem, but it definitely is for Xbox and almost certainly is for Mobile.

Here's a screen shot showing where the most garbage is created. http://imgur.com/6Dyo3

Over a meg was generated in about 2 seconds and the Xbox garbage collector kicks in every 1 meg, causing a noticeable stutter in game.

I've not looked at the monkey flixel code yet to see what is causing it specifically, but i'll try to this weekend.


devolonter(Posted 2012) [#59]
@raz Wow! This is serious. What code (or demo) was launched at that moment? Could you tell by what means do you profile code in XNA? Maybe some tutorial? I have some free time and I would like to try to find out the reason for such amount of garbage.


Raz(Posted 2012) [#60]
Sorry, yeah I probably should have actually given you some details! It was the collision demo in the bananas directory. http://chrismingay.co.uk/blog/2011/06/monkey-xna-and-clr-profiling/ explains how I do CLR Profiling. I've had it running fine in XP 32bit and today in Windows 7 64bit (though you have to run the created bat file as an administrator). I imagine the function I highlighted is creating at least 1 new quad each time the function is called. By the looks of it, it's getting called lots of times per update as well, so this would easily cause junk.


devolonter(Posted 2012) [#61]
Thanks for the link!

By the looks of it, it's getting called lots of times per update as well, so this would easily cause junk.

That's right. But unfortunately it's just the tip of the iceberg ... I've just run collision demo and found out that in one update loop there were created from 60 to 80 objects of FlxQuadTree and from 300 to 400 of FlxList. It's strange that I did not pay any attention to it when porting. I'll try to use recycling, to get rid of the generation of new instances. FlxList caching should not be a problem, but FlxQuadTree may be a headache task, so I can provide a working solution no earlier than tomorrow. I think this should help


devolonter(Posted 2012) [#62]
OK. Maybe not the best solution, but it seems it worked. Now the garbage collector in a collision demo is called once in 11 seconds (in Windows). I will continue the research with a profiler, to reduce the amount of garbage.

[edit]To update the lastest-stable release, replace the following files: flxg.monkey, flxobject.monkey, system/flxlist.monkey and system/flxquadtree.monkey files from the archive. Nightly build was also updated.[/edit]


Raz(Posted 2012) [#63]
Did you get the CLR profiling working ok? :) I'll give things another look tonight and help in whatever way I can.


devolonter(Posted 2012) [#64]
Hi! Profiler works fine :) It's a great tool. Thank you! By the way, I found the CLR Profiler for. NET Framework 4, it works without .bat file. You can download it here - http://www.microsoft.com/download/en/details.aspx?id=16273

After more thorough testing, I found a few places for improvement, as well as fixed caching bug, which had caused an infinite loop. Now in collision demo, garbage collection is called once every 20 seconds, and the mode-game demo no more than two times per minute.

To update the lastest-stable release, replace the following files: flxg.monkey, flxobject.monkey, system/flxlist.monkey and system/flxquadtree.monkey files from the archive. Nightly build was also updated.


Raz(Posted 2012) [#65]
Hey glad to hear it. Flixel seems perfect for the game I hope to make (specifically the whole collision handling thing), so I look forward to using it.


Raz(Posted 2012) [#66]
Just tried this again Devolonter and there is much less junk now :) Angelfont is causing a lot of junk still though



I'm not sure how much there is that can be done about this though because XNA is really bad at handling strings during run time (to the point where I removed all strings from Ninjah and used images for all text).

Commenting out _driver.Draw(x,y) within the DrawSurface method of flxText and running the same collision demo creates the following



And there isn't too much you can do about NativeMethods.Point


Raz(Posted 2012) [#67]
I just tried the mode demo and amazing to see that NativeMethods.POINT is the only major cause of junk (once text drawing is disabled) :)


devolonter(Posted 2012) [#68]
Hi! I'm glad to hear it! :) I will look how to optimize the rendering of text, but for now I can not understand the reason for this amount of garbage. Maybe I should look at the code generated by the Monkey.


Raz(Posted 2012) [#69]
(I think) It's because strings aren't managed objects and so every time you parse a string to get the individual characters (as Angel font would to display the string), it's creating a new instance of a string object.

I'm half working on a system that converts a string in to a managed object. It reads the string at creation and then converts each character in to relative coordinates (so basically turns a string in to an object full of ints). It doesn't do any clever wrapping or anything, but it will almost certainly be enough for what I need.


devolonter(Posted 2012) [#70]
@raz I think you're right.
Your idea sounds interesting! Should we wait any patch for flixel-monkey or it is suitable only for your project? In any case, thanks for the idea!


Raz(Posted 2012) [#71]
I'll have to clear it up a bit, but I'd be happy for it to be used if it were useful!

You can't really do much with it yet, but the syntax is currently...

testStringSmall = New Text()
testStringSmall.SetSize(Text.SMALL)
testStringSmall.SetPos(200,200)
testStringSmall.AddLine("the third line")
testStringSmall.AddLine("shows unassinged characters")
testStringSmall.AddLine("£ $ %")
testStringSmall.AddLine("it sure does!")



devolonter(Posted 2012) [#72]
Nice! I will be waiting. Thanks!


Goodlookinguy(Posted 2012) [#73]
I just picked up the latest main branch of this and also looked at the pre-beta branch. There's a bug I noticed on line 140 of flxsprite.monkey on both versions.

If (reverse) Then
	_flipped = True
Else
	_flipped = True
End if


I changed it to this to fix it

_flipped = reverse



devolonter(Posted 2012) [#74]
Hi! Fixed that. Thank you!


devolonter(Posted 2012) [#75]
Hello,

Nightly builds now support the Jungle IDE automatic module updater! You can download the new version here - https://github.com/downloads/devolonter/flixel-monkey/flixel-monkey-nightly.zip

Important! Remember that nightly builds are for testing only, and may be unstable.


devolonter(Posted 2012) [#76]
Hello,

The decision to release one more interim alpha-version before the beta release was motivated by the following reasons:
1. The release of beta-version, unfortunately, was obscenely delayed
2. Compilation errors in the Monkey v58

So, meet Flixel for Monkey v1.0a2. List of changes:
* Compatibility with Monkey v58

* Added support of the Jungle IDE automatic module updater

* The prefix of internal library assets was changed by suffix _flx. Now you can filter the application resources using standard Monkey tools, without breaking the framework. For example, #IMAGE_FILES = "* _flx.png|* _your_filter.png"

* Added implementation of Revive method for FlxGroup class. This API is absent in original flixel

* Simplified the use of FlxBasic.Cameras property. Now, to specify object cameras use a simple snippet: object.Cameras = [id1, id2, ..]. Note that now FlxBasic.Cameras is a property, rather than a field and, therefore, a CamelCase is used

* Added support of the Cameras property for class FlxGroup. This API is absent in original flixel

* Added FlxText.GetFontObject method. In order for you to have the opportunity to customize the font properties for a particular object

* Added FlxG.RemoveBitmap function. This API is absent in original flixel

* Added the accelerometer support in WP7

* Improved class FlxQuadTree FlxObject.SeparateX and FlxObject.SeparateY functions. Now they do not generate a huge amount of garbage

* The use of class FlxArray is simplified. All methods are replaced by functions, and now you have to use it static. For example, FlxArray<Int>.GetRandom(array)

* Many other bug fixes


But that's not all! Now Flixel for Monkey has a website that will contain some useful information. Hope you enjoy it!

Official website: http://devolonter.github.com/flixel-monkey/. There you can download the latest version of the framework.

P.S. Now you can support the project financially! In Donate section you will find everything that’s necessary for it:) Thank you!


Neuro(Posted 2012) [#77]
Its great to see this coming along :)! Definitely looking forward to updates on the Monkey Flixel website. BTW, does this current version of Monkey Flixel supports joystick input yet?


Soap(Posted 2012) [#78]
Cool that you're using Bootstrap. You should use Font Awesome too! http://fortawesome.github.com/Font-Awesome/


devolonter(Posted 2012) [#79]
BTW, does this current version of Monkey Flixel supports joystick input yet?

Yes, current Flixel for Monkey version supports joystick. Use FlxG.Joustick(unit = 0) to get the object of Joystick class, which contains all the methods of generic input class, such as Pressed, JustPressed, JustReleased, and, additionally, has the X, Y and Z properties

Cool that you're using Bootstrap. You should use Font Awesome too! http://fortawesome.github.com/Font-Awesome/

Wow! Thanks for link! I definitely will use this


devolonter(Posted 2012) [#80]
Important update!


* Fixed two critical bugs in the FlxEmitter and FlxSound classes.
* Now, to revive all the elements in the group use FlxGroup.ReviveAll



Learn more about bugs here.

Sorry.


FelipeA(Posted 2012) [#81]
I've been playing with Flixel monkey since I am used to work with the as3 version. I don't know if it's my problem or what but I get an "Array out of Index" error on FlxTilemap.monkey, line 213, when I make more than 10 SwitchState when having a tilemap on a state.


devolonter(Posted 2012) [#82]
Hi!

Can you send me code example on email?

Thanks!


devolonter(Posted 2012) [#83]
Hi!

There is an important fix for those who use FlxTilemap and FlxG.SwitchState. Replace the file FlxTilemap by the file from here: flxtilemap.monkey

This fix will be included into the next release.


devolonter(Posted 2012) [#84]
Hi!

Update v1.0a3 is now available. Only bug fixes are included. Download the update.

--
Best regards


c.k.(Posted 2012) [#85]
Your "Quickstart" guide says, "Monkey currently does not support reflection, so here we emulate necessary functional"

I think monkey supports reflection now. Does that mean the lib will be updated to reflect that?


devolonter(Posted 2012) [#86]
Does that mean the lib will be updated to reflect that?

Yes, I'm currently working on it. Version with reflection support will be released in a couple of weeks.


devolonter(Posted 2012) [#87]
Topic was moved here