Where is Diddy?

Monkey Programming Forums/User Modules/Where is Diddy?

Beaker(Posted 2012) [#1]
It's here:
Diddy thread


therevills(Posted 2012) [#2]
LOL!


therevills(Posted 2012) [#3]
I've just commited this change:

http://www.monkeycoder.co.nz/Community/post.php?topic=1964&post=28581

and defaulted the fade time to be 1000 (it was 50), so if your fading happens really quickly (or you cant see it) change your fade time!


Samah(Posted 2012) [#4]
Perhaps the other Diddy threads could be moved here then?


Paul - Taiphoz(Posted 2012) [#5]
I think what should be done is you guys make a Diddy thread in here with all the info on the module, what is it, some example source showing its use, some blurb about it etc.

then bellow add links to any related threads, that way people looking for modules find it, and find the info quickly, then if they want to can follow the links to read the more discussion based threads.


Samah(Posted 2012) [#6]
I assume this will become the new Diddy topic then?
Anyway, I've extended the threading module slightly to add coroutine support. Currently tested on Android, but it should work fine for the other threaded targets. I'll test them when I get a chance.

What's a coroutine, you say?
http://en.wikipedia.org/wiki/Coroutine

Essentially you can split your code up into discrete jobs and freeze them at any point. It's very useful for AI. When I get a chance I'll post an example that shows how you might use it in a game.

Warning: Each coroutine is a thread, so don't go creating one for every enemy and bullet!


therevills(Posted 2012) [#7]
Finally got round to adding support for Sprite Atlases (Sparrow Format):

[monkeycode]Strict

Import diddy

Function Main:Int()
new MyGame()
Return 0
End

Global gameScreen:GameScreen

Class MyGame Extends DiddyApp
Method OnCreate:Int()
Super.OnCreate()
LoadImages()
gameScreen = new GameScreen
game.Start(gameScreen)
return 0
End

Method LoadImages:Void()
' create tmpImage for animations
Local tmpImage:Image
' load normal sprite
images.LoadAnim("Ship1.png", 64, 64, 7, tmpImage)
' load atlas sprites
images.LoadAtlas("sprites.xml")
End
End

Class GameScreen Extends Screen
Field shipImage:GameImage
Field axeAltasImage:GameImage
Field longswordAltasImage:GameImage

Method New()
name = "Game"
End

Method Start:Void()
shipImage = game.images.Find("Ship1")
axeAltasImage = game.images.Find("axe")
longswordAltasImage = game.images.Find("longsword")
End

Method Render:Void()
Cls
DrawText "GAME SCREEN!", SCREEN_WIDTH2, 10, 0.5, 0.5
FPSCounter.Draw(0, 0)
shipImage.Draw(100, 100, 0, 1, 1, 3)
axeAltasImage.Draw(200, 100)
longswordAltasImage.Draw(300, 100)
End

Method Update:Void()
If KeyHit(KEY_ESCAPE)
FadeToScreen(Null)
End
End
End[/monkeycode]


Zwer99(Posted 2012) [#8]
I heard that diddy includes the autofit-Code from James. Is that true?
How can I use it? I can't find the SetVirtualDisplay and the UpdateVirtualDisplay - Methods... or are they somehow "hidden" in the diddy-Framework?

Thank you for your answers ;)


therevills(Posted 2012) [#9]
I heard that diddy includes the autofit-Code from James. Is that true?


Yep its true :)

We wrapped it in the SetScreenSize command, there is an example included in Diddy and we even did a wiki page for it:

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


Zwer99(Posted 2012) [#10]
:D aaa... Thank you! I'm so sorry, but I really couldn't find it, although I searched in the wiki :)


Zwer99(Posted 2012) [#11]
Hmmm... strange. When I use SetScreenSize without Aspect Ratio it works, but the scene is distorted. And when I use it WITH Aspect Ratio I just see a black screen... Is it a bug or is it again my mistake ;)


therevills(Posted 2012) [#12]
Post your code so we can see what you are doing...


Zwer99(Posted 2012) [#13]
format_code('Class Robotobot Extends DiddyApp
Method OnCreate:Int()
Super.OnCreate()

SetUpdateRate(60)
SetScreenSize(960, 640, True)
logoScreen = New LogoScreen()
logoScreen.PreStart()

Return 0
End
End')

format_code('
Class LogoScreen Extends Screen

Private
Field timer:Timer

Public
Method New()
game.images.Load("logo.png", "logo", False)
titleScreen = New TitleScreen()
Self.timer = New Timer(6000)
End

Method Start:Void()
game.screenFade.Start(2000, False)
End

Method Render:Void()
game.images.Find("logo").Draw(0,0)
End

Method Update:Void()
Self.timer.Update()

If Self.timer.getMode() = Timer.STOPPED Then
game.screenFade.Start(2000, True)
game.nextScreen = titleScreen
EndIf
End
End')


That's all what I'm doing


therevills(Posted 2012) [#14]
Yep, you found a bug ;)

We (*cough Samah cough*) changed the VR stuff in r405...

I need to test it but I think the fix is this:

framework.monkey
[monkeycode] Method OnCreate:Int()
...
SetScreenSize(DEVICE_WIDTH, DEVICE_HEIGHT)
deviceChanged = True ' <<<<<<<< NEW
...

Method OnRender:Int()
FPSCounter.Update()
If virtualResOn
PushMatrix
If aspectRatioOn
If (DeviceWidth() <> DEVICE_WIDTH) Or (DeviceHeight() <> DEVICE_HEIGHT) Or deviceChanged ' <<<<< NEW (or deviceChanged)
DEVICE_WIDTH = DeviceWidth()
DEVICE_HEIGHT = DeviceHeight()
deviceChanged = False ' <<<<< NEW
...
[/monkeycode]

Once I'm happy with it, I'll commit it to Diddy.


therevills(Posted 2012) [#15]
Just been testing and it seems to work okay (with a slight change), so I've commited it and added an Aspect Ratio example.

BTW Severin (Zwer99), Diddy will automatically set the update rate to 60, only set it if you want something different.

Also I wouldnt do the loading in a constructor, its asking for trouble ;)

And we added a new way to fade between screens, this is how I would do your code from above:

[monkeycode]Strict

Import diddy

Global logoScreen:LogoScreen
Global titleScreen:TitleScreen

Function Main:Int()
New Robotobot()
Return 0
End

Class Robotobot Extends DiddyApp
Method OnCreate:Int()
Super.OnCreate()
SetScreenSize(960, 640, True)
logoScreen = New LogoScreen()
game.Start(logoScreen)
Return 0
End
End

Class LogoScreen Extends Screen
Field logo:GameImage

Private
Field timer:Timer

Public
Method New()
name = "title"
End

Method Start:Void()
logo = game.images.Load("logo.png", "logo", False)
titleScreen = New TitleScreen()
Self.timer = New Timer(game.CalcAnimLength(6000))
End

Method Render:Void()
Cls
logo.Draw(0,0)
End

Method Update:Void()
Self.timer.Update()
If Self.timer.GetMode() = Timer.STOPPED Then
FadeToScreen(titleScreen)
Endif
End
End

Class TitleScreen Extends Screen
Method New()
name = "title"
End

Method Start:Void()
End

Method Render:Void()
Cls
DrawText "TITLESCREEN", 10, 10
End

Method Update:Void()
If KeyHit(KEY_ESCAPE)
FadeToScreen(game.exitScreen)
End
End
End

Class Timer
Field time:Float
Field mode:Int
Const RUNNING:Int = 0
Const STOPPED:Int = 1

Method New(amount:Float)
time = amount
mode = RUNNING
End

Method Update:Void()
If time > 0 Then
time -= dt.delta
Else
mode = STOPPED
End
End

Method GetMode:Int()
Return mode
End
End[/monkeycode]

(Of course I don't know whats in your Titlescreen and Timer classes)

Finally always use Cls in the Render...


Zwer99(Posted 2012) [#16]
Thank you! Now it's working ;)


SweCoder(Posted 2012) [#17]
After browsing around for a few days, I've come to realize that Diddy is more or less a definite starting point for most monkey-projects.

It's a bit overwhelming though, and I'm not sure of what all is included to be honest. I tried to read through all the old diddy-threads but I got lost :).

I know documentation is the most boring part of development, but it's also worth it's weight in gold for other developers. Is someone working on keeping the wiki updated? I'd love to see an up to date overview of functions and syntaxes for all that's included in Diddy.


Samah(Posted 2012) [#18]
@therevills: We (*cough Samah cough*) changed the VR stuff in r405...

The change fixed one bug but apparently introduced another. At least I found the first one... ;)

@SweCoder: I know documentation is the most boring part of development, but it's also worth it's weight in gold for other developers.

Diddy has been a hobby project for me, and I basically add things as I need them. I know documentation is important, but I'd really need to put some extra time aside for it. therevills can attest to how poor my documentation skills are... ;)

Edit: I've started doing some documentation, so don't complain. ;)


Snader(Posted 2012) [#19]
I love diddy, it is getting better and better. Is it possible to add something like this into Diddy?

http://en.androidwiki.com/wiki/Loading_images_from_a_remote_server


SweCoder(Posted 2012) [#20]
@Samah: Diddy has been a hobby project for me, and I basically add things as I need them. I know documentation is important, but I'd really need to put some extra time aside for it. therevills can attest to how poor my documentation skills are... ;)

Edit: I've started doing some documentation, so don't complain. ;)



Haha, it was certainly not meant as a complaint. Believe me, I have the deepest respect for what you guys are doing with Diddy. It's just that as a newcomer it feels a bit intimidating to get into, not having a good overview of what's available. Right now I'm looking through the example code and learning a lot from that though.


therevills(Posted 2012) [#21]
Is it possible to add something like this into Diddy?
http://en.androidwiki.com/wiki/Loading_images_from_a_remote_server

It is possible to add it to Monkey, but if we add it to Diddy, coders will have to always be change the Monkey generated Android Manifest xml, so its best to do this outside Diddy.

I know documentation is the most boring part of development

I've slowly started in-source documentation:
http://code.google.com/p/diddy/source/detail?r=429


Origaming(Posted 2012) [#22]
hi, yesterday i update my monkey,diddy and flex to build for flash,,,

And found this bug while build on flash :
1. Click stage
2. Then I click another window( lost focus )
3. When I back on stage, onTouchHit function always run even I don't click it

I already test it with android and html5 build and it work's well..

Have any idea ?


Goodlookinguy(Posted 2012) [#23]
@Origaming
This is a Monkey bug - http://www.monkeycoder.co.nz/Community/posts.php?topic=3107


Origaming(Posted 2012) [#24]
@Goodlookingguy
cause i checked using

format_code('
Method OnTouchHit:Void(x:Int, y:Int, pointer:Int)
If TouchDown(0)
Print "Pointer1 + " + pointer
Endif
Print "Pointer2 + " + pointer
end
')

TouchDown return false and pointer2 return 0.
i' think, monkey has update something, and that's not suitable with diddy..
Thanks, I will be wait for next release


therevills(Posted 2012) [#25]
Added support for LibGDX atlases...

[monkeycode]images.LoadAtlas("libgdx_sprites.txt", images.LIBGDX_ATLAS)[/monkeycode]

[monkeycode]Field spriteImage:GameImage
...
spriteImage = game.images.Find("ship") 'ship is stored in the atlas[/monkeycode]


Samah(Posted 2012) [#26]
If it's a Diddy bug it'll most likely be in InputCache. I'll take a look later today.


Origaming(Posted 2012) [#27]
Thanks Samah

I have created a save game system using FileSystem.monkey class
Please take a look and feel free to leave any comments :D
format_codebox('
#rem
Created by Rudianto Chai

'How To use
Local saveClass:saveGame = new saveGame()
saveClass.create("myGame")
saveClass.save("myHp","500")
Local myHp:Int = 0
myHp = Int(saveClass.load("myHp"))
#end

Import diddy

Class saveGame
Field saveGameFolder:String
Field saveGameName:String
Field saveGameSlot:Int

Private
Field fileHandler:FileSystem

Method findVar:Int(var:String)
Local stream:FileStream
Local temp:String
stream = Self.fileHandler.ReadFile(saveGameFolder + "/" + saveGameName + saveGameSlot + ".bin")
For Local i:int = 0 until stream.arr.Length
temp = stream.ReadString()
if temp.Find(var + ":") = 0 Then
Return 1
endif
next
Return 0
End

Public
Method create:void(_saveGameName:String, _saveGameSlot:Int = 0, _saveGameFolder:String = "origaming")
Self.fileHandler = FileSystem.Create()
saveGameName = _saveGameName
saveGameFolder = _saveGameFolder
saveGameSlot = _saveGameSlot
End

Method save:void(var:String, value:String)
Local stream:FileStream
Local temp:String

if Self.fileHandler.FileExists(saveGameFolder + "/" + saveGameName + saveGameSlot + ".bin") then
Local data :Int = findVar(var)
stream = Self.fileHandler.ReadFile(saveGameFolder + "/" + saveGameName + saveGameSlot + ".bin")
Local temp2:String[] = new String[stream.arr.Length]
For Local i:int = 0 until stream.arr.Length
temp2[i] = stream.ReadString()
Next
stream = Self.fileHandler.WriteFile(saveGameFolder + "/" + saveGameName + saveGameSlot + ".bin")
if data = 0 then
For Local i:int = 0 until temp2.Length
stream.WriteString(temp2[i])
Next
stream.WriteString(var + ":" + value)
Else
stream = Self.fileHandler.WriteFile(saveGameFolder + "/" + saveGameName + saveGameSlot + ".bin")
For Local i:int = 0 until temp2.Length
temp = temp2[i]
if temp.Find(var + ":") = 0 Then
stream.WriteString(var + ":" + value)
Else
stream.WriteString(temp)
endif
Next
EndIf
Else
stream = Self.fileHandler.WriteFile(saveGameFolder + "/" + saveGameName + saveGameSlot + ".bin")
stream.WriteString(var + ":" + value)
EndIf

Self.fileHandler.SaveAll()
End

Method load:String(var:String)
Local stream:FileStream
Local temp:String
if Self.fileHandler.FileExists(saveGameFolder + "/" + saveGameName + saveGameSlot + ".bin") = False then
Return "No SaveGame File"
EndIf
if findVar(var) = 0 Then
Return var + " Not Found"
EndIf
stream = Self.fileHandler.ReadFile(saveGameFolder + "/" + saveGameName + saveGameSlot + ".bin")
For Local i:int = 0 until stream.arr.Length
temp = stream.ReadString()
if temp.Find(var + ":") = 0 Then
Return temp.Replace(var + ":","")
endif
next
End

Method copyGameSlot:Void(_from:Int, _to:Int)
Local stream:FileStream
Local temp:String

if Self.fileHandler.FileExists(saveGameFolder + "/" + saveGameName + _from + ".bin") then
if Self.fileHandler.FileExists(saveGameFolder + "/" + saveGameName + _to + ".bin") then
delete(_to)
EndIf
stream = Self.fileHandler.ReadFile(saveGameFolder + "/" + saveGameName + _from + ".bin")
Local temp2:String[] = new String[stream.arr.Length]
For Local i:int = 0 until stream.arr.Length
temp2[i] = stream.ReadString()
Next
stream = Self.fileHandler.WriteFile(saveGameFolder + "/" + saveGameName + _to + ".bin")
For Local i:int = 0 until temp2.Length
stream.WriteString(temp2[i])
Next
Self.fileHandler.SaveAll()
EndIf
End

Method delete:Void(_slot:Int = 0)
if Self.fileHandler.FileExists(saveGameFolder + "/" + saveGameName + _slot + ".bin") then
Self.fileHandler.DeleteFile(saveGameFolder + "/" + saveGameName + _slot + ".bin")
endif
End
End
')


therevills(Posted 2012) [#28]
Just a small heads up, I've removed the RealMod function from Diddy since the Mod function in Monkey now supports floats (since v41)... So if your code uses RealMod just replace it to use the normal Monkey Mod function.


Samah(Posted 2012) [#29]
I've just thought of something with the input event handling, and I'd like some ideas on solutions. At the moment OnTouchHit and OnMouseHit are separate methods and are called separately based on target. I assume people will not want to implement both these methods with the same code when deploying to multiple targets.

I'm reluctant to create a OnTouchOrMouseHit method, and if I remove one of the methods it may break something. I'm tempted to just leave it as it is in case people want to implement different functionality per target. I think the best solution at the moment is to code your own delegate method and make those call it.

Edit: After looking through the changes in Monkey v59, I found this in mojo.flash.as:
[monkeycode]internal function OnDeactivate( e:Event ):void{
input=new gxtkInput;
if( Config.MOJO_AUTO_SUSPEND_ENABLED=="true" ){
InvokeOnSuspend();
}
}[/monkeycode]
The input=new gxtkInput; line was added, and I have a feeling that this is causing InputCache to mess up when it checks for changes in the button state. I'll see what I can do.


Samah(Posted 2012) [#30]
After some investigation, this is a Mojo bug. Raising a bug report...


therevills(Posted 2012) [#31]
A bug has already been raised, Samah:
http://www.monkeycoder.co.nz/Community/posts.php?topic=3107


Samah(Posted 2012) [#32]
A bug has already been raised, Samah:

Pfftt... sif I pay attention to the bug report forum. I'm more interested in new features. ;)
At least I don't have to fix InputCache, that thing is horrific!


Tibit(Posted 2012) [#33]
Just a small heads up, I've removed the RealMod function from Diddy since the Mod function in Monkey now supports floats (since v41)... So if your code uses RealMod just replace it to use the normal Monkey Mod function.


I found RealMod to still in use in Framework.monkey row 328

Change:
' Monkey's MOD doesnt work with floats
Local re:Float = RealMod(numTicks, 1)

To:
Local re:Float = numTicks Mod 1


therevills(Posted 2012) [#34]
Opps, thanks Tibit! Monkey's aggressive compiler got me again :(


Origaming(Posted 2012) [#35]
hi therevills,
does diddy screen have, function to check Deactive and Active when we push home button ?
because First draw problem on Android, i need to load while App get focus,,,

Edit : android platform even in a lock condition


therevills(Posted 2012) [#36]
Sorry Origaming, I dont understand what you mean. (also why do you have so much whitespace between "Cheers" and "Origaming" - it makes your post look really big ;))


Origaming(Posted 2012) [#37]
about first draw delay :
http://monkeycoder.co.nz/Community/posts.php?topic=1430

but when we push home button then return to app again,
it's delay again:
http://www.monkeycoder.co.nz/Community/posts.php?topic=2132

already try this solution and it's take a delay too,

how can we check on app focus or lostfocus ?
(opss sorry for the cheers XD)


therevills(Posted 2012) [#38]
In pure Monkey Mojo, you can use OnSuspend and OnResume. Within Diddy, you can only currently do this within the DiddyApp (since a DiddyApp extends Mojo's App).

What we could try is adding Suspend and Resume to the Screen class, and you should then be able to call custom code in there.

Add the OnSuspend and OnResume to the DiddyApp class in framework.monkey:
[monkeycode]Class DiddyApp Extends App
...
Method OnSuspend:Int()
currentScreen.Suspend()
Return 0
End

Method OnResume:Int()
currentScreen.Resume()
Return 0
End[/monkeycode]

And add the Suspend and Resume methods to the Screen class in framework.monkey:
[monkeycode]Class Screen Abstract
...
Method Suspend:Void()
End

Method Resume:Void()
End[/monkeycode]

Then in your screen code you can override Suspend and Resume.

Let me know how it goes and if its good, I'll add it to Diddy :)


Origaming(Posted 2012) [#39]
Thank's it work,
but it need some input on monkey for flash and html5 build, there's no Feature requests Forum, i'll post it on Monkey Programming Forum.


Midimaster(Posted 2012) [#40]
Diddy is a nice module project, which could save a lot of time in developing my android apps. But the reference part seems not to be complete....

I plan to you use Diddy intensive and want to write a tutorial on the german forum, but i cannot find a complete api reference.

At first I want to start with writing a tutorial about SimpleGui, but where can I see all possible functions, methods, constants, etc...

I see the samples, but do the show the complete possibilities of the SimpleGui?

I could search the file "simplegui.monkey.svn-base", but how can I know, which methods or field you decide to keep "private" or which "public"?

Where is a description of the "screen"-Class?

Wouldn't it be helpful, if you could write a short line in a additional text-file, each time you add any functionality?


Why0Why(Posted 2012) [#41]
Is there an example that covers the Sprite class extensively?


therevills(Posted 2012) [#42]
@Midimaster - I am slowly adding more doco to Diddy, but when we first started Diddy, we "hoped" that fellow developers would actually look at our code to see how it works and to see how Monkey works in general... it is coming.... slowly ;)

@Why0Why - I am in the process of writing a platformer example for Diddy which will use the Sprite class. In the mean time, check out testAnimation's player class and the SpaceBugs examples.


Why0Why(Posted 2012) [#43]
I have been ciphering through the source. I have looked at SpaceBugs. I understand that you guys have written Diddy in your spare time and it is a free labor of love, but I wish there was even a line of comments here or there. Like when I looked at the sprite class and rotation for example, I am just putting in numbers to guess what length does and what values it needs. It took me awhile just to figure out where the Sprite class was located.

I am generally bad at commenting myself, but I try to put one line before each method if it isn't totally obvious what all of the parameters do. I do understand docs are a pain and I appreciate all the work!

Part of the problem is even though I have been coding for years, it has always been as a hobbyist and it probably takes me a lot longer to figure stuff out than the average person. So it is probably mostly my lack of skills ;O

Major props again to both you and Samah. Diddy is an awesome piece of work!


Karja(Posted 2012) [#44]
Hey, I found a little bug when debugging my game. The range check doesn't allow an index >= size, which seems reasonable - but fails when you have an empty array. I.e., size 0.

Current code:
format_code(' Method RangeCheck:Void(index:Int)
' range check doesn't use assert, for speed
If index < 0 Or index >= size Then AssertError("ArrayList.RangeCheck: Index out of bounds: " + index + " is not 0<=index<" + size)
End')

Fix:
format_code(' Method RangeCheck:Void(index:Int)
' range check doesn't use assert, for speed
If index < 0 Or (index > 0 And index >= size) Then AssertError("ArrayList.RangeCheck: Index out of bounds: " + index + " is not 0<=index<" + size)
End')


Paul - Taiphoz(Posted 2012) [#45]
Are you guys all working off of the svn latest version or are you working off of the latest stable archive ?

Iv been working off of the archive but it looks like a lot has changed and I'm worried about updating to the svn version in case it breaks a lot of code. ?


Paul - Taiphoz(Posted 2012) [#46]
slid the new svn into the modules folder and my game still runs as expected phew!..

screen fades are a bit faster tho so guess im gona have to read up and find out all the juicy stuff iv been missing.


therevills(Posted 2012) [#47]
@Karja, thanks for the fix :)

@Taiphoz, we are pretty careful about our changes, so most of our changes wont break existing code.

With changes in general, check out the Changes pages: http://code.google.com/p/diddy/source/list

And regarding the Screen Fade, it was changed in r408, so that the time it would take to fade is the same on all targets. Just increase the value and you should be fine :P


Samah(Posted 2012) [#48]
@Karja: Hey, I found a little bug when debugging my game. The range check doesn't allow an index >= size, which seems reasonable - but fails when you have an empty array. I.e., size 0.

This fix is incorrect. Basically it's saying "index 0 is always ok, even if the list is empty," which is wrong. Can you show me your code that fails, please?

@therevills: ...we are pretty careful about our changes, so most of our changes wont break existing code.

lolololol except when we (and be we I mean I) randomly change function or class names... >_>

I only do it if it's logical, honest! ;)


Karja(Posted 2012) [#49]
Samah: "AddFirst" calls "Insert(0, o)", which causes a range check failure in debug mode. I guess one could fix it at the Insert instead; I took the lazy way. :)

This should do it:

format_code(' ' Overrides IList
Method Insert:Void(index:Int, o:E)
If rangeChecking And index <> 0 Then RangeCheck(index)
If size+1 > elements.Length Then EnsureCapacity(size+1)
For Local i:Int = size Until index Step -1
elements[i] = elements[i-1]
Next
elements[index] = o
size+=1
modCount += 1
End')


Samah(Posted 2012) [#50]
Yes, fixing it at the Insert is the correct way to do it. RangeCheck is for checking the range, which it does. Basically Insert needs to account for the case where index==size, in which case you're inserting at the end.

Also, I fixed a bug in the Tiled engine that was causing the map to be rendered one column left. This also fixes a compatibility issue with the latest version of the Tiled editor. They changed non-standard tile sizes to be aligned to the bottom right corner instead of the bottom left.


therevills(Posted 2012) [#51]
Added Vector2D module and a BresenhamLine function for RayCasting.

I've changed the platformer example to use raycasting for collisions, its still not 100% but its getting there.


AdamRedwoods(Posted 2012) [#52]
I made a quick & simple tile collision for Diddy's tile maps here, but ray-casting would be more accurate:
http://monkeycoder.co.nz/Community/posts.php?topic=3093


Why0Why(Posted 2012) [#53]
Steve,

Is the platform example available anywhere yet?


therevills(Posted 2012) [#54]
Is the platform example available anywhere yet?

Yep, its checked into the Diddy SVN - it is still WIP though, I'm trying to refine the raycasting to be faster and easier to use.

http://code.google.com/p/diddy/source/browse/#svn%2Ftrunk%2Fexamples%2FPlatformer

@Adam, yeah I saw that and thats similar to the way I normally do it, but I've been wanting to try out ray casting for a while :)


Neuro(Posted 2012) [#55]
Thats pretty cool :). But as easy as it is to use Tiled, i do get annoyed when i can't seem to select an area of the map and move it else where without having to copy/paste it.


Origaming(Posted 2012) [#56]
Hi...
OS Module from monkey have a StripAll, StripDir and StripExt function which same like diddy.function module and the result I can't use StrippAll in my code, should diddy use monkey os module too?

I already block the function and import the OS module at the top?


therevills(Posted 2012) [#57]
The os module is only for the GLFW target, Diddy needed these functions for the other targets and I added these before the os module was released... So you will have to use the namespace to decide which one you want to use :)


therevills(Posted 2012) [#58]
Added A* Path Finding module, thanks to Samah for saving my sanity again ;)


vicente(Posted 2012) [#59]
I'm having "unpexpected token '<' on this line:

stringbuilder.monkey
Arrays<Int>.Copy(value, 0, characters, length, value.Length)

Trying to run examples from last svn (and monkeypro60)

Am I doing something wrong?


therevills(Posted 2012) [#60]
I've just done a clean checkout and tested half a dozen examples and I havent received that error.

What example were you running?


vicente(Posted 2012) [#61]
Sorry, my bad! Was opening with the demo monkey. It's working :)


Paul - Taiphoz(Posted 2012) [#62]
There/Sam any chance of you adding support for http://www.codeandweb.com/physicseditor ?


therevills(Posted 2012) [#63]
any chance of you adding support for http://www.codeandweb.com/physicseditor ?


Maybe... its just spits out an xml file? So you can use the xml parser in Diddy to load them into Monkey?


Volker(Posted 2012) [#64]
Yes, you can select between Bxo2d generic xml which is a bit buggy, the vertices are flipped, and AndEngine exporter xml, which may be the better choice.


Origaming(Posted 2012) [#65]
hi,
newbie question about del asset,
am i right ?
[monkeycode] For Local key:String = EachIn game.images.Keys()
game.images.Find(key).image.Discard()
Next
game.images.Clear()[/monkeycode]

i am already try this, it was not clear 100%
[monkeycode] 'using this to clear recent asset sceene
game.images.Clear()[/monkeycode]

on some thread, that's say to load all asset at first load, i don't think that's good, because i try to run my game on Samsung GalaxyW, and got closed while on loading, i already to do separate loading.


therevills(Posted 2012) [#66]
i am already try this, it was not clear 100%


It looks fine to me, how do you know it wasnt cleared 100%?

game.images is just a StringMap, so game.images.Clear() should removes all keys and values and you are using discard for the images which is right.

Maybe you've found a Monkey bug...


Origaming(Posted 2012) [#67]
sorry for late replay

i did several test on flash and android to see memory result, on the first try, it cost less memory then second the one

edit : when I'm said
i am already try this, it was not clear 100%

I just used
[monkeycode]game.images.clear()[/monkeycode]
to clear my images.


therevills(Posted 2012) [#68]
Are you saying that game.images.clear() didnt release the memory, but this did:
format_code(' For Local key:String = EachIn game.images.Keys()
game.images.Find(key).image.Discard()
Next
game.images.Clear()')

?


Origaming(Posted 2012) [#69]
sorry, have found the problem,
i put
[monkeycode]game.images.PreCache()[/monkeycode]
while loading and i clear it, images cache will clear after GC run,
now i force GC to clear it, thanks


therevills(Posted 2012) [#70]
Sorry I am having a hard time understanding your posts.

How are you forcing the GC?


Origaming(Posted 2012) [#71]
Sorry I'm not a good english writer XD

I build my game for an Android,
I put the function on my custom class :
format_code('public static void forceGC()
{
System.gc();
}')

because my game have a huge source of images especially when on gameplay
I need to optimize my memory usage because we are planning on having this game in all devices


Volker(Posted 2012) [#72]
A friend told me the LaunchBrowser() function does not work under
Windows Phone. He sended me some code which should work.

For launchBrowser:
format_code('
#if WINDOWS_PHONE
var wbt = new WebBrowserTask();
wbt.Uri = new Uri(address);
wbt.Show();
#endif
')
For launchEmail:
format_code('#if WINDOWS_PHONE
EmailComposeTask emailComposeTask = new EmailComposeTask();

emailComposeTask.Subject = subject;
emailComposeTask.Body = text;
emailComposeTask.To = email;

emailComposeTask.Show();
#endif ')


therevills(Posted 2012) [#73]
Cheers Volker :)

I've added the launchEmail code as is, but I changed the launchBrowser code to this:
format_code(' WebBrowserTask webBrowserTask = new WebBrowserTask();
webBrowserTask.Uri = new Uri(address, UriKind.Absolute);
webBrowserTask.Show();')
Based off the MSDN page: http://msdn.microsoft.com/en-us/library/hh394020(v=vs.92).aspx#Y0

So these are in r464, I have not tested these changes.


Origaming(Posted 2012) [#74]
Hi, I found a bug on Sprite when midhandle = false;
format_code('Method New(img:GameImage, x:Float, y:Float)
...
'Self.SetHitBox( -img.w2, -img.h2, img.w, img.h)
Self.SetHitBox(-img.image.HandleX(), -img.image.HandleY(), img.w, img.h)
Self.visible = True
End')


therevills(Posted 2012) [#75]
Cheers :)


Moggy(Posted 2012) [#76]
Hi,
I'm seems to be having an issue when playing a looping mp3 file using diddy.
it loops ok, but there is a slight pause at the end so its not a smooth loop.

It's not a big mp3, only 47k. i've tried other mp3's as well and its the same issue.

i've tried the same sample just in monkey and it seems to loop fine.

I'm creating a game that will play a small sample of crowd noise in the background, but like i said its not looping correctly.

Is this a bug? or is there something else i should be doing. I looked at the sound demo in diddy so am sure i'm loading and playing the sound correctly.

Thanks


Volker(Posted 2012) [#77]
On flash? See here:
http://www.monkeycoder.co.nz/Community/posts.php?topic=2995


Tibit(Posted 2012) [#78]
I can't find the particle editor to be used with diddy's particle system. Where should I look? :)


Moggy(Posted 2012) [#79]
Ok, i found this post by siread (linked below) that helped fix my problem with looping sounds.

http://www.monkeycoder.co.nz/Community/post.php?topic=2519&post=25193

doing the looping like this works perfectly for me.


therevills(Posted 2012) [#80]
having an issue when playing a looping mp3

@Moggy, maybe raise a Monkey bug for the sound looping issue.

I can't find the particle editor to be used with diddy's particle system. Where should I look?

@Tibits... Samah did start a particle editor but he wasn't happy with it and unfortunately didn't continue with it.


Tibit(Posted 2012) [#81]
Aww.. so no particles? Any recommended alternative?


Tibit(Posted 2012) [#82]
therevills, I tried to up the FPS over 60 when using diddy, but it did not seem to work. Can it be done?


therevills(Posted 2012) [#83]
Aww.. so no particles?

There is a particle system in Diddy, but no editor...

http://code.google.com/p/diddy/source/browse/trunk/examples/Particle/testParticle.monkey

I tried to up the FPS over 60 when using diddy

Are you talking about the UpdateRate? If so you can do it like this:
[monkeycode]
Function Main:Int()
game = New MyGame()
game.FPS = 120
Return 1
End[/monkeycode]


Samah(Posted 2012) [#84]
Tibits, I might look at doing an editor for it, but I need to get this MonkeyTouch project done first.


Tibit(Posted 2012) [#85]
Yeah I really need a particle editor, but I do not want to create one myself haha

In my search I did find:

"working on a Monkey version of TimelineFX module at the moment (albeit a bit slowly!)" - http://www.rigzsoft.co.uk/index.php

Also found this:
http://pyro.fenomen-games.com/files/pyro_latest.exe

And this:
http://particledesigner.71squared.com/index.php

I'm not after something complex, just a very easy to use particle editor. Otherwise I can just as will handcode the stuff.

I'd have nothing against testing the editor you already made, if it is just wasting space - what language did you build it in?

I know, you use it in your Touch game and KILL two birds in one explosion!


Samah(Posted 2012) [#86]
I was going to do it in BlitzMax using wxMax, but I decided to go with C#. I think I might just do it Monkey so that it's easier to test.


Tibit(Posted 2012) [#87]
Yeah, having it in-game would allow for some pretty cool realtime testing. With reflection it might even be very possible to "attach" particle systems ad-hoc using a simple overlay interface.

Na that i too much fun...

btw the effects in TimelineFX is just superB. I mean WOW. Seriously.


Samah(Posted 2012) [#88]
Yeah TimelineFX is pretty sexy. I'm not quite pro enough to clone that though, sorry. :)


therevills(Posted 2012) [#89]
Thanks to invaderJim, Diddy now has support for the Mouse Wheel in Flash, HTML5, GLFW and XNA.

To access the MouseWheel you just need to call MouseZ and the framework will do the rest.

eg:
[monkeycode]yPos -= MouseZ() * 3.0[/monkeycode]

Also I've added MouseXSpeed and MouseYSpeed commands.


Moggy(Posted 2012) [#90]
Hi, i wonder if any of you could help me.

I'm loading a tilemap i created in tiled, and loading it and displaying it fine. I used the tile example from diddy to get this far.

but now i'm trying to figure out how to change one of the tiles in the grid, but for the life of me i can't figure out how. i'm quite new to this monkey stuff so i would be so happy if someone could point me in the right direction.

Thanks.


therevills(Posted 2012) [#91]
now i'm trying to figure out how to change one of the tiles in the grid


Within the TileMap there is a method called SetTile:

[monkeycode]Method SetTile:Void(x:Float, y:Float, tile:Int, layerName:String)[/monkeycode]


Moggy(Posted 2012) [#92]
Hi therevills,

I tried the setTile method but nothing in my tilemap has changed. it still draws as when it was first loaded.

i tried tilemap.SetTile(2,2,1,"border")

border being the name of the layer i want to change. I changed border to a name i know there is no layer called that and i got an error, so i know i've got the right layer. But its the same on any layer i try.

i'm trying to change grid x2 y2 to tile 1 in my tileSheet.

is there something im doing wrong? or am i just not understanding how this stuff works? which is very likely :)

here is the code i'm using
[monkeycode]
Class GameScreen Extends Screen
Field tilemap:MyTileMap
Field offsetX:Int, offsetY:Float

Method New()
name = "Game"
End

Method Start:Void()
Local reader:MyTiledTileMapReader = New MyTiledTileMapReader
Local tm:TileMap = reader.LoadMap("maps/map.xml")
tilemap = MyTileMap(tm)
game.screenFade.Start(1000, False)
End

Method Render:Void()
Cls
tilemap.RenderMap(offsetX, offsetY, SCREEN_WIDTH, SCREEN_HEIGHT)

End

Method Update:Void()
If KeyDown(KEY_UP) Then offsetY -=3
If KeyDown(KEY_DOWN) Then offsetY +=3
If KeyDown(KEY_LEFT) Then offsetX -=3
If KeyDown(KEY_RIGHT) Then offsetX +=3
If KeyDown(KEY_SPACE) Then tilemap.SetTile(2,2,1,"border")
End
End

Class MyTiledTileMapReader Extends TiledTileMapReader
Method CreateMap:TileMap()
Return New MyTileMap
End
End

Class MyTileMap Extends TileMap
Method ConfigureLayer:Void(tileLayer:TileMapLayer)
SetAlpha(tileLayer.opacity)
End
Method DrawTile:Void(tileLayer:TileMapTileLayer, mapTile:TileMapTile, x:Int, y:Int)
mapTile.image.DrawTile(x, y, mapTile.id, 0, 1, 1)
End
End

[/monkeycode]


therevills(Posted 2012) [#93]
The x and y parameters in SetTile are pixel coordinates not map coordinates.

Try this:
[monkeycode]Local layer:TileMapTileLayer = FindLayerByName("border")
layer.mapData.Set(2, 2, 1)[/monkeycode]


Moggy(Posted 2012) [#94]
Thanks for the help therevills, i think i'm getting closer.

i added this to my code in my post above
[monkeycode]
Local layer:TileMapTileLayer = tilemap.FindLayerByName("border")
layer.mapData.Set(2, 2, 1)
[/monkeycode]

Then did checks before and after using mapData.Set with
[monkeycode]
layer.mapData.Get(2, 2)
[/monkeycode]

I can see the tile is changing to what i set it, but its still not changing on screen, the tiles are still the same as when the map was first loaded. Is there something i need to do after using mapData.Set to let the tile system know i've made changes to the data?


Moggy(Posted 2012) [#95]
i think i've solved my problem. This worked for me.

[monkeycode]
Local layer:TileMapTileLayer = tilemap.FindLayerByName("border")
layer.mapData.Set(2,2,1)
Local cell:TileMapCell = New TileMapCell
cell.gid= 1
layer.mapData.SetCell(2,2,cell)
[/monkeycode]

Thanks again therevills, you've been a great help.


Tibit(Posted 2012) [#96]
It seems the sound and music examples are not working. I tried changing the Config.txt (Since I assumed this was the issue) but it seems it wants to load the .wav file insteaf of the .off (in the example).

I just updated on SVN so I should have the latest version of diddy.


therevills(Posted 2012) [#97]
To reduce the size of Diddy I removed the *.wav and *.mp3 files, when you load a sound without an extension Diddy will try to load the correct format based on the target:

[monkeycode] #if TARGET="flash"
sound = LoadSoundSample(SoundBank.path + file +".mp3")
#else If TARGET="android"
sound = LoadSoundSample(SoundBank.path + file +".ogg")
#else
sound = LoadSoundSample(SoundBank.path + file +".wav")
#endif[/monkeycode]


Samah(Posted 2012) [#98]
Added a CreateScreenshot() function that uses the new ReadPixels/WritePixels functionality. x, y, width, and height are optional and default to the entire screen.

Very simple:
[monkeycode]Local screenshot:Image = CreateScreenshot()[/monkeycode]


Midimaster(Posted 2012) [#99]
At first thank you for your nice modules and the work you are doing

But I wondered today about use of globals:


Do you use global constants outside your namespace in Diddy?

I tried to define my own const VERTICAL and I got an error!

Is this very reasonable to define globals, if you offer the module public? Wouldn't it be better to define them only in a namespace like "DIDDY.VERTICAL"?

But I have to ask me the same question...
Is it nowadays useful to define globals or should they be defined always in Classes only?

How should I do it in the future?


therevills(Posted 2012) [#100]
I tried to define my own const VERTICAL and I got an error!


Strange as Monkey does use namespaces, what error did you get?

I can do this without any errors:

format_codebox('Strict

Import diddy

Const VERTICAL:Float = 1.0

Function Main:Int()
game = New MyGame()
Return 0
End Function

Global titleScreen:TitleScreen

Class MyGame Extends DiddyApp
Method OnCreate:Int()
Super.OnCreate()
titleScreen = New TitleScreen
titleScreen.PreStart()
Return 0
End
End

Class TitleScreen Extends Screen
Field menu:SimpleMenu
Field musicFormat:String

Method New()
name = "TitleScreen"
End

Method Start:Void()
game.screenFade.Start(50, False)
menu = New SimpleMenu("ButtonOver", "ButtonClick", 0, 0, 10, False)
Local b:SimpleButton = menu.AddButton("newgame.png", "newgameMO.png")
menu.Centre()
End

Method Render:Void()
Cls
menu.Draw()
End

Method Update:Void()
menu.Update()

If menu.Clicked("newgame") Then
Print VERTICAL
Print diddy.VERTICAL
Print simplegui.VERTICAL
Print diddy.simplegui.VERTICAL
End
End
End')

Take note of the "Print" commands.


therevills(Posted 2012) [#101]
Continues here.

Mods please lock this thread :)