Diddy (part 2)

Monkey Forums/Monkey Programming/Diddy (part 2)

DruggedBunny(Posted 2011) [#1]
Thread continued from here...

Original post by therevills:

We've started an open-source code base which adds extra functions to Monkey.

Currently Diddy (as in Diddy Kong ;)) has the following:

* New Commands (tested on most platforms, apart from iOS and Mac):
- FlushKeys()
- RealMillisecs()
- ShowMouse()
- HideMouse()

* Screen-based Framework
- Move between screens with fading


http://code.google.com/p/diddy/


muddy_shoes(Posted 2011) [#2]
Wow... pagination, how does that work?


DruggedBunny(Posted 2011) [#3]
Hey, this is the historically approved way from blitzbasic.com, which also doesn't feature pagination! In fairness, it's rarely needed, but 100+ posts generally means "do this".

Aaanyway... Diddy.


therevills(Posted 2011) [#4]
Once Samah has checked in the new GUI stuff, I'll create a new zip with the latest source.

For those who might have missed the GUI demo:

* Z-ordered Movable Windows (and closable!)
* Buttons
* Checkboxes
* Radiobuttons
* Sliders

Using one image atlas and an XML file.

http://users.on.net/~swoolcock/monkey/testGUI/MonkeyGame.html


matt(Posted 2011) [#5]
It'd be nice if threads are going to be split like this, that the original poster can put a summary near the top. For those people who will undoubtedly come in here and say "what exactly is this thread about?


DruggedBunny(Posted 2011) [#6]
OK, updated original post.


matt(Posted 2011) [#7]
Thanks man


Samah(Posted 2011) [#8]
GUI is checked in! The next version will have sound support and an ImageButton class where you can assign your own static images.


luggage(Posted 2011) [#9]
Cool. The GUI will come in handy for the editor. Do I have to get a version from SVN? It's a bit tricky as when I try to install a client it plays havok with my current sourcecontrol. Is there any chance of a version in the Downloads link at all please?


Samah(Posted 2011) [#10]
therevills said he'd throw together a download at some point. If you want to manually get them through the Google Code browser, all you should need is framework.monkey, gui.monkey, and the GUI example. I think that's all I changed...


therevills(Posted 2011) [#11]
Just uploaded r179.zip:

http://code.google.com/p/diddy/downloads/list

I wanted to fix issue 15 before uploading the new zip - it took alot longer than I thought it would!!!

BTW Zip files will almost always be behind the SVN source code.


luggage(Posted 2011) [#12]
Awesome. Will stick that in tonight and give the GUI a good going over.

Thanks for the work on this!


Aman(Posted 2011) [#13]
Diddy rocks. I learned alot from the examples. Thanks very much


Samah(Posted 2011) [#14]
Thanks for the work on this!

Diddy rocks. I learned alot from the examples. Thanks very much

<3

I'm working on some simple layout managers at the moment. I'll likely have a ButtonPanel class handy (or something similar) to make it easy to throw together a "main menu" with very little fuss.


matt(Posted 2011) [#15]
Ooh, lovely.


therevills(Posted 2011) [#16]
Added "ShowKeyboard" for Android... trying to figure out how to actually get the input from it though... normally you would add an EditText and link the keyboard to the component.


luggage(Posted 2011) [#17]
Hi There

I'm just working on an editor for my game and was wondering the best way to save my data. I've had a look at the serialize example but I'm not sure how I go about using the DeSerialize bit? In the example it does...

Local tcSer:XMLElement = s.SerializeObject("tc", tc)


Then resuses "tcSer" to DeSerialize later on.

Local tc2:TestClass = TestClass(s.DeserializeObject(tcSer))


If all I'm doing is DeSerializing how do I create a valid tcSer to pass through?

Oh. And where is the file saved? I'm guessing I need to copy the file out and stick it in my levels folder as I can't see how to write to a specific file.

Thanks!


Samah(Posted 2011) [#18]
The "file" isn't saved anywhere. What happens is that the serializer gives you an XML node that you can add to a document. Sorry, that should be a bit clearer in the example. :)

To serialize (assuming s is a Serializer):
Local doc:XMLDocument = New XMLDocument

doc.Root.AddChild(s.SerializeObject("object1", object1))
doc.Root.AddChild(s.SerializeObject("object2", object2))
doc.Root.AddChild(s.SerializeObject("object3", object3))

Local output:String = doc.ToString()

Now you can do what you will with the output string (save it to a .xml file or whatever you need).

To deserialize (assuming s is a Serializer, and all your top level objects are of type MyClass):
Local parser:XMLParser = New XMLParser
Local doc:XMLDocument = parser.ParseString(LoadString("myobjects.xml"))

For node:XMLElement = EachIn doc.Root.Children
  Local myobject:MyClass = MyClass(s.DeserializeObject(node))
  ' do something with your deserialized object here
Next


In the future I may make the serialization module a little more robust so that it generates full documents for you. If I need to change the format significantly I'll look into putting version numbers on the files so that your code won't break (hopefully).


Samah(Posted 2011) [#19]
Just to tease you all, here's the work-in-progress for the latest version of the GUI.

http://users.on.net/~swoolcock/monkey/testGUI/MonkeyGame.html

Once I'm happy with it I'll check it in. :)

Edit: Compiled with debug, sorry. I need to do some HTML5 optimisations, then I'll post a new demo and look at checking it in.


Dabz(Posted 2011) [#20]
Nice going Samah! ;)

Dabz


therevills(Posted 2011) [#21]
Added LaunchBrowser and LaunchEmail for Android, thanks to Matty.

http://www.monkeycoder.co.nz/Community/posts.php?topic=1112

On the weekend I'll have a go at getting these to work with some of the other targets.

[edit]
Well HTML5 was easy...
[/edit]

[edit]
Flash was abit harder...
[/edit]

[edit]
Windows GLFW was alot harder!!! HATE C!
[/edit]


luggage(Posted 2011) [#22]
re: Serialization. Ah, thanks Samah, that makes more sense.

Looking forward to the latest GUI, your font looks much neater!


Samah(Posted 2011) [#23]
GUI example updated. Nothing visual, I just added some optimisations for text in HTML5 (should be a massive FPS boost!) and rebuilt it in release mode.

Edit: AARRRGHGHHHH refactoring is a horrid task! D:

Should be good for checkin tonight, hopefully. A lot of public fields have been made private with public properties. The reason for this is that the less fields and methods that are exposed, the more I can tinker around with the internals and (hopefully) not break compilation of users' code. :)
So yes, you will need to update some of your code to use properties instead of direct field references. Remember, field names start with lowercase, property names are usually the same as the field name but starting with uppercase... usually. :)

Note that at some stage I will be going through Diddy and renaming public interfaces to start with "I" and public abstract classes to start with "Abstract". This should hopefully remove some ambiguity between class and field names. For example, I can now have a field called "mouseListener" and a property called "MouseListener" (since the field is of type IMouseListener).

Once I'm ready I'll also upload the Java source I used to generate the fonts.


matt(Posted 2011) [#24]
Just a quick note to say thanks for the continued work on this :)


Samah(Posted 2011) [#25]
Just a quick note to say thanks for the continued work on this :)

<3

GUI changes committed! No zip build yet until all targets have been tested thoroughly (HTML5 works swimmingly). Bleeding edge is bleeding. :)

Edit: Renamed the font files since Flash doesn't like hyphens.


NoOdle(Posted 2011) [#26]
I don't see any text on the gadgets with the GUI example, I am using the r179 zip and have tried it on HTML5, iOS and GLFW.

Is this a bug or am I missing something?


therevills(Posted 2011) [#27]
BTW Zip files will almost always be behind the SVN source code.



therevills(Posted 2011) [#28]
r199.zip uploaded, which includes the latest GUI changes.

http://code.google.com/p/diddy/downloads/detail?name=diddy-r199.zip&can=2&q=


Xaron(Posted 2011) [#29]
Added "ShowKeyboard" for Android... trying to figure out how to actually get the input from it though... normally you would add an EditText and link the keyboard to the component.


That is awesome! Will that be available for iPhone as well?

Regarding the EditText: You're right, the keyboard should pop up automatically as soon as you have an edit box there. Have you tried it that way?


Samah(Posted 2011) [#30]
New GUI changes uploaded, maximise/shade buttons work now and a couple of bug fixes.
Next up, TextBox! (hopefully)


therevills(Posted 2011) [#31]
@Xaron... still trying to get it to work... :/

Added SetGraphics(w, h) for HTML5 and GLFW (Windows and Mac) - thanks to Erik (Earok):

http://www.monkeycoder.co.nz/Community/posts.php?topic=1157


luggage(Posted 2011) [#32]
Has anyone else got any problems with looping sfx playing in html5? The example provided doesn't work. My browser is Firefox 5.0.


therevills(Posted 2011) [#33]
@luggage - not really a Diddy issue, HTML5 has heaps of sound problems. And a quick test just using Monkey/Mojo in FireFox 4 has the same issue:



luggage(Posted 2011) [#34]
Phew! Thought I was doing something wrong. I didn't mean to imply it was definitely a Diddy problem. I just didn't want to post in the HTML5 thread as the code I'd list would have been the Diddy interface (which is a nicer way of handling the sounds imo).

While I'm in the Diddy thread, what are people's thoughts on handling multiple resolutions. I'm using the virtual resolution in Diddy which is excellent but I'm not sure how to handle content and aspect ratios.

If I have a set of artwork at 1024x768 for iPad\PC you'd really want to specify a different set of art for mobile phones. And then what would be a good way to handle aspect ratio? The 4:3 game looks stretched on the phones.

Just wondering what everybody else is doing. It's really the biggest question mark I have with having something working across a lot of devices.


Aman(Posted 2011) [#35]
Great work. It helped me a lot. I am about to submit my first game sooner than expected thanks to your module. Thanks again.


therevills(Posted 2011) [#36]
I just didn't want to post in the HTML5 thread as the code I'd list would have been the Diddy interface


If you think you've got an issue, the best way is to do a little test app like I did in post #33 - then you know its either your code or Monkey.

I'm using the virtual resolution in Diddy which is excellent but I'm not sure how to handle content and aspect ratios.



Yeah Diddy needs to take into the aspect ratio... I've been meaning to do this. I've recently watched Google I/O 2011 Building Aggressively Compatible Android Games, and Chris' solution is this:


align the height of display, scale everything up, and let the
horizontal part grow/contract based on device aspect ratio.



This means that some of the graphics may get cut off on some devices. Check the presenation slides on 28 and 29. Its either that or black borders...


luggage(Posted 2011) [#37]
That's an interesting talk he gave, thanks for that.

The aspect ratio is a tricky one as it varies from game to game. Scaling and then handling the aspect ratio difference is the best option. Making the stretch left\right optional is best.

Something like a platform game you'd just draw more of the surrounding level to fill the screen. If your game is on a static screen however you'd probably be better off centering it and using a different background to fill to the left\right edges rather than have black bars. Any floating huds or whatever would be drawn related to the edges of the screen.

There must be a good sweet spot for screen res, aspect ratio for the devices we can target. I'm currently working in 1024x768 but I'm thinking I might be better off working in 1366x768 so it'll look correct on widescreen devices but design the layout so that the middle 1024 contains all the important bits.

Just to add. I'm calling SetScreenSize(1024, 768) but how do I get the flash build to display at 640x480? I've set about 3 different things in the html and as to 640x480 but the render still tries to do 1024x768.


therevills(Posted 2011) [#38]

Just to add. I'm calling SetScreenSize(1024, 768) but how do I get the flash build to display at 640x480? I've set about 3 different things in the html and as to 640x480 but the render still tries to do 1024x768.


Are you talking about the actual size of the Flash component in the browser? If so you need to alter the MonkeyGame.html and change the embed tag.

Im a little confused, do you want it to render at 1024x768 but in a 640x480 window?


@Amen:
Great work. It helped me a lot. I am about to submit my first game sooner than expected thanks to your module. Thanks again.

Excellent glad it has helped you - I guess this is your game you are talking about: http://www.monkeycoder.co.nz/Apps/app.php?id=72 - Looks good :)


luggage(Posted 2011) [#39]
Thanks for the reply. My game's native resolution is 1024x768 and all looks fine if my MonkeyGame.html is set to be 1024x768 as well.

If I change the size of the component in the browser to 640x480 the game still renders at 1024x768. Ideally Diddy's virtual resolution would size it down to 640x480 to match the component size.

Currently the game is still rendered at 1024x768 but you only see the top left 640x480.


therevills(Posted 2011) [#40]
Hmmm just tested it and works fine here. I tried the VirtualRes demo in examples\VirtualRes\virtual.monkey, all I changed was the SetScreenSize to SetScreenSize(1024, 768).

Can you post some code?


Gerry Quinn(Posted 2011) [#41]
Just want to say what a terrific piece of work you guys are doing! I downloaded Diddy the other day and I will definitely be incorporating it in my project. (Of course I should have looked before I made a menu class!)


Cheese(Posted 2011) [#42]
Hey there,

I haven't really touched upon the tile engine yet, but I plan to very soon! Before I do, though, I need a bit of help understanding how it works.
Taking a quick browse through the example and skimming through the module's source gave me a good idea as to how to use it from the top end, but I can't say the same thing for the map's XML file structure; specifically tile layers.

I see that it can only read base64 encoded tile data so far. This is okay, but I'm just uncertain as to how you arrived at the present data in the example.
Having seen the mention within the ToDoList on the Wiki concerning implementation of DAME support in the future, I was wondering if you've already created an early Lua script for DAME's exporter that generated the file for you.

If this is the case, could you please share it, or otherwise elaborate on the tile data's structure and how you arrived at it? ;)

Thanks in advance,
- Brandon.


therevills(Posted 2011) [#43]
elaborate on the tile data's structure and how you arrived at it


This one is Samah's module... but basically the data structure is based on the Tiled map editor's struture:

http://www.mapeditor.org/

Just create your map in Tiled and save it, rename to an xml and you should be able to load it up using Diddy's tile engine.


Cheese(Posted 2011) [#44]
@therevills

Alright, thank you!
Tiled looks like a very nice editor and I'll definitely give it a whirl.
DAME's downside, despite it having some very cool dynamic features, is that it tends to display itself as generally unstable to me.

Up until this point, I've always just quickly thrown an editor together myself or commissioned someone to do so.. and I've got to say, it feels pretty relieving to be able to focus on gameplay more so than anything else right now.
Gotta love Diddy.

Kind regards,
- Brandon.


hardcoal(Posted 2011) [#45]
thats great


therevills(Posted 2011) [#46]
Just created a wiki page for the Tile engine:

http://code.google.com/p/diddy/wiki/TileEngine


Samah(Posted 2011) [#47]
Just added touch event handling support, including long press and fling. I may do some more gestures in the future if I get around to it. :)

Make sure to download the latest source from the repository.


TheRedFox(Posted 2011) [#48]
Just a note, I seem to be unable to load an image with more than one frame and then display one of the frames as I want.

Diddy's code has support for tiles and animations, but I basically want to have an image with all kind of pictures and then pick one of these using DrawImage( image:Image, x#, y#, frame=0 ) with a frame number > 1.

I wanted to use something like:

images.Load(resname + GFX_EXT, resname, False,... 2)

and be able to do a images.Find(resname).Display(x,y,frame)

I can do this with mojo but would love to have it in the images manager.

Or am I missing something?


TheRedFox(Posted 2011) [#49]
... looks like LoadTileSet and DrawTile will do the job.


Volker(Posted 2011) [#50]
Just created a wiki page for the Tile engine:

Looks great. Thanks.


therevills(Posted 2011) [#51]
@TheRedFox: Why not use: images.Find(resname).Draw(x:Float, y:Float, rotation:Float = 0, scaleX:Float = 1, scaleY:Float = 1, frame:Int = 0)?

BTW I really wouldn't be doing images.Find(resname) is the runtime loop... its better to assign the image within the Start method of a screen.


Zwer99(Posted 2011) [#52]
I have a problem with the tile engine:

When I use your map "map.xml" then everything works perfectly. If I open the map.xml and change something, for example the tileset or the map size then everything works perfectly.

But if I try to make my own map, by clicking on the "new"-button in Tiled then there's always following error:

"Array intex out of range"
on the line:

Local tm:TileMap = reader.LoadMap("maps/map4.xml")


What is the problem. It is impossible!

Yes, I changed the preferences to Base64(uncompressed)
Yes, I took a look into my XML-File and searched for the tileset-path. It is exactly the same as in your xml-file.

Everything is the same, but it doesn't work!


therevills(Posted 2011) [#53]
If our example works fine, there must be some difference.

Can you upload/email your map and images so we can test with?


Neuro(Posted 2011) [#54]
I had the same problem with the tile engine..


therevills(Posted 2011) [#55]
Example? Code? Files?


Zwer99(Posted 2011) [#56]
Alright! Here are my code files + different maps. Just uncomment the mapPaths in the GameScreen.monkey - file in the method "Start"

I'm using Monkey V44 and Tiled V 0.7.0

http://www.cac.bplaced.net/downloads/temp/TileEngine_Problem.zip


Zwer99(Posted 2011) [#57]
By the way, thank you very much for the Framework. It helps a lot, if the tile engine will work properly. I think I'll need nearly every feature of it.

Good job, man! Thank you!


TaskMaster(Posted 2011) [#58]
Posted this under the Diddy sample. Probably should have posted it here:

I think the option buttons shouldn't return that they have been pressed when they were already selected? If I keep hitting one, it keeps returning the pressed event.


TaskMaster(Posted 2011) [#59]
I noticed you posted that Android and iOS don't need HideMouse/ShowMouse. My Android Tablet (Asus Transformer) allows me to plug in a mouse and a mouse cursor appears (it actually comes with a touchpad built into the keyboard dock). Would be nice if these two functions worked. I have not tried yet though, so I am not sure if they do or not.


GfK(Posted 2011) [#60]
My Android Tablet (Asus Transformer) allows me to plug in a mouse and a mouse cursor appears
Interesting... anybody tried pairing a bluetooth MagicMouse to an iPod/pad?


therevills(Posted 2011) [#61]
@Zwer99 - Thanks for the example, I'll have to talk to Samah, but I think the issue is with the Base64 padding, Diddy's example map data doesnt end in "=" or "==". (The '==' sequence indicates that the last group contained only 1 byte, and '=' indicates that it contained 2 bytes)

@TaskMaster - Not sure what you mean, sorry. Option button?

I didnt know that about the Android Mouse cursor... is it just a USB connection?


Samah(Posted 2011) [#62]
Fixed, will check in in a sec. Turns out that although it was correctly skipping the padding, it wasn't taking that into account when it created the actual return array (so it was 2 bytes too big).

Fixed function in functions.monkey:
Function DecodeBase64Bytes:Int[](src:String)
	InitBase64()
	Local a:Int, b:Int, c:Int, d:Int, i:Int, j:Int
	Local src2:Int[] = New Int[src.Length]
	Local padding:Int = 0
	
	' find out how many base64 characters
	Local srclen:Int = 0
	For i = 0 Until src.Length
		If BASE64_ARRAY[src[i]] >= 0 Then
			src2[srclen] = src[i]
			srclen += 1
			' check if it's a padding character and increment the count
			If BASE64_ARRAY[src[i]] = 64 Then padding += 1
		End
	Next
	
	' die if there are no base64 chars
	If srclen = 0 Then Return []
	
	' get the target length and create the array
	Local len:Int = 3*(srclen/4)
	If srclen Mod 4 = 0 Then
		len -= padding
	ElseIf padding = 0 Then
		If srclen Mod 4 >= 2 Then len += 1
		If srclen Mod 4 = 3 Then len += 1
	End
	Local rv:Int[] = New Int[len]
	
	i = 0
	j = 0
	Repeat
		a = BASE64_ARRAY[src2[i]]
		If i+1 > srclen Then Exit ' This shouldn't happen with base64, so something's wrong!
		b = BASE64_ARRAY[src2[i+1]]
		If i+2 < srclen Then c = BASE64_ARRAY[src2[i+2]] Else c = 64
		If i+3 < srclen Then d = BASE64_ARRAY[src2[i+3]] Else d = 64
		rv[j] = (a Shl 2) | (b Shr 4)
		If j+1 < len Then rv[j+1] = ((b & 15) Shl 4) | (c Shr 2)
		If j+2 < len Then rv[j+2] = ((c & 3) Shl 6) | d
		i += 4
		j += 3
	Until i >= srclen
	Return rv
End


Edit: Fixed another bug that would break if there was no padding.


Neuro(Posted 2011) [#63]
Still having the same issue with the tile engine.
Here's my test tile map : http://www.megaupload.com/?d=LXQWHLIO


Samah(Posted 2011) [#64]
The file you are trying to access is temporarily unavailable. Please try again later.



Neuro(Posted 2011) [#65]
Ok...sorry try this link : http://thewiieffect.com/files/Tile.zip


therevills(Posted 2011) [#66]
Just tried it Neuro, works fine for me - what error are you getting?


Samah(Posted 2011) [#67]
Make sure you use your arrow keys to scroll all the way down to the actual level. You could also manually set the offsets to the player location at the start of the level.

Also, if you use these properties on the layers, parallax should be taken care of for you.
<layer name="Cloud Layer" width="400" height="40">
 <properties>
  <property name="parallax_scale_x" value="0.3"/>
 </properties>
...
<layer name="Mountain Layer" width="400" height="40">
 <properties>
  <property name="parallax_scale_x" value="0.7"/>
 </properties>
...


A list of built-in properties can be found on the tile engine's wiki page.
http://code.google.com/p/diddy/wiki/TileEngine


Neuro(Posted 2011) [#68]
Just tried it Neuro, works fine for me - what error are you getting?

You were able to load it??

I was getting this error :


therevills(Posted 2011) [#69]
Yes with the fix above... Have you applied the change that Samah posted in post #62?
http://www.monkeycoder.co.nz/Community/post.php?topic=1060&post=12317


Neuro(Posted 2011) [#70]
Oh, i thought he already checked in that update to the latest Diddy Framework..adding now..

EDIT : Ok it doesn't throw the error messages anymore but now nothing loads after the title screen?


therevills(Posted 2011) [#71]
i thought he already checked in that update to the latest Diddy Framework..


He has... its in the SVN part not the zip.

http://code.google.com/p/diddy/source/diff?spec=svn231&old=229&r=231&format=unidiff&path=%2Ftrunk%2Fsrc%2Fdiddy%2Ffunctions.monkey

Ok it doesn't throw the error messages anymore but now nothing loads after the title screen?


Scroll down... press the down cursor key ;)


Neuro(Posted 2011) [#72]
Scroll down... press the down cursor key ;)

Whoohoo!!! Its there now :)!!! Thnx for the help therevills and Samah :)!


Zwer99(Posted 2011) [#73]
Yea!!! It works fine!

Thanks a lot! Nice support ;)


TaskMaster(Posted 2011) [#74]

@TaskMaster - Not sure what you mean, sorry. Option button?



In your GUI example there are a bunch of "option" buttons. Little round buttons that when you click them, they return a pressed event. If I press an option button that is already on, it should not return the "pressed" event again.

If I just keep clicking it, it keeps returning the "pressed" event. I think it should only send the event when it's state has actually changed.

Does this make more sense?


therevills(Posted 2011) [#75]
Ah the radio buttons... its just the example, you can do what you want in the GUI.

Normally a radio button is selected then another action (eg a click of another button) will use that selected radio button value.


Samah(Posted 2011) [#76]
If I press an option button that is already on, it should not return the "pressed" event again.

I disagree. You're clicking the button, therefore it should fire mouse events. If you want to catch when the value changes, there should be a separate event for it (which I can add if you want).

Edit: So what I'm doing is adding a ValueChanged method to RadioGroup. Just extend RadioGroup and override that method to handle when a new RadioButton is selected. I'll check it in once I've tested it all.


matty(Posted 2011) [#77]
Hi all,

I thought I'd post this here as a useful addition - it is the "Shareapp" feature in android - therevills you may want to add this?

http://www.monkeycoder.co.nz/Community/post.php?topic=1112&post=12337


therevills(Posted 2011) [#78]
Hi Matty, yeah I saw this but I'm not sure what it does? And whatever it does is there a similar thing for iOS/Windows etc?


wiebow(Posted 2011) [#79]
With this, your application can tell Android it is capable of doing something. When another app wants to perform an action (intent) it asks Android which applications on the system can perform that action. It's like the Windows equivalent to 'open this file (in this case, perform this action) with ...'


therevills(Posted 2011) [#80]
Thanks Weibo, I know what the intent part is but I dont know whats Matty's Shareapp thing does...


matt(Posted 2011) [#81]
It looks to me that it pops up a "Share" menu, populated by the system so people can share something from your game. I'd expect common entries to the menu to be Email, SMS, Twitter, Facebook, as supported by installed apps on your Android phone.

There's nothing quite like that on iOS. I hope there is one day, but right now the closest you can get is an Action menu (icon rectangle with curved arrow coming out of it) but the contents are hard coded per app.


therevills(Posted 2011) [#82]
Yep your right Matt... just tested it on my phone. It pops up a little dialog:

Share Using
* Bluetooth
* Email
* Gmail

When I hit Gmail, it opens the Gmail app with the message in the body.


matt(Posted 2011) [#83]
This is one feature I wish was on iOS. It could be made to do so much more... kind of like Services or Automator in Mac OS X. Limitless inter-app operability.


wiebow(Posted 2011) [#84]
Oh it's the other way around: the app can now tell the android OS its intent. Handy.


matt(Posted 2011) [#85]
Yes, very


Samah(Posted 2011) [#86]
Edit: So what I'm doing is adding a ValueChanged method to RadioGroup. Just extend RadioGroup and override that method to handle when a new RadioButton is selected. I'll check it in once I've tested it all.

Done. Check out the latest components.monkey to try it out. I've updated the GUI example too.


Difference(Posted 2011) [#87]
I'm getting an error when trying to compile for the GLFW target.
SVN version 260



It happens on the Functions example and others too.

Mac, Snow Leopard


therevills(Posted 2011) [#88]
Hi Difference, I cant get on my Mac ATM, but can you try altering the diddy.glfw.mac.cpp file for me?

The issue is with the RealMod function:
	static float realMod(float value, float amount) {
		return modf(value, &amount);
	}


For some reason it thinks that one of the parameters is a double!?!?

Could you try this:
	static float realMod(float value, float amount) {
		return fmod(value, &amount);
	}


And add this to the top of the file:
#include <math.h>



Difference(Posted 2011) [#89]
Whit the changes above I get:




Samah(Posted 2011) [#90]
Try this then:
static float realMod(float value, float amount) {
	return (float)fmod(value, amount);
}
Since fmod expects absolute values and not pointers.
You may need that (float) cast too if fmod is bringing back a double.


Difference(Posted 2011) [#91]
Solved! Samahs version compiles.

Thanks both & thanks for creating and maintaining diddy :-)


therevills(Posted 2011) [#92]
Glad its working... still dont see why its using the double method instead of the float one:

fmod
     double fmod (      double numerator,      double denominator );
      float fmod (       float numerator,       float denominator );
long double fmod ( long double numerator, long double denominator );


http://www.cplusplus.com/reference/clibrary/cmath/fmod/

[edit]
Actually looking at Samah's code he isnt using the pointer in the call... so I wonder if the cast to float is needed...

modf
     double modf (      double x,      double * intpart );
long double modf ( long double x, long double * intpart );
      float modf (       float x,       float * intpart );

http://www.cplusplus.com/reference/clibrary/cmath/modf/

But again, why does the Mac version when using modf use the double version!?!
[/edit]


Big Jim(Posted 2011) [#93]
Ok, what am I doing wrong now?

I unzipped diddy and put it in my modules sub directory in my main MonkeyPro44 folder.

I try to run the first example, and I get "Module diddy" not found.


muddy_shoes(Posted 2011) [#94]
http://code.google.com/p/diddy/wiki/HowToInstall


GfK(Posted 2011) [#95]
I think there's a bug in Diddy's XML parser. It works perfectly in HTML5, but not for GLFW. I get an error:
"C:/MonkeyPro44/modules/diddy/assert.monkey<106> : Error : Loose text outside of any tag!"


Checked right through my XML file and everything is fine. Its the language file for my game (the English version) so I can't post it here.


therevills(Posted 2011) [#96]
or a bug with Monkey ;)

Any chance you can send me the xml?


GfK(Posted 2011) [#97]
Check your email!

I'm loading the file with:
self.xmldata = LoadString(binpath + "locale/locale.xml")


Then, this fails:
		Local parser:XMLParser = New XMLParser
		Local node:XMLElement
		Local nodeList:ArrayList<XMLElement>

		Self.map = New StringMap<StringObject>
		
		'parse XML data and dump it into a Tmap
		xmldoc = parser.ParseString(Self.xmldata)  'FAILS HERE



therevills(Posted 2011) [#98]
Ta Dave... looks like Monkey' GLFW doesnt like UTF-8 files, re-save it as ANSI and it should be good to go, I've raised a bug:

http://www.monkeycoder.co.nz/Community/posts.php?topic=1496

In other news, thanks to this post:

http://www.monkeycoder.co.nz/Community/posts.php?topic=1483

Diddy's Android method ShowAlertDialog will allow you to get text from the user using the virtual keyboard :)

Now got to find something similar for iOS....


samowitsch(Posted 2011) [#99]
With the new MonkeyPro45 i get an compile error ;o(

TRANS monkey compiler V1.18
Parsing...
Semanting...
/Users/csg/Desktop/DEVELOPING/Monkey/MonkeyPro/modules/diddy/collections.monkey<36> : Error : Missing return statement.

I posted an issue at google code of the diddy framework.

Regards, Christian


gregbug(Posted 2011) [#100]
Same here!!!

but only in strict mode...


therevills(Posted 2011) [#101]
Monkey bug guys:

http://www.monkeycoder.co.nz/Community/posts.php?topic=1515


GfK(Posted 2011) [#102]
Was just about to post that with v45, Diddy doesn't want to play nice.

Consider this code:
Strict
Function Main:Int()
	Local a:Bool = Test(True)
	Return
End Function	

Function Test:Bool(val:Bool)
	If val
		Return True
	Else
		Return False
	Endif
End Function

Result: Missing return statement error (fair enough, although there's no way out of this function without returning either True or False).

Strict
Function Main:Int()
	Local a:Bool = Test(True)
	Return
End Function	

Function Test:Bool(val:Bool)
	If val
		Return True
	Else
		Return False
	Endif
        Return   'should this not return the default value for the function (i.e. False)?  Diddy seems to think so!
End Function

Result: Missing return expression error.

Diddy has loads of issues like this.


therevills(Posted 2011) [#103]
Diddy has loads of issues like this.


You mean Monkey dont ya? ;)


GfK(Posted 2011) [#104]
You mean Monkey dont ya? ;)
Well... I dunno! I'm not sure if this is normal behaviour in Strict mode. I did search but couldn't find any documentation on it anywhere.

All I know for sure is Diddy compiled yesterday, and today it doesn't! :D


therevills(Posted 2011) [#105]
All I know for sure is Diddy compiled yesterday, and today it doesn't! :D


And what changed since yesterday, Diddy doesnt control the compiler ;)


GfK(Posted 2011) [#106]
Well, I thought Strict mode was 'fixed' in v45. As I say, I can't find any documentation on it so I'm never really sure exactly what it's meant to be doing. I've only been using Monkey for three weeks and in all of that time, Strict has been broken.


therevills(Posted 2011) [#107]
I would say it was fixed for this bug:

http://www.monkeycoder.co.nz/Community/post.php?topic=1370&post=12736

But now Abstract Methods are broken ;)


therevills(Posted 2011) [#108]
Mark has just uploaded v45b which fixes Abstract Methods, so now Diddy compiles again :)

[edit] Opps the GUI stuff needed a slight fix - DoDrag wasnt returning anything...


Zwer99(Posted 2011) [#109]
One short question: are you working on the particle engine? How long will it take approximately?

Thank you!


Samah(Posted 2011) [#110]
Zwer99: One short question: are you working on the particle engine? How long will it take approximately?

It's still on the backburner, since I've decided I'd like to actually write a game. :) If my game ends up needing a decent particle system, I'll add one to Diddy.


Zwer99(Posted 2011) [#111]
@Samah: Alright, thank you for the info :)

Today I updated my Monkey to V45b and tried to compile my game to the flash-target. Suddenly I get following errors:

C:\Monkey\Android\BunnyHopp\Main.build\flash\MonkeyGame.as(5614): Spalte (Column): 26 Fehler(Error): Call to a
possibly undefined method loadBitmap through a reference with static type MonkeyGame.

		var bitmap:Bitmap=game.loadBitmap( path );

ERROR:C:\Monkey\Android\BunnyHopp\Main.build\flash\MonkeyGame.as(6056): Spalte(Column): 24 Fehler(Error): Call
to a possibly undefined method loadSound through a reference with static type MonkeyGame.

		var sound:Sound=game.loadSound( path );


I don't know if its a diddy-bug or a monkey-bug... sorry, if it is a monkey-bug ;)


Soap(Posted 2011) [#112]
One suggestion. This will be simple to do, add an update function that can be overloaded. I'll be adding it to the diddy framework but it'd be nice if it was there and I didn't have to add it every time I updated diddy.


therevills(Posted 2011) [#113]
@Zwer99 - that looks like a Monkey bug, but I'll check it out tonight.

@Soap - Not sure what you mean can you post where and what you add to the framework?


Samah(Posted 2011) [#114]
Just added a very simple implementation for internationalisation.
Basically you make a file called i18n.xml with all your language information, then load it with LoadI18N(). Use SetI18N("language") to select the current language.
Whenever you want to use a string that might be localised, wrap it with I18N(). If that string hasn't been localised for the selected language, it will just return the argument.

In OnCreate:
LoadI18N()

Anywhere else in your app:
Print(I18N("Hello World!")) ' prints "Hello World!"
SetI18N("french") ' change the current language to French
Print(I18N("Hello World!")) ' prints "Bonjour, tout le monde!"
ClearI18N() ' resets language to "default", which is whatever you've coded (not necessarily English)

Look in the example for the xml format.


therevills(Posted 2011) [#115]
@Zwer99 - I've just tested Diddy and v45b in Flash and I don't get those errors, have you cleaned your build folder? If so, can you post a code sample which produces the issue?


Zwer99(Posted 2011) [#116]
Oh, sorry!

I cleaned my build folder and now it works! Thank you for the hint ;)

Sorry again...


Nobuyuki(Posted 2011) [#117]
silly issue: Does a tilemap have to have an .xml extention to be read in by the parser? using a .tmx filename on the wiki example asserts "Tiled Raw XML not supported!" on a supported map, though by changing the same map's extension to .xml it appears to work...


DruggedBunny(Posted 2011) [#118]
It's that time again! Thread continued here...

[EDIT: Stuff up my own previous post, didn't I?]