Diddy - An Open Source Framework - Part 8

Monkey Programming Forums/User Modules/Diddy - An Open Source Framework - Part 8

Samah(Posted 2014) [#1]
Thread continued from here...
An Open Source Framework that includes a set of extra functions and APIs for the Monkey language.

Diddy includes the following modules:

* Easy to use Screen based framework
* Sprite class
* Resource managers for sounds and images
* A* Path finding
* XML parser
* Asserts
* Serialization
* Particles
* Containers
* Tweening
* GUI (Buttons, Sliders, Windows)
* Base64 encoding/decoding
* Tile Engine (Using the Tiled Map Editor)
* ..and more


Diddy has moved to GitHub!
https://github.com/swoolcock/diddy


Samah(Posted 2014) [#2]
Reserved.


Samah(Posted 2014) [#3]
Storyboard now uses a <resources> tag in the xml file rather than accessing the framework GameImages. This allows you to use storyboards without using the screen framework.
Added an extra example that shows how to do this.


Dylan at sea(Posted 2014) [#4]
Samah, apologies if you've answered this before, but I just came back to Monkey after being away for a long time, and I didn't find any updates. In any case, I'm wondering whether you'll be able to add threading (coroutine) support for winrt/xna targets.


Samah(Posted 2014) [#5]
XNA shouldn't be too hard to do, I just need to search MSDN etc. for how to implement C# threading. I have no experience with compiling for WinRT. Does it just use .NET?


ziggy(Posted 2014) [#6]
I have no experience with compiling for WinRT. Does it just use .NET?
No, AFAIK it's c++/cli http://en.wikipedia.org/wiki/C%2B%2B/CLI


Samah(Posted 2014) [#7]
@ziggy: No, AFAIK it's c++/cli...

If it's C++ it should already work, although there may need to be some precompiler tweaking done. It uses TinyThread++ for its C++ target, which is a lightweight implementation of POSIX threads.

Edit:
Dylan at sea: Try changing these lines in thread.monkey, threading.monkey, and coroutine.monkey:
format_code('#If TARGET <> "ios" And TARGET <> "stdcpp" And TARGET <> "glfw" And TARGET <> "android" And TARGET <> "bmax" Then')
To:
format_code('#If TARGET <> "ios" And TARGET <> "stdcpp" And TARGET <> "glfw" And TARGET <> "android" And TARGET <> "bmax" And TARGET <> "winrt" Then')

Tell me if WinRT compiles (and works). Don't forget to copy header files, etc.


SGEM(Posted 2014) [#8]
Bug or intended consequence?

The recent addition of the math module duplicates the name "Tween" - in math it is a function, but it also exists as a class with static members in the tween module.

This has forced me to use some unpleasant qualification in my code, such for example

format_code('Local tween := diddy.tween.Tween.CreateSine(durationMillis, 0.5, -0.25, 0.5)')

Is this an intentional change?

Additionally shouldn't RectsOverlap() return a Bool rather than an Int?

I'm happy to contribute changes if someone can tell me how (including a fix for https://code.google.com/p/diddy/issues/detail?id=43).

Zac


therevills(Posted 2014) [#9]
Bug or intended consequence?

Definitely a bug... I added a bunch of helpful calculations functions, I didn't even think it would cause a clash with a Class name :(
I'll fix up the function name...

Additionally shouldn't RectsOverlap() return a Bool rather than an Int?

In the end it doesn't really matter as a lot of Monkey Bools get converted to Ints anyway and you can use Ints as a Bool in most situations. I would be reluctant to change it now as its very old code.

I'm happy to contribute changes if someone can tell me how

Thanks for the offer, do you know Hg well? You can clone Diddy and submit pull requests.


Samah(Posted 2014) [#10]
@SGEM: This has forced me to use some unpleasant qualification in my code...

You could use an alias if you want. At the top of your source:
format_code('Alias DiddyTween = diddy.tween.Tween')
Then you can use it like this:
format_code('Local tween := DiddyTween.CreateSine(durationMillis, 0.5, -0.25, 0.5)')


Dylan at sea(Posted 2014) [#11]
[Samah] Tell me if WinRT compiles (and works).

I tested with a simple project. Without Threading imported, it works fine. With Threading imported (and no code changes), it spits out errors like so:
format_codebox('Error 25 error C3861: 'InitializeCriticalSection': identifier not found project.buildv77f\winrt_win8\tinythread.h 160 1 MonkeyGameNative
Error 26 error C3861: 'Sleep': identifier not found project.buildv77f\winrt_win8\tinythread.h 184 1 MonkeyGameNative
Error 27 error C3861: 'InitializeCriticalSection': identifier not found project.buildv77f\winrt_win8\tinythread.h 249 1 MonkeyGameNative
Error 28 error C3861: 'Sleep': identifier not found project.buildv77f\winrt_win8\tinythread.h 666 1 MonkeyGameNative
Error 29 error C3861: 'CreateEvent': identifier not found project.buildv77f\winrt_win8\monkeygame.cpp 4791 1 MonkeyGameNative
Error 30 error C3861: 'CreateEvent': identifier not found project.buildv77f\winrt_win8\monkeygame.cpp 4792 1 MonkeyGameNative
Error 31 error C3861: 'InitializeCriticalSection': identifier not found project.buildv77f\winrt_win8\monkeygame.cpp 4793 1 MonkeyGameNative
Error 32 error C3861: 'WaitForMultipleObjects': identifier not found project.buildv77f\winrt_win8\monkeygame.cpp 4811 1 MonkeyGameNative
Error 33 error C3861: '_beginthreadex': identifier not found project.buildv77f\winrt_win8\monkeygame.cpp 4937 1 MonkeyGameNative
Error 34 error C3861: 'WaitForSingleObject': identifier not found project.buildv77f\winrt_win8\monkeygame.cpp 4962 1 MonkeyGameNative
Error 35 error C3861: 'GetSystemInfo': identifier not found project.buildv77f\winrt_win8\monkeygame.cpp 4992 1 MonkeyGameNative
')
The header files (tinythread.h and fast_mutex.h) are in the build folder. I'm note sure exactly how to fix it.


Samah(Posted 2014) [#12]
Alright, looks like I might have to reimplement it natively unless I can extern that stuff for TinyThread. I'll see what I can do.
It gives me an excuse to code the C# wrapper too.

Edit: ThreadPool class looks like the way to go, and I should be able to reuse that in C#.


nikoniko(Posted 2014) [#13]
Diddy seems a bit easy to understanding then fantomEngine or Ignition X but its documentation is poor too and uses incompatible with ted format of help file.


nikoniko(Posted 2014) [#14]
opps. look above.


Samah(Posted 2014) [#15]
@nikoniko: ...but its documentation is poor too and uses incompatible with ted format of help file.

I've been trying to slowly document what I can, but it's a big task. :)
As for documentation format, it was decided to use the Jungle format rather than monkeydoc.


Samah(Posted 2014) [#16]
Just implemented XNA threading and it seems to work. I'll port it over to WinRT when I can.

Edit: Looks like it's nigh on impossible to properly emulate pthreads in Windows Store apps. The API provided by Microsoft is just too restrictive. Sorry. :(


Asmodean(Posted 2014) [#17]
Is there an editor for Storyboard? I looked at the xml-File and this is far to complicated for me. An editor would be very handy.


Samah(Posted 2014) [#18]
@Asmodean: Is there an editor for Storyboard?

I have actually been working on one recently, but it got put on hold because no-one was specifically asking for it. I guess now I have incentive to continue it. :)


Asmodean(Posted 2014) [#19]
I guess now I have incentive to continue it.

That would be great. I think that Stroyboard is a great and useful feature and I wonder nobody ask about an editor.


Asmodean(Posted 2014) [#20]
SetGraphics and Html5

I have a little problem with SetGraphics. I tried it with different resolutions, but the canvas in Html5 is always 640x480.
With the target "Desktop" it works fine. I tried it with Chrome 34 and FireFox 29.
Doesn't SetGraphics work with Html5?


therevills(Posted 2014) [#21]
Doesn't SetGraphics work with Html5?

It works here.... but with MonkeyX's new resizable template you can only tell by that the images within the canvas changes.


Asmodean(Posted 2014) [#22]
Ok, I see. I thought it would resize automatically in the Browser-Window.
With Ziggys 'EnableAutoSize' from here EnableAutoSize it works fine.
Thanks for your help.


sionco(Posted 2014) [#23]
hi,
I've just started playing with the module, and love the tiled integration.

But, is there a way in diddy to separate the drawing of the layers, so I could draw one layer behind the player and another infront of them, so instead of

format_code('
tilemap.RenderMap(diddyGame.scrollX, diddyGame.scrollY, SCREEN_WIDTH, SCREEN_HEIGHT, 1, 1)
'player.Draw(diddyGame.scrollX, diddyGame.scrollY, True)
')
format_code('
something like
tilemap.RenderLayer(layer1,...)
player.Draw(...)
tileMap.RenderLayer(layer2,..)
')

not the best example, but,



therevills(Posted 2014) [#24]
I've added two RenderLayer methods to the TileMap class:
format_code('Method RenderLayer:Void(layerName:String, bx:Int, by:Int, bw:Int, bh:Int, sx:Float = 1, sy:Float = 1)')
and
format_code('Method RenderLayer:Void(layer:TileMapLayer, bx:Int, by:Int, bw:Int, bh:Int, sx:Float = 1, sy:Float = 1)')

Also changed RenderMap so you can add the layer name too.
format_code('Method RenderMap:Void(bx:Int, by:Int, bw:Int, bh:Int, sx:Float = 1, sy:Float = 1, layerName:String = "ALL")')

If you use RenderLayer, it will not call PreRenderMap and PostRenderMap.

Example:
format_code('tilemap.RenderLayer("CollisionLayer", diddyGame.scrollX, diddyGame.scrollY, SCREEN_WIDTH, SCREEN_HEIGHT, 1, 1) ' using the name of the layer we want to draw
tilemap.RenderLayer(tileLayer, diddyGame.scrollX, diddyGame.scrollY, SCREEN_WIDTH, SCREEN_HEIGHT, 1, 1) ' using the object of the layer we want to draw
player.Draw(diddyGame.scrollX, diddyGame.scrollY, True)
tilemap.RenderMap(diddyGame.scrollX, diddyGame.scrollY, SCREEN_WIDTH, SCREEN_HEIGHT, 1, 1, "Background") ' using the RenderMap to draw the layer with the name background
')


nikoniko(Posted 2014) [#25]
Asmodean wrote:
I have a little problem with SetGraphics. I tried it with different resolutions, but the canvas in Html5 is always 640x480.
With the target "Desktop" it works fine. I tried it with Chrome 34 and FireFox 29.
Doesn't SetGraphics work with Html5?


Fix for it http://www.monkey-x.com/Community/posts.php?topic=8515&post=88697


Asmodean(Posted 2014) [#26]
nikoniko wrote:



Oh, that's nice, Thanks. But I have a little trouble with the coordinates. I tried it with 800x600
Then I have a canvas with 800x600, but I can only use 640x480 pixel of the canvas. The coordinates in the 640x480-Canvas are for a 800x600 canvas.(I hope I could make myself clear :) )
If I set 'SetGraphics(800,600) at the begin, all works fine

format_code('
Import diddy
Import sethtmlsize

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

Class MyGame Extends DiddyApp
Method Create:Void()
SetGraphics(800, 600)
SetScreenSize(800, 600)
SetHTMLSize(800, 600)

Start(Singleton<MyScreen>.Instance())
End
End

Class MyScreen Extends Screen
Method Start:Void()
End

Method Update:Void()

End

Method Render:Void()
Cls
DrawRect(0, 0, 20, 20)
DrawRect(780, 580, 20, 20)
End
End
')


nikoniko(Posted 2014) [#27]
Set third parameter to True.
SetScreenSize(w, h, True)

Asmodean wrote:
If I set 'SetGraphics(800,600) at the begin, all works fine


It does the same as SetHMTLSize(), except call canvas.updateSize()

So new version for diddy's function is

format_code('
diddy.setGraphics=function(w, h)
{
var canvas=document.getElementById( "GameCanvas" );
canvas.width = w;
canvas.height = h;
if( canvas.updateSize ) canvas.updateSize();
//return window.innerHeight;
}
')


Asmodean(Posted 2014) [#28]
Set third parameter to True.


Ok, I thougt, it would be true by default. Now it works fine.
Thanks!


sionco(Posted 2014) [#29]

I've added two RenderLayer methods to the TileMap class:
Method RenderLayer:Void(layerName:String, bx:Int, by:Int, bw:Int, bh:Int, sx:Float = 1, sy:Float = 1)

and
Method RenderLayer:Void(layer:TileMapLayer, bx:Int, by:Int, bw:Int, bh:Int, sx:Float = 1, sy:Float = 1)

Also changed RenderMap so you can add the layer name too.
Method RenderMap:Void(bx:Int, by:Int, bw:Int, bh:Int, sx:Float = 1, sy:Float = 1, layerName:String = "ALL")

If you use RenderLayer, it will not call PreRenderMap and PostRenderMap.

Example:
tilemap.RenderLayer("CollisionLayer", diddyGame.scrollX, diddyGame.scrollY, SCREEN_WIDTH, SCREEN_HEIGHT, 1, 1) ' using the name of the layer we want to draw
tilemap.RenderLayer(tileLayer, diddyGame.scrollX, diddyGame.scrollY, SCREEN_WIDTH, SCREEN_HEIGHT, 1, 1) ' using the object of the layer we want to draw
player.Draw(diddyGame.scrollX, diddyGame.scrollY, True)
tilemap.RenderMap(diddyGame.scrollX, diddyGame.scrollY, SCREEN_WIDTH, SCREEN_HEIGHT, 1, 1, "Background") ' using the RenderMap to draw the layer with the name background


Thanks for this, this is fantastic!


Derron(Posted 2014) [#30]
If you "zOrder" your layers, you could also extend the code to allow "RenderLayers(0,10)" which draw all layers (non-exclusive) between 0 and 10 - then draw your player and then "RenderLayers(11,-1)" to draw all 10.

I am doing this in my BlitzMax-framework's gui-managing classes (framework is of course heavily inspired by the genious work done with diddy :D).

bye
Ron


therevills(Posted 2014) [#31]
Regarding the HTML5 screen size, I'll have a look at it tonight if I get time. I think the SetHTMLSize should be part of SetScreenSize to be more inline with the other targets.


therevills(Posted 2014) [#32]
Okay, I've had a look at the HTML5 resize code... this looks like all that is needed:
format_code('diddy.setGraphics=function(w, h)
{
var canvas = document.getElementById("GameCanvas");
canvas.width = w;
canvas.height = h;
canvas.setAttribute("style", "");
}')

By setting the style to be empty it seems to work... what do you guys think?


nikoniko(Posted 2014) [#33]
Or set if it needs or remove style attribute that is correct.
format_code('canvas.style.height=h;')


updateSize() method calcs also xscale/yscale if they are used in diddy...

format_code('
canvas.updateSize=function(){
xscale=canvas.width/canvas.clientWidth;
yscale=canvas.height/canvas.clientHeight;
game.RenderGame();
}
')


therevills(Posted 2014) [#34]
what about this:
format_code('diddy.setGraphics=function(w, h)
{
var canvas = document.getElementById("GameCanvas");
canvas.width = w;
canvas.height = h;
canvas.setAttribute("style", "");
if( canvas.updateSize ) canvas.updateSize();
}')

From my testing we need to clear the style of the canvas and now we call updateSize just in case anyone wants to use the xscale/yscale...


nikoniko(Posted 2014) [#35]
therevills wrote:
canvas.setAttribute("style", "");


I am not sure that is fully correct. Someone may set canvas' style in the html file (set backround-color, padding, margin, etc) this code remove all his changes.


therevills(Posted 2014) [#36]
Yeah that is true... I think I may leave Diddy as it is then, as the issue with setting the size depends on what HTML page the developer includes it in.


therevills(Posted 2014) [#37]
I've just committed a WIP SnapFling module, here its running:
http://www.therevillsgames.com/monkey/snapfling/MonkeyGame.html

(Horizontal only at the moment)


nikoniko(Posted 2014) [#38]
Nice!

Question about autoCls

I want to disable it in my code:

format_code('
Class MyGame Extends DiddyApp
Method Create:Void()
Local w:Int = 800
Local h:Int = 600

autoCls = False
drawFPSOn = True

'SetGraphics(w, h)
SetHTMLSize(w, h)
SetScreenSize(w, h, True)

Start(GameScreen.GetInstance())
End
End

')

FPS is displayed. And screen is cleared too! What do I wrong?


Asmodean(Posted 2014) [#39]
Question about autoCls
I want to disable it


autoCLS is by default False you shouldn't need to call it.
The problem seems to be SetScreenSize. If you change it form 640x480 autoCLS doesen't work anymore.


nikoniko(Posted 2014) [#40]
Asmodean wrote:
The problem seems to be SetScreenSize. If you change it form 640x480 autoCLS doesen't work anymore.


You're right! It's strange


therevills(Posted 2014) [#41]
Seems to work for me fine...

format_code('Strict

Import diddy

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

Class MyGame Extends DiddyApp
Method Create:Void()
drawFPSOn = True
SetGraphics(800, 600)
SetScreenSize(800, 600)
Start(Singleton<MyScreen>.Instance())
End
End

Class MyScreen Extends Screen
Field x:Float = 0

Method Start:Void()
End

Method Update:Void()
x += 1 * dt.delta
End

Method Render:Void()
DrawRect(x, SCREEN_HEIGHT2, 20, 20)
End
End')

If you use DiddyData, autoCls is set to true automatically.

BTW some targets don't like not having CLS, so be careful ;)


Samah(Posted 2014) [#42]
Re: Storyboard Editor: It's still being developed, don't worry! ;)


nikoniko(Posted 2014) [#43]
I used code as template from this topic http://www.monkey-x.com/Community/posts.php?topic=8396


Asmodean(Posted 2014) [#44]
@nikoniko:
If you use only SetScreenSize without! SetGraphics and you set the 'useAspectRatio' = true then autoCLS is enabled. With SetGraphics all works fine.


Samah:
Re: Storyboard Editor: It's still being developed, don't worry! ;)

That's nice. I'm looking forward to it. :D


nikoniko(Posted 2014) [#45]
Asmodean wrote:
If you use only SetScreenSize without! SetGraphics and you set the 'useAspectRatio' = true then autoCLS is enabled. With SetGraphics all works fine.


Ok. I did not find relation between these methods and autoCls/cls() in the framework.monkey. That is confused me.


therevills(Posted 2014) [#46]
@nikoniko - can you post your code here? I am also confused as I can't see the issue with autoCls :)


nikoniko(Posted 2014) [#47]
Monkey 79c/d, diddy don't know, got it from google rep.

format_codebox('
Strict

Import diddy

#If TARGET="html5"
Import dom
Extern Private
Global win:windowExtended = "window"
Class windowExtended Extends dom.Window = "Window"
Field innerWidth:Int
Field innerHeight:Int
Method eval:Object(parameter:String) = "eval"
End
Public
#END


Function EnableAutoSize:Void(canvasName:String = "GameCanvas")
#If TARGET="html5"
Local elem:= document.getElementById(canvasName)
If elem <> Null Then
elem.setAttribute("style", "");
EndIf
win.eval("var canvas=document.getElementById( '" + canvasName + "' );canvas.onresize=null;");
win.eval("window.onresize=function (e) {var canvas=document.getElementById( '" + canvasName + "' ); canvas.width = window.innerWidth; canvas.height = window.innerHeight; canvas.style='outline:initial;';} ;")
win.eval("window.onresize()")

#End
End

Function SetHTMLSize:Void(_w:Int, _h:Int, _canvasName:String = "GameCanvas")
#If TARGET="html5"
EnableAutoSize()
win.eval("var canvas=document.getElementById( '" + _canvasName + "' );")
'win.eval("CANVAS_WIDTH = "+_w+"; CANVAS_HEIGHT = "+_h+";")
win.eval("canvas.width = "+_w+"; canvas.height = "+_h+";")
win.eval("if( canvas.updateSize ) canvas.updateSize();")

#End
End


Global readyUpdate:Bool = True


Function Main:Int()
New MyGame()
Return True
End

Class MyGame Extends DiddyApp
Method Create:Void()
Local w:Int = 800
Local h:Int = 600

SetUpdateRate(60)

autoCls = False
drawFPSOn = True

'SetGraphics(w, h)
SetHTMLSize(w, h)
SetScreenSize(w, h, True)



Start(GameScreen.GetInstance())
End
End






'######################## MOVE TO UTIL.MONKEY
Global cEnum:Int = 0
Function enum:Int( i:Int = cEnum )
cEnum = i + 1
Return i
End
'########################


Class APad
Field xPos:Float
Field yPos:Float

Field prevXPos:Float
Field prevYPos:Float

Field canUpdate: Bool = True




Method New()
End Method

Method Update:Void()

If Not canUpdate Then Return
canUpdate = False

If TouchHit(0)
xPos = TouchX(0)
yPos = TouchY(0)

Print "Click at : " + xPos +" "+ yPos

Endif

if TouchDown(0)
xPos = TouchX(0)
yPos = TouchY(0)

Print "Move " + xPos + " " + yPos

Else

End if

End Method

Method Render:Void()
'Cls
DrawCircle(xPos, yPos, 10)
canUpdate = True
End Method

Method SendPosition:Void()
End Method

End Class


Class AGameField

Field width: Float
Field height: Float
Field left: Float
Field top: Float

Field rows: Int
Field cols: Int

Field gameField:Int[] 'size W * H


' set border size for best image game
Field borderSize:Float = 50.0
Field cellWidth: Float
Field cellHeight: Float

Global ERROR_OUT_OF_BOUNDS:Int = -1000

Field img: Image

Field pad: APad



Method New(_cols:Int, _rows:Int)

rows = _rows
cols = _cols
gameField = New Int[rows * cols]

'now define size of cell
cellWidth = Ceil((DeviceWidth() - borderSize) / cols)
cellHeight = Ceil((DeviceHeight() - borderSize) / rows)
'set to cell size to min - one of sides
cellWidth = Min(cellWidth, cellHeight)
cellHeight = cellWidth

Print cellWidth + " = " + cellHeight

width = cellWidth * cols
height = cellHeight * rows

left = (DeviceWidth() - width) / 2
top = (DeviceHeight() - height) / 2

Print left + " = " + top + " = " + width + " = " + height

img = LoadImage("monkey://data/zapor.jpg")

'stripsMan = New AStripManager(img, 15)

'board = New ABoard(6, 6)

pad = New APad()


End Method


Method Update:Void()

pad.Update()


End Method

Method Render:Void()
pad.Render()
End Method

End Class




Class TitleScreen Extends Screen
Global instance:TitleScreen = Null

Method New()
name = "Title"
End

Function GetInstance:TitleScreen()
If instance = Null
instance = New TitleScreen()
End
Return instance
End

Method Start:Void()
End

Method Render:Void()
'Cls
DrawText "TITLE SCREEN!", SCREEN_WIDTH2, SCREEN_HEIGHT2, 0.5, 0.5
DrawText "Space to Play!", SCREEN_WIDTH2, SCREEN_HEIGHT2 + 20, 0.5, 0.5
DrawText "Escape to Quit!", SCREEN_WIDTH2, SCREEN_HEIGHT2 + 40, 0.5, 0.5
End

Method Update:Void()
If KeyHit(KEY_ESCAPE)
FadeToScreen(diddyGame.exitScreen)
End
If KeyHit(KEY_SPACE) Or TouchHit()
FadeToScreen(GameScreen.GetInstance())
End
End
End

Class GameScreen Extends Screen
Global instance:GameScreen = Null

Field countScreen:Int = 1
Field TheGameField:AGameField

Method New()
name = "GameScreen"

TheGameField = New AGameField(10, 5)



End

Function GetInstance:GameScreen()
If instance = Null
instance = New GameScreen()
End
Return instance
End

Method Start:Void()
Print "Started screen " + countScreen
countScreen = countScreen + 1
End

Method Render:Void()
'If Not readyUpdate Return
'Print autoCls
'Cls
DrawText "GAME SCREEN!", SCREEN_WIDTH2, SCREEN_HEIGHT2, 0.5, 0.5
DrawText "Escape to go back to the Title!", SCREEN_WIDTH2, SCREEN_HEIGHT2 + 40, 0.5, 0.5
TheGameField.Render()

End

Method Update:Void()


TheGameField.Update()



If KeyHit(KEY_ESCAPE)
FadeToScreen(TitleScreen.GetInstance())
End


End
End


Class AdvScreen Extends Screen
Global instance:AdvScreen = Null

Method New()
name = "Advertising screen"
End Method

Function GetInstance:AdvScreen()
If instance = Null
instance = New AdvScreen()
End
Return instance
End Function

Method Start:Void()
End Method

Method Render:Void()
'Cls
DrawText "Adv screen!", SCREEN_WIDTH2, SCREEN_HEIGHT2, 0.5, 0.5
DrawText "Click anywhere to exit", SCREEN_WIDTH2, SCREEN_HEIGHT2 + 40, 0.5, 0.5

End Method

Method Update:Void()
If TouchHit()
FadeToScreen(GameScreen.GetInstance())
Endif
End Method


End Class



')


therevills(Posted 2014) [#48]
Thanks nikoniko, the issue is not with autoCls but it is caused by SetScreenSize as Asmodean stated. When using a virtual resolution and maintaining the aspect ratio the AutoFit code clears the screen.


Asmodean(Posted 2014) [#49]
Problem with FileSystem example

I tried the FileSystem example 'testFileSystem', but the example doesn't generate any files. I compiled for Desktop with Windows7/VC2010 and I searched all folders but there was no file generated. If I use the brl import from Monkey without diddy, the files will be generated in the VC2010 Folder. With diddy and brl Import I get an error about an duplicate identifier 'FileStream'.


StoneFaceEXE(Posted 2014) [#50]
I've had problems with compiling desktop target using MSVC so I switched to MinGW and very happy, except that I keep getting a certain error

format_code('
../main.cpp: In static member function 'static String diddy::openfilename()':
../main.cpp:5102:18: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
char *filter = "All Files (*.*)\0*.*\0";
^
../main.cpp: In static member function 'static String diddy::savefilename()':
../main.cpp:5130:18: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
char *filter = "All Files (*.*)\0*.*\0";
^
')

It doesn't affect anything really, builds are working perfectly, it's just the sound that I am missing. Could that be an issue or is it I just have to get my openal drivers reinstalled?

And I have the newest version of both monkey and diddy now.


therevills(Posted 2014) [#51]
@Asmodean
Problem with FileSystem example

The FileSystem within Diddy (created by Gfk) is a virtual file system which uses Monkey's LoadState and SaveState commands. It doesn't actually create physical files.
With diddy and brl Import I get an error about an duplicate identifier 'FileStream'.

Diddy's came first... you need to fully qualify which module you want to use.

@StoneFaceEXE
Nah its just a warning with the "OpenFileName" and "SaveFileName" native commands in Diddy, don't worry about them.


Asmodean(Posted 2014) [#52]
The FileSystem within Diddy (created by Gfk) is a virtual file system which uses Monkey's LoadState and SaveState commands. It doesn't actually create physical files.


Ah,ok. So there is no way to load a file from a directory with diddy?


therevills(Posted 2014) [#53]
Ah,ok. So there is no way to load a file from a directory with diddy?

You can use the normal MonkeyX commands, such as LoadString etc.


Asmodean(Posted 2014) [#54]
You can use the normal MonkeyX commands, such as LoadString etc.

OK. Thanks for your help.


sionco(Posted 2014) [#55]
Hi again, another question.

If I want to use the Path finding module with a tiled map, what do I put in the PathFinder.SetMap() brackets?

format_code('
PathFinder.SetMap(tilemap.??, tilemap.width,tilemap.width, 2, 0)
')


rIKmAN(Posted 2014) [#56]
Had a little play with Diddy and it's tilemap stuff recently, and just have a couple of questions.

1) Is there any way to use *just* the tilemap stuff on it's own, without any other Diddy stuff (screens, images etc) or having to be extended from a DiddyApp?
I guess I would like to be able to create a vanilla Monkey project and drop in the tilemap stuff and have it work if this is possible?

2) I may be doing something wrong, but I couldn't seem to find a way to get any tile data from the map - being able to get the current tile under the mouse, the properties of tiles etc etc
I'm sure it's possible, but the docs are a little lacking and the example from the wiki online are different than example code I've seen around the forum to do the same thing.

3) It seems that when my app "Extends DiddyApp" that #MOJO_IMAGE_FILTERING_ENABLED is ignored (or set again somewhere in the Diddy code after I have set it) as graphics that are in a vanilla "App" work fine, but when I use "DiddyApp" it seems image filtering is applied anyway and the resulting images are aliased/blurred.

Any help appreciated.


rIKmAN(Posted 2014) [#57]
Bump.

Any Diddy devs/users got any ideas?


therevills(Posted 2014) [#58]
@sionco
If I want to use the Path finding module with a tiled map, what do I put in the PathFinder.SetMap() brackets?

Adding this here, just in case someone else finds it useful:

Here is an example of a Tiled map using pathfinding:
http://code.google.com/p/diddy/source/detail?r=322c5ed4894ab246e1318fcf5a4830ef3b24d60a

@rIKmAN
Sorry - I didn't see this post until you bumped it...

1) Is there any way to use *just* the tilemap stuff on it's own, without any other Diddy stuff (screens, images etc) or having to be extended from a DiddyApp?
I guess I would like to be able to create a vanilla Monkey project and drop in the tilemap stuff and have it work if this is possible?

Not at the moment, the tiled module uses the framework internally for images and of course it uses the Diddy XML parser. By the way a DiddyApp is a normal Mojo App but extended.

I may be doing something wrong, but I couldn't seem to find a way to get any tile data from the map - being able to get the current tile under the mouse, the properties of tiles

Check out the testTiled example: http://code.google.com/p/diddy/source/browse/examples/Tile/testTile.monkey
And the platformer example: http://code.google.com/p/diddy/source/browse/#hg%2Fexamples%2FPlatformer

It seems that when my app "Extends DiddyApp" that #MOJO_IMAGE_FILTERING_ENABLED

Works fine here for me:
format_code('Strict
#MOJO_IMAGE_FILTERING_ENABLED=False

Import diddy

Global game:MyGame

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

Class MyGame Extends DiddyApp
Method Create:Void()')

Have you got an example?


Samah(Posted 2014) [#59]
I added a new RandomSource class that lets you separate random seeds across your application. This is amazingly useful for procedural world generation, because it no longer matters what order you create your entities, and it will not interfere with the global seed. I'll throw together a simple example at some point showing world generation.

At the moment it reuses the system Rnd() function, but I may rework some magic on it later to allow for your own pseudorandom algorithms.

format_code('Import diddy.math

Function Main()
' NextInt() ' returns a random value within the entire 32-bit signed integer range (-2147483648 to +2147483647)
' NextInt(n) ' returns a random integer value from 0 (inclusive) to n (exclusive)
' NextInt(low,high) ' returns a random integer value from low (inclusive) to high (inclusive)
' NextFloat() ' returns a random float value from 0 (inclusive) to 1 (exclusive) - this is essentially the same as Rnd()
' NextBool() ' returns true or false with an approximately 50/50 spread

' create a RandomSource - you could store the seed in your savegame
Local one:RandomSource = New RandomSource(12345)
Print "First"
Print "a "+one.NextInt(1,10) ' a
Print "b "+one.NextInt(5) ' b
Print "c "+one.NextFloat() ' c

' create another one with a different seed
Local two:RandomSource = New RandomSource(67890)
Print "d "+two.NextInt() ' d
If two.NextBool() Print "e true" Else Print "e false" ' e
Print "f "+two.NextInt(7) ' f

' recreate them
one = New RandomSource(12345)
two = New RandomSource(67890)

' as long as the calls are in the same order within each source, you can mix and match them with no conflicts
' these will give you the same values as before, even though the calls for one and two are mixed together
Print "Second"
Print "a "+one.NextInt(1,10) ' a
Print "d "+two.NextInt() ' d
If two.NextBool() Print "e true" Else Print "e false" ' e
Print "b "+one.NextInt(5) ' b
Print "f "+two.NextInt(7) ' f
Print "c "+one.NextFloat() ' c
End

#Rem
First
a 1
b 0
c 0.5431557893753052
d -1945622467
e true
f 4
Second
a 1
d -1945622467
e true
b 0
f 4
c 0.5431557893753052
#End
')


rIKmAN(Posted 2014) [#60]
Sorry - I didn't see this post until you bumped it...

No apology needed mate :)
Not at the moment, the tiled module uses the framework internally for images and of course it uses the Diddy XML parser. By the way a DiddyApp is a normal Mojo App but extended.

Ahh I see, yeah I was hoping there was a simple way to remove it from the internal image use etc, and have it as just a standalone tilemap reader/renderer.
I wrote a simple reader/renderer yesterday for tmx maps, but I've not added multiple layers, object layers etc yet and not sure if it will be worth re-inventing the wheel...yet! :)

Ahh thanks, I did look through those examples but must have missed it, I see the "tileData" part now.
Is there any documentation on the tilemap usage/commands in diddy or just the code examples?

Works fine here for me:
Have you got an example?


It's largish project that I added in the diddy tilemap stuff into, and as soon as I did all the (previously pixelated) graphics became blurred like they were being filtered.
When I removed it, they went back to being pixelated again (which is what I wanted)

I will knock up a smaller test case and report back, might be a couple of days though before I can get back to it.


Samah(Posted 2014) [#61]
I'm hacking the Diddy tilemap stuff now to support raw images. It shouldn't affect existing code.


therevills(Posted 2014) [#62]
It shouldn't affect existing code.

It better not ;)


Samah(Posted 2014) [#63]
Done.

rIKmAN: The tile module now has no hard dependency on the screen framework (but it still works fine with existing code). Try it now with the latest changeset. You'll need to move your tileset image out of the "graphics" directory and into the root of your data directory.


rIKmAN(Posted 2014) [#64]
Hey Samah, thanks and I will try this when I get home later on tonight.

Just a question: you say the tileset image should now be placed in the root of the data directory, is this hardcoded or will the path from the tmx/xml file be used for the path to the tileset images?

Thanks again.


Samah(Posted 2014) [#65]
@rIKmAN: ...will the path from the tmx/xml file be used for the path to the tileset images?

Correct. The difference is that with the framework, it always looks in the graphics directory first. Without the framework it will go by the path relative to the root data directory.


Paul - Taiphoz(Posted 2014) [#66]
Having a bit of a brain fart at the moment, trying to do the bellow.

format_code('
Class gameScreen Extends Screen 'gameScr
Field starfield:Int[20]
End Class

Class anotherScreen Extends Screen
Method blah()
GameScr.starfield[1]=1
End Method
End
')


Hotshot(Posted 2014) [#67]
I was running testGUI from your Example folder but I get compilation error saying Method Component.ApplySkin:Void() is private.


therevills(Posted 2014) [#68]
@Paul - What are you trying to do? Do you want anotherScreen to inherit the array or just access it?

@Hotshot - I'll check tonight.


Amon(Posted 2014) [#69]
@Paul

Instead of making it a field swap the field for Global.

format_code('
Class gameScreen Extends Screen 'gameScr
Global starfield:Int[20]
End Class

Class anotherScreen Extends Screen
Method blah()
gameScreen.starfield[1]=1
End Method
End
')


Paul - Taiphoz(Posted 2014) [#70]
@therevills , yeah I want access to the array from some where outside it's parent class so I could change the content of the array from within my main menu screen for example..
@Amon , yeah it is global but I wanted to know if I could access it from outside of the class directly.


therevills(Posted 2014) [#71]
@Hotshot - I've committed a fix for that issue, thanks for letting us know :)

@Paul, there are a few years to do it - Amon is correct a global would do it, but if you want to be a field I would do it something like this:
format_codebox('Strict

Import diddy

Global game:MyGame

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

Class MyGame Extends DiddyApp
Method Create:Void()
Start(TitleScreen.GetInstance())
End
End

Class TitleScreen Extends Screen
Global instance:TitleScreen
Field starfield:Int[20]

Function GetInstance:TitleScreen()
If instance = Null
instance = New TitleScreen
End
Return instance
End

Method New()
name = "TitleScreen"
End

Method Load:Void()
End

Method Start:Void()
End

Method Update:Void()
If MouseHit(MOUSE_LEFT) Then FadeToScreen(GameScreen.GetInstance())
End

Method Render:Void()
Cls
DrawText(Self.name, 100, 100)
DrawText(Self.starfield[1], 100, 120)
End
End

Class GameScreen Extends Screen
Global instance:GameScreen

Function GetInstance:GameScreen()
If instance = Null
instance = New GameScreen
End
Return instance
End

Method New()
name = "GameScreen"
End

Method Load:Void()
End

Method Start:Void()
TitleScreen.GetInstance().starfield[1] += 1
End

Method Update:Void()
If MouseHit(MOUSE_LEFT) Then FadeToScreen(TitleScreen.GetInstance())
End

Method Render:Void()
Cls
DrawText(Self.name, 100, 100)
End
End')


Hotshot(Posted 2014) [#72]
When Can I have update of Diddy as I like focus on GUI :)


Paul - Taiphoz(Posted 2014) [#73]
thanks will look that over later.. knew there had to be a way of doing it.


Hotshot(Posted 2014) [#74]
Had TestGUI been fixed yet?


therevills(Posted 2014) [#75]
Had TestGUI been fixed yet?


http://www.monkey-x.com/Community/posts.php?topic=8291&post=93274

@Hotshot - I've committed a fix for that issue, thanks for letting us know :)



Lugato(Posted 2014) [#76]
Hi Samah,

I'm trying to use the "gameservice" module from Diddy, to include a Leaderboard in my game. I made all steps in Developer Console, create the "ids.value" file in "res/values" directory of my android project with this XML structure (ID and number_guesses_leaderboard: is valid in my file):
<string name="app_id">11111111111</string>
<string name="number_guesses_leaderboard">XXXXXXXXXXXX</string>

But when I try to build (using the Android Game Experimental), the build process stop and give me the message:

..../android_new/res/values/ids.xml:2: error: Error parsing XML: junk after document element
[aapt]

BUILD FAILED
/android-sdk-mac_x86/tools/ant/build.xml:653: The following error occurred while executing this line:
/android-sdk-mac_x86/tools/ant/build.xml:698: null returned: 1

Can you give a little help to solve this ?

thanks


CGV(Posted 2014) [#77]
About a year ago several people requested a change to Diddy's FadeToScreen method to allow for different types of fade transitions.

Was this feature ever added to Diddy?


Samah(Posted 2014) [#78]
@CGV:
What kind of different fade transitions? Like, colour?

@Lugato:
Can you give us a bit more of your XML? Sounds to me like there might be an extra opening or closing tag somewhere.


CGV(Posted 2014) [#79]
@Samah, check out page 4 of the thread "Diddy - An Open Source Framework - Part 7"
http://www.monkey-x.com/Community/posts.php?topic=4589&page=4

scroll down to post #87 by zoqfotpik and you'll see what I'm taking about.


Samah(Posted 2014) [#80]
Shows how poor my memory is, hey. :)
I'll take a look at it and see what I can do.


Lugato(Posted 2014) [#81]
Hello Samah,

I managed to fix the errors that prevented the build, I had to create the following files in "resource / values" directory:
- ids.xml
format_codebox('
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_id">MyAppID</string>
</resources>
')

- version.xml
format_codebox('
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="google_play_services_version">4242000</integer> # for ironstorm google-play-services version
<integer name="google_play_services_version">4452000</integer> # for diddy version (I'm using this one)
</resources>
')
I read the comment you made in the Ironstorm post, to sign in in OnUpdate and not in onCreate, and adjusted my code.

My #ANDROID_APP_PACKAGE is the same that are in the google play developer console

The game start, but when I click in the button to initialise the Google Play Service the error "null pointer exception" occur again ...


Samah(Posted 2014) [#82]
I assume those "for ... version" comments are only in your post and not in the XML file. :)
I also assume you don't have both of those google_play_services_version lines in the XML, otherwise only the second one will count.
therevills knows more about this, he might want to reply...


Lugato(Posted 2014) [#83]
Samah, you are right in the two points :)

My version.xml:
format_codebox('
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="google_play_services_version">4452000</integer>
</resources>
')
I put the comments because I don't have any information about what files I need to put in the resource directory, to Google Play Service work and what your content .. :(. So I checked the ironstorm module and see what's files are using and what the content in the files.

I made a module that abstract the IOS Game Center and Android Google Service, but I need adjust the error in the Android Layer, before put the module in the forum

Therevills can you give a little help here ?? :)


therevills(Posted 2014) [#84]
I would need to see your code to work out why you are getting a null pointer exception.


Raul(Posted 2014) [#85]
Hi guys,

Recently I found this issue regarding the filesystem.

Asmodean talked about it earleir:

With diddy and brl Import I get an error about an duplicate identifier 'FileStream'.




Diddy's came first... you need to fully qualify which module you want to use.


How exactly do I fully qulify the module I want to use?


Raul(Posted 2014) [#86]
Update on this?

I receive the error message: Duplicate identifier 'FileStream' found in module 'filestream' and module 'filesystem'. if I try to compile on desktop target.
I am using diddy for the filesystem features.

Also I do not import brl in my program.

How to handle this?

Thanks,


therevills(Posted 2014) [#87]
Sorry Raul, I've been pretty busy.

Anyway, I've decided to rename the Diddy's FileSystem to VirtualFileSystem, go get the latest version from GoogleCode.


Raul(Posted 2014) [#88]
many thanks man.


Samah(Posted 2015) [#89]
All,
Over the holidays I replaced Diddy's tweening system with a conversion of the Java Universal Tweening Engine. It's not 100% tested and there's a few changes still to be made, but for the most part it works. You can still use the old system by changing any references to the Tween class to TweenDep. The screen framework will automatically handle both the new and old systems. Just update to the latest changeset to use it.

Java version:
https://code.google.com/p/java-universal-tween-engine/

Once the system is fully tested I'll create an example file and add documentation.

Samah


Paul - Taiphoz(Posted 2015) [#90]
Not checked this thread in a while and just saw ligado's post about a gameservice module part of diddy, is there any example source for using this yet in the docs? I'm also a bit hesitant to just update my out of date version of diddy for fear of braking something lol, will test an update later tonight if I have time.


Samah(Posted 2015) [#91]
@Taiphoz: ...gameservice module part of diddy...

You'd have to ask therevills about that, he added that module.
@Taiphoz: I'm also a bit hesitant to just update my out of date version of diddy for fear of braking something lol,

This is what version control is for. ;)


therevills(Posted 2015) [#92]
So with the upcoming closure of Google Code, what are peoples preferences? BitBucket or GitHub? (If we move to GitHub, it will mean moving to GIT).

http://google-opensource.blogspot.com/2015/03/farewell-to-google-code.html


Samah(Posted 2015) [#93]
My preference is GitHub, simply for the fact that Monkey and most of the community frameworks are too.


CGV(Posted 2015) [#94]
GitHub please. Mainly for the reason Samah mentioned. I think most of us are more familiar with GitHub since everything we already use is hosted there.


Samah(Posted 2015) [#95]
therevills if we decide to go down the GitHub path, do you want me to do the migration? I already have an account with some public repositories.


Samah(Posted 2015) [#96]
Done.

https://github.com/swoolcock/diddy


therevills(Posted 2015) [#97]
Thanks Samah, I was going to wait a bit for more replies... We weren't in too much of a rush 😉

I'm still keen on hearing what other users think. But it's good to know its there.

I want to clean it up too, maybe separate the extern code totally out of it to another module.... But as you know I'm quite busy.


Samah(Posted 2015) [#98]
But the "Export to GitHub" button did absolutely everything for me short of make me a cup of tea. XD

Edit: To be honest, I clicked the button to see how many steps were required, and as soon as I logged into GitHub it was done!


Derron(Posted 2015) [#99]
The current diddy implementation of "Libgdx-Atlasloader" does not work for me.

I wrote "'Ronny" to things I adjusted:

format_codebox('
Method LoadLibGdxAtlas:Void(fileName:String, midHandle:Bool=True, readPixels:Bool = False, maskRed:Int = 0, maskGreen:Int = 0, maskBlue:Int = 0)
Local str:String = LoadAtlasString(fileName)
Local all:String[] = str.Split("~n")
Local spriteFileName:String = all[0].Trim()
'Ronny: my libgdx adds a new line before name
Local skipFirstLine:Bool = False
If all[0].Trim() = "" then spriteFileName = all[1].Trim();skipFirstLine = True

Local pointer:Image = LoadImage(path + spriteFileName)
AssertNotNull(pointer, "Error loading bitmap atlas "+ path + spriteFileName)
Local atlasGameImageName:String = SaveAtlasToBank(pointer, fileName)

Local line:String = ""
Local i:Int = 4

'Ronny: add this line too
If skipFirstLine then i += 1
'Ronny: also for me there are 4 lines between title + first
'sprite while diddy assumes 3 lines
i += 1

Local xy:String[] =["",""]
Local debug:Bool = False
While True
' name of the image
line = all[i].Trim()
If debug Then Print "name = "+line
If line = "" Then Exit
Local name:String = line
'rotate
i+=1
line = all[i].Trim()
If debug Then Print "rotate = "+line
Local rotate:String = line
' x and y
i+=1
line = all[i].Trim()
If debug Then Print "x and y = "+line
xy = line[ (line.FindLast(":")+1)..].Split(",")
Local x:Int = Int(xy[0].Trim())
Local y:Int = Int(xy[1].Trim())
' width and height
i+=1
line = all[i].Trim()
If debug Then Print "width and height = "+line
xy = line[ (line.FindLast(":")+1)..].Split(",")
Local width:Int = Int(xy[0].Trim())
Local height:Int = Int(xy[1].Trim())
' origX and origY
i+=1
line = all[i].Trim()
If debug Then Print "origX and origY = "+line
xy = line[ (line.FindLast(":")+1)..].Split(",")
Local origX:Int = Int(xy[0].Trim())
Local origY:Int = Int(xy[1].Trim())
' offsets
i+=1
line = all[i].Trim()
If debug Then Print "offsets = "+line
xy = line[ (line.FindLast(":")+1)..].Split(",")
Local offsetX:Int = Int(xy[0].Trim())
Local offsetY:Int = Int(xy[1].Trim())
'index
i+=1
line = all[i].Trim()
If debug Then Print "index = "+line
Local index:Int = Int(line[ (line.FindLast(":") + 1) ..].Trim())
i+=1
Local gi:GameImage = New GameImage
If index > - 1
name += index
End
If debug
Print "name = " + name
Print "x = " + x
Print "y = " + y
Print "width = " + width
Print "height = " + height
Print "origX = " + origX
Print "origY = " + origY
Print "offsetX = " + offsetX
Print "offsetY = " + offsetY
Print "index = " + index
End

gi.name = name.ToUpper()
gi.image = pointer.GrabImage(x, y, width, height)
gi.CalcSize()
gi.MidHandle(midHandle)

'Ronny: offset of each image is defined differently!
' libgdx "offsetX" is what was cut from "left"
' libgdx "offsetY" is what was cut from "bottom"
' (because libgdx has 0,0 in bottom left).
' libgdx encodes the "left"/"top" portions in
' origY and height
' -> so offset for top is:
' offsetTop: (origY - height) + "bottom"
gi.offSetX = offsetX
gi.offSetY = (origY - height) - offsetY

gi.atlasName = atlasGameImageName
gi.subX = x
gi.subY = y
gi.readPixels = readPixels
gi.SetMaskColor(maskRed, maskGreen, maskBlue)

Self.Set(gi.name, gi)
Wend
End
')

If thats ok with you I would fork diddy and send out pull requests with my patches then.


Another flaw is the volume adjustment during screen changes. If someone does not use diddy's sound functions it should not manipulate global things.

In other words: diddy fades out and in - but does not care of the "old volume". So Diddy just needs to store volumes of all channels before fading out - and then fade in to this old value (in my jam entry I recognized that because I use a volume of <> 1 and after fading volume was bigger than I wanted).


bye
Ron


Samah(Posted 2015) [#100]
Derron: Before any code changes are made to the atlas loader, can you give an example of where the current Diddy code breaks?

As for the volume thing, that does indeed sound like a bug. I'll look at it tonight.


therevills(Posted 2015) [#101]
Hey Ron, could you test the included example for loading in the Atlases with your changes:

https://code.google.com/p/diddy/source/browse/examples/SpriteAtlas/spriteAtlas.monkey

I'm not too keen on the LibGdx format, I prefer either JSON or XML.

Also I read you had issues with the loading screen and had to do your own, the loading screen was done really quickly and there is a way to use it currently but it isn't straight forward. We'll have a look at your way to see which is better :)


Samah(Posted 2015) [#102]
therevills: Ron's proposed changes look to be very implementation-specific. I would prefer that some smarts be put in to skip all unwanted newlines rather than a binary yes/no for a single line.


Derron(Posted 2015) [#103]
Therevills asked me in the blitzmax.com-forum what I missed from Diddy during the jam (as I mentioned I missed some things)

All below is based on my fresh and very limited knowledge about Monkey - so things might exist somewhere and I just do not know it. Same for the diddy-framework.

----

@therevills
All basic things I had to implement on my own are things it missed :p

--[ * ] --
a proper music-crossfader: to enable this the sound engine must use some kind of "music channels" or "protected channels". So if you play 31 sfx simultaneously, the two music channels (needed for crossfading) are not touched -> implemented in "jam/resources.monkey: TSoundManager"

--[ * ] --
music loops (not really needed in a framework - but in mobile dev this lowers total file size) -> implemented in "jam/resources.monkey: TMusicSound" (not implemented in a good way but it works)

--[ * ] --
I miss a way to measure "activetime". Millisecs() returns the time since initial load, but for html5 this runs even with the app being suspended. Why? Music stops during suspension ... but my crossfader crossfades as soon as the time of a "music" (which might be a loop of 3 samples) is run out. Having such a helper is simpler than listening to various events

--[ * ] --
ChannelVolumes are touched during fading screens (if enabled) but not reset to the previous value

--[ * ] --
LoadingScreen does not work

There are some other things I would change, but this could happen in each individual app - eg "SpriteAnimation" uses constant frame times ... In my BlitzMax-Game I have setup'ed idle animations with individual frametimes - eg to blink with your eyes. Also this allows to add a bit of randomness: [open 200ms, closed 20ms, open 250ms, closed 25ms, ....]. I'd better call that "feature request".


@LibGDX
I am with Samah, my fixes just did it the same way as the original loader (and because I did not want to use time for this during the jam). The better alternative is to use everything in the file the loader is capable of recognizing.
I will try to adjust it properly and do a pull request on github then...


@Loading screen
I am not deep enough into Monkey (need Pro for it :p). There are multiple options do handle things in a loader. In my BlitzMax game/framework I load my assets using a big "to load resources"-table containing tresource-containers, these containers abstract individual "load"-functions so all my resources implement loading on their own (they then call LoadImage(), Load an xml and append new resources, ...).
The AssetManager is run on every loop of the app (so you could dynamically add new resources during the game). The AssetManager has a "needed for start" resource table which has to get "emptied" before a loading-bar could get displayed somewhere (means: it loads eg mouse cursor, basic font and loading bar ...)

Every loaded resource sends out an event with the resource object and information about total loaded assets and current asset count. So the event contains everything needed for other objects without the need to know the asset manager.

Ok, so how to implement a loading screen there? If you do not use the "load while ingame" feature you have to have a loop calling the AssetManager until there is nothing more to load. But contrary to the current Diddy Loading screen, you have of course to Render your Loading screen inbetween.

Diddys logic:
- set screen to loading screen
- LoadResources()
- - load image 1
- - load image 2
- - load image 3
- first calls to Update()/Render() (results in loading being finished then already)

Needed logic is:
- set screen to loading screen
- loop calling Render() (or Update() - you know the best call of both) of the loading screen
- - LoadNextResource()
- - If AllResourcesLoaded() 'done separately because assets could add more assets or delay loading (dependencies!)
- - - refresh "loading bar state"
- - else
- - - finish with loading screen and fade to desired one
- render/update-call finished

BUT - like said I do not know enough about Monkey, I have read there is some kind of "onLoad"-call when things get loaded, in this case the portion done in Render()/Update() should not be needed. But if that worked - the current loading screen implementation should work fine - which doesn't

Aboves approach does not work well for async loading, you might need to introduce a "AllResourcesFinishedLoading()" check too.

My described implementation can be found here:
https://github.com/GWRon/Dig/blob/master/base.util.registry.bmx
It is of course not flawless too - but maybe you find problems there or get inspired... who knows. (I got inspired by many things of Diddy without using it - just looking at the code/approach in the sources).

bye
Ron


Derron(Posted 2015) [#104]
Ok, made a fix proposal for "LoadLibGdxAtlas".

Fixes variation in config orders and properly adjusts "offsetX" and "offsetY" (see my comment in the source code).
Because of the added flexibility I naturally needed a bit more lines of code - feel free to truncate even more (eg. reuse variable names - which I added to keep things clear).


I thought I could symlink the diddy-src-diddy-directory to Monkey/modules/diddy ... but guess what, Monkey has the same problem as BlitzMax regarding file paths (it uses the "real path" instead of first trying the given one). This eg. leads in our case to an error because Diddy has own exceptions and Monkey base too... But as said, without having Pro I wont furtherly into it (in BlitzMax I believe it is in the Brl.mod/blitz.mod core - the one giving back Paths).

So for now I have to have 2 copies: the one I use, and the one I do the fixes in - or how to use the whole diddy-directory in the "modules" folder?


bye
Ron


Samah(Posted 2015) [#105]
Thanks, I'll go through it tomorrow and make a few small changes before I merge. Need to test it though.

You can give the Monkey compiler a list of module directories, they don't have to all be in the same place. Open config.winnt.txt (or whatever OS) and check out the MODPATH variable.

As an example, here's mine:
format_code('MODPATH="${MONKEYDIR}/modules;${MONKEYDIR}/modules_ext;D:/Shane/Dropbox/Repositories/DiddyHg/src;D:/Shane/Dropbox/Repositories/junglegui;D:/Shane/Dropbox/Repositories/fontmachine"')


Derron(Posted 2015) [#106]
Isn't this a bit hmm "inconvenient" - instead of just using symlinks the correct way (inconvenient in the way of being invisible when looking at the module-directory, invisible regarding portable installs ...). But at least it is an option.

@changes
You could do this, I made a new branch so this is unproblematic if you decline the patch.


bye
Ron


Samah(Posted 2015) [#107]
@Derron: Isn't this a bit hmm "inconvenient"...

I don't see a problem with it. You'd do the same with include and lib directories in a C project.

...instead of just using symlinks the correct way...

Windows symlinks are a lot harder to manage than their *nix equivalents. Most Monkey developers will not have (nor should they need) the knowhow to do this.

By the way, you don't need to put your name in source code comments. GitHub will tie the changeset to your email/GitHub account, so it's unnecessary.


Derron(Posted 2015) [#108]
@include
I do this in a "per file" base, not in a "per compiler-environment-installation-base". When doing everything in with the second variant (aka putting things to the "module" directory) the for me ideal solution would be to allow symlinks. And I do not bother if this is "harder" or "easier" on Windows - if something is possible, and for more than one user a convenient approach, it might be tried to get it working. But we do not want to derail the thread, so we just leave that open - okay?


@name in source code
I got used to read names of contributors in my OSS if they are not sure whether they did thingsk correct, or if they want to have a personal explanation of things in it so other see: ahh ok, no general way of doing but a very personal approach. Of course maintainer of the main project may remove such things.

@changesets
I think "git" itself does that already. GitHub "just" adds the convenient way of "pull requests".

But yeah, I will try to remember your hint and leave my name out of the next commit (especially if this is is "common sense" your the diddy-project).


bye
Ron


Derron(Posted 2015) [#109]
I tried to patch the sound-portion of the diddy framework. But I was surprised there is no "GetChannelVolume()" available in Monkey. Am I right that there is no way to get the current channel volume? I mean seriously: is there a way to do that?

If not it seems the core needs to get at least a patch to store the initial value of a channel volume (1.0) and on each SetChannelVolume adjusts this array entry. This allows easy integration of a GetChannelVolume()-function.
If that is done somewhen, it is very easy to take care of volume changes in diddy.

Another little unneccessary thing in diddy is done in "ScreenFade.CalcRatio()"

The function is only called in the "Update()"-Method of the same class. This "Update()" already adjusts volume of all 33 channels (0-31 + 32 for music). It does that on the calculated ratio. So any previous adjustment in "CalcRatio()" is overridden.

format_code('
Method CalcRatio:Void()
ratio = counter / fadeTime
If ratio < 0 Then ratio = 0
If ratio > 1 Then ratio = 1
If fadeOut Then ratio = 1 - ratio
End
')

Should be all the CalcRatio() method should do. At least - until I did not understand the previous version properly.
I tried my current code and it seems to work flawless without too -- but of course I cannot check everything to be absolutely sure (that is why I just propose it here than making a push to my fork).

For now I patched my "mojo/audio.monkey" to store the volumes. I added "GetChannelVolume(channel)" and "GetMusicVolume()". Using these new functions I appended something to the screen fader. When the screen fades out it stores the current volume and uses this for its volume adjustments. I needed to do it that way, because screenfaders are used 2 times instead of a single one with "fadeIn" and "fadeOut" methods. I thought of using FadeToScreen() to store volumes in the screenfade, but this a) isnt encapsulated properly and b) isnt the only way to change the screen.
So to make it properly I would opt for multiple things:
- Monkey/mojo needs GetChannelVolume() and GetMusicVolume()
- Diddy-Screenfade needs something which is called _once_ per screen transition (so on initial FadeIn of the app, and on FadeOuts on each screen change) - this is then the function to attach the volume-backup (and volume-array-initialization)


bye
Ron


Samah(Posted 2015) [#110]
I got used to read names of contributors in my OSS if they are not sure whether they did thingsk correct, or if they want to have a personal explanation of things in it so other see: ahh ok, no general way of doing but a very personal approach. Of course maintainer of the main project may remove such things.

You can certainly (and should!) put comments in the code explaining how it works, but my point is that you don't need to put your actual name there. That's the only comment I'll remove, the rest are fine.

I think "git" itself does that already. GitHub "just" adds the convenient way of "pull requests".

Git/Hg/Subversion and pretty much every other version control tool will tag a commit with the email or name of the person who made it. GitHub then ties it to your GitHub account based on the email.

But yeah, I will try to remember your hint and leave my name out of the next commit (especially if this is is "common sense" your the diddy-project).

It's common practice at my place of work, too.


Derron(Posted 2015) [#111]
Updated my pull request: removed my name and reformatted the comments to fit into the "72 chars per line" suggestion many editors have (you might know them from the commit-windows in your GUI-VCS-Tool).

Hope this saves some work for you (copy paste the code and adjusting the comments).

If you have any improvement to make for my suggestion regarding "audio channels", feel free to drop a line:
https://github.com/blitz-research/monkey/pull/76
Like said ... am not into Monkey (yet) so I do not know much about better ways to approach this subject.

bye
Ron


Samah(Posted 2015) [#112]
Unrelated update:
I'm currently working on DiddyMap and reworking some of the containers framework. In testing DiddyMap I unwittingly found a serious bug in DiddySet. As in, it doesn't work at all. I was unaware that creating custom Set classes requires you to pass a Map object to the constructor. Originally there was no proper way for me to automate this, since Map requires a subclass to implement Compare. Now that DiddyMap exists, I can fix it.
Here's the catch: To use DiddyMap or DiddySet, you MUST make your generic type implement IComparable or assign an IComparator to the Map/Set. This is still more convenient than having to extend Map or Set every time you want a new generic.

I have also created a DiddyDeque that extends the recent(ish) Deque class. It adds all the functionality of IContainer to Deque, such as sorting and predicates, and much of the functionality from Stack/List/Set that doesn't exist in Deque (such as adding/removing arbitrary elements). I've also added Deque methods (AddAll, RemoveAll, etc.) to IContainer and therefore all its subclasses (DiddyStack, DiddyList, DiddySet), including initialisation constructors.
format_code('' regular monkey Deque
Local d:Deque<Foo> = New Deque<Foo>
' creates a DiddyStack initialised with the contents of the Deque
Local s:DiddyStack<Foo> = New DiddyStack<Foo>(d)')
Gotta clean up the code a bit and add some doco, then I'll push to GitHub.


Samah(Posted 2015) [#113]
DiddyMap/DiddyDeque pushed. Feel free to break it. :)


k.o.g.(Posted 2015) [#114]
Will diddy updated to be compatible with glfw3?


Samah(Posted 2015) [#115]
@k.o.g.: Will diddy updated to be compatible with glfw3?

I never thought to check that... I'll take a look tomorrow.


therevills(Posted 2015) [#116]

@k.o.g.: Will diddy updated to be compatible with glfw3?

I never thought to check that... I'll take a look tomorrow.



I think it'll need a new native file and the native functions have to be recoded to work with GLFW3...


Samah(Posted 2015) [#117]
@therevills: I think it'll need a new native file and the native functions have to be recoded to work with GLFW3...

Off you go then... ;)


Nobuyuki(Posted 2015) [#118]
Hi! I've done some work on the Tiled loader to remove its dependency on Diddy. It seems pretty thorough, but there are a few portions that don't seem complete, so I'm curious to know:

* Does it truly support layer wrapping? (I've tried adding wrap_x/wrap_y properties to a layer in the example map and it didn't seem to wrap when rendering...)
* If it does support layer wrapping, does this jive well with parallax?
* Did map/layer scaling in render actually ever get completed?
* Was the code touched anytime recently? The declarative style is very java-like, and some usage of Diddy containers can now be done in Monkey.

Since my project doesn't need isometric maps, these questions apply only to orthogonal maps.

I've also changed the xml dependency from Diddy's to skn3's xml, and might incorporate some of the new node-fetching features in it to reduce the amount of code used for the loader and prepare it for an eventual separate release. However, I'd like to avoid doing any extra work if I can avoid it, hence the questions :)


Samah(Posted 2015) [#119]
Hi! I've done some work on the Tiled loader to remove its dependency on Diddy.

Cool! What changes have you made, exactly? The importing of "framework"?

* Does it truly support layer wrapping? (I've tried adding wrap_x/wrap_y properties to a layer in the example map and it didn't seem to wrap when rendering...)

It should do. If it's not, that's a bug (raise an issue).

* If it does support layer wrapping, does this jive well with parallax?

Wrapping should be independent per layer.

* Did map/layer scaling in render actually ever get completed?

I don't think so, but it's something I never had time to do.

* Was the code touched anytime recently? The declarative style is very java-like, and some usage of Diddy containers can now be done in Monkey.

What do you mean by "java-like"? Which usage of Diddy containers "can now be done in Monkey"? Note that the new containers module extends the core Monkey classes anyway.

I've also changed the xml dependency from Diddy's to skn3's xml...

I'm not so keen Diddy having a dependency on another 3rd party framework, to be honest. I have in the works an implementation of SAX, anyway, so that should improve performance immensely.

...prepare it for an eventual separate release

Fork and pull request!


Nobuyuki(Posted 2015) [#120]
ool! What changes have you made, exactly? The importing of "framework"?


Haha, no, that's the exact opposite of what I wanted to do. Framework's the core of Diddy! I don't want to dig in there, so off it went. All references to DiddyStack and AssertError are gone and replaced with brl equivalents (where applicable). References to GameImage have been removed. StripDir() now references brl.filepath.StripDir(). diddy.xml has been replaced by skn3's xml. (That last one was a bit annoying seeing as how skn3 gave some public properties lowercase names!!!)
https://www.diffchecker.com/qknvucb5

It's still a bit messy; with the new changes to skn3's xml from the other day, it's likely that turning nodes into an internal list of properties can be simplified. Furthermore, some references to check for the existence of diddyGame to find a preloaded resource have been removed. I think that there's a better way to do this, namely having specific points where someone can say "look for an image source here first" without having to override the entire loader.


[regarding wrapping] It should do. If it's not, that's a bug (raise an issue).



I'll check it with the official example first to make sure it's not my code or something I did when removing the diddy framework references.

What do you mean by "java-like"?


format_code('Field layers:DiddyStack<TileMapLayer> = New DiddyStack<TileMapLayer>')

^ declarations like this and longer are all over the file; I'm surprised there's no "late-bound" syntax here to save a few electrons :)

The extra encapsulation between the xml loader and the parser seems pointless when using skn3's xml, but perhaps makes more sense when using diddy.xml for other things. I did a half-assed job of removing it, but the root node stuff and assembling the property list seems like places the code can be trimmed down some more.

Also the assertions are a bit "strict", I was thinking of letting some of them print a warning to debug console instead and let the program error out if it couldn't recover (exposing a more relevant stack trace just in case the error assertion was premature or caught the wrong thing), but there weren't too many places where this seemed like it would be helpful.


Which usage of Diddy containers "can now be done in Monkey"? Note that the new containers module extends the core Monkey classes anyway.

The only thing in DiddyStack which was used here was FillArray, and I find its functionality a bit strained now that stack.data[] is exposed. It was used only once in this file, and was pretty easily replaced.

I'm not so keen Diddy having a dependency on another 3rd party framework, to be honest. I have in the works an implementation of SAX, anyway, so that should improve performance immensely.


what's SAX? I swapped out the dependency because I didn't want the tilemap loader to have a dependency on Diddy, lol. Outside of diddy I believe skn3's xml is the most used, and so I've used it here (and indeed have already done so in my own framework, where json can't be used)


Samah(Posted 2015) [#121]
@Nobuyuki: All references to DiddyStack...

Generally I only use DiddyStack within the framework if I need extra functionality. If it's only using vanilla functionality, it can be safely replaced with Stack. It extends Stack for this exact reason.

@Nobuyuki: ...and I find its functionality a bit strained now that stack.data[] is exposed

This is the one of the reasons it existed, and yes you're correct that it's no longer required.

@Nobuyuki: References to GameImage have been removed...

That was there for backward compatibility, because at one point the renderer required you to use the screen framework. I changed it to handle raw Images if you don't use GameImage.

@Nobuyuki: That last one was a bit annoying seeing as how skn3 gave some public properties lowercase names!!!)

Yeah, I try to make all properties start with uppercase.

@Nobuyuki: ...declarations like this and longer are all over the file; I'm surprised there's no "late-bound" syntax here to save a few electrons :)

Personal taste, due to (as you stated) Java 5/6 requiring it. Java 7+ has the diamond operator so that you can use inferred generics (albeit the other direction).
In Monkey you would do this:
format_code('Field layers := New DiddyStack<TileMapLayer>')
In Java 7+ you would do this:
format_code('Stack<TileMapLayer> layers = new Stack<>();')
I tend to dislike inferred variable declaration (especially fields, locals are generally ok).

@Nobuyuki: what's SAX?

https://en.wikipedia.org/wiki/Simple_API_for_XML
Basically the developer creates a class that dynamically handles XML tags as they're read, rather than reading the entire thing into memory.
Much much much lower memory requirement, and it lets you stream multi-megabyte XML from disk or network rather than downloading the entire file at once.
The downside is not being able to use any kind of Xpath-style magic, but it means that your data (map format, etc.) is not directly tied to an XML document or its elements.

@Nobuyuki: I didn't want the tilemap loader to have a dependency on Diddy...

But the Tiled loader is part of Diddy. :)
Otherwise you may as well strip every submodule of Diddy into its own directory. Also, unless you import reflection, Monkey will strip anything it doesn't need.
People seem to have this mindset that to use part of Diddy you need to use all of it. This is true in some cases due to poor encapsulation on my part, but it's one of those 20:20 hindsight things where you learn from your mistakes. If I were to write Diddy 2 (maybe I already am?) it would be a lot cleaner.

@Nobuyuki: Outside of diddy I believe skn3's xml is the most used...

I wouldn't have a problem with this if skn3's xml was distributed with Monkey, or if Monkey had a nice Maven-style dependency management system.

Something that might be awesome is for me to work with Skn3 to make both XML parsers work with a common interface, so that the developer can choose which engine they want to use.
For example, Diddy's XMLElement and Skn3's XMLNode could be changed to implement IXMLNode which provides method declarations that both parsers understand.

If you'd like I can add you as a contributor, just make sure to put your modifications on a separate branch for now, and once we've decided on final changes it can be merged into develop.


Nobuyuki(Posted 2015) [#122]
Otherwise you may as well strip every submodule of Diddy into its own directory.


A difference in preferences, I suppose! I've kept my framework modular to the point that there's been one or two times where I've had to suck it up and have duplicate code because it was "just too clever" for a transport object to do justice... Normally though, I do pretty much separate everything out into folders like you say. The Tiled loader is really neat and probably deserves its own module. So would your XML thing if you get that SAX thing working.


Something that might be awesome is for me to work with Skn3 to make both XML parsers work with a common interface, so that the developer can choose which engine they want to use.
For example, Diddy's XMLElement and Skn3's XMLNode could be changed to implement IXMLNode which provides method declarations that both parsers understand.


The only thing really keeping skn3's xml parser working with yours are a couple differences in type names that could be overcome with a transport object, and that (frankly really annoying) change of some public properties to lowercase instead of the usual Sentence case. Just guessing here, but those are maybe the way they are for backwards compatibility from an earlier time when the original variables were completely exposed in his code.

You're probably more likely to get cooperation by using direct-casted transport objects than a unified Interface; you might have to bite the bullet on that one even if it's less "safe". (I had this same issue when trying to unify sorters under an interface with skn3 -- he really insisted on having part of the implementation exposed (ascending/descending:Bool) in the function definition, despite that not jiving with things like collating and unicode locale-specifc sorting. Hurrgh!) That's just the thing about personal preference in coding styles, though.


If you'd like I can add you as a contributor, just make sure to put your modifications on a separate branch for now, and once we've decided on final changes it can be merged into develop.

If it's possible to somehow start a separate repo or fork for just the tile portion so I can make lazy pull requests upstream, I'd be okay with it. However I don't plan on doing too much work, so it may be just as easy once all's said and done to just re-incorporate it yourself. I've never really screwed around with Git too much to know about how convenient forking is -- merging branches in the same repo, yes. Forking to separate repos and sending stuff back upstream, no idea.

My changes are a bit "radical" to easily re-merge a separate branch, since all of Diddy's gone save for base64 and tile (renamed tilemap for my project) and put into different folders...


Samah(Posted 2015) [#123]
@Nobuyuki: If it's possible to somehow start a separate repo or fork for just the tile portion so I can make lazy pull requests upstream, I'd be okay with it.

Easily done. You can just directly edit a file in the master repository on GitHub and it will automatically fork it for you. Once you're done, click the big green "Create pull request" button.

@Nobuyuki: ...since all of Diddy's gone save for base64 and tile...

Then it doesn't really matter if it's still in the diddy package. :)


Nobuyuki(Posted 2015) [#124]
I've filed a bug report about the wrapping, with a link to a file which utilizes wrapping.


Samah(Posted 2015) [#125]
Cool, I'll check it out.


Samah(Posted 2015) [#126]
Hmm... looks like it's something to do with the wacky way I implemented screen boundaries. It's something I've been wanting to fix for ages, but backward compatibility etc.
I may have to rewrite the rendering engine to fix it. No biggie, I guess, I'll just have to be careful so that people will only have to make minor changes to their code.


Nobuyuki(Posted 2015) [#127]
Hopefully whatever the rewrite does still deals with rects (and popping the matrix state, if necessary); dunno much about the screen framework but if it gets tied heavily into that, it may be a bit harder to interop with it again

Was the problem more complicated than just how the render rect was specified?


Samah(Posted 2015) [#128]
@Nobuyuki: Was the problem more complicated than just how the render rect was specified?

Kinda... originally it was designed such that the RenderMap call expected the screen boundaries, and you'd do the offset manually in DrawTile. Since the base RenderMap call knows nothing about where the map starts and ends, it can't do wrapping properly.
I'm rewriting it such that RenderMap accepts the offset as well as the target rectangle, and I'm fixing the scaling in the process. DrawTile should be automatically handled for you so you only need to override it if you want to do something special.


Nobuyuki(Posted 2015) [#129]
Let me know when you've made an update, I look forward to seeing the results :)


therevills(Posted 2015) [#130]
Samah is currently having some RL issues, it may take a bit of time. :(


Samah(Posted 2015) [#131]
RL issues all good now, back to Diddy. ;)
Just working out some glitches with the scaling, then I'll update it. The next thing I'll do is strip out most of the XML stuff and have the loader in a separate module. Now that there's a working SAX implementation it should be a lot easier to do.

Edit: Done, in theory. Update to latest develop.


Nobuyuki(Posted 2015) [#132]
haven't tested it yet, but looks good so far. There are a lot of local variables which Jungle flags as hiding local variables in an enclosing block. These variables are defined near the top level of the render method, but don't appear to be used in the outside block. The diffs show that you added a lot of these locals in the latest update. Was this for safety purposes (variables living outside their scope)? When they're re-declared like this in the nested blocks, the enclosing block declarations appear to become useless. My bad, I missed a line in the diff where you got rid of the upper block level locals.


Nobuyuki(Posted 2015) [#133]
A couple things:

1. Wrapping still doesn't appear to work on my end, in either the example or in my project's test map.
2. I've removed the diddygame references again, particularly the one at line 619. I don't believe this causes any problems, but......
3. The routine now breaks when combined with an autofit routine. I'm assuming this is because when doing RenderLayer() either the operations after PushMatrix() don't respect the global matrix the way it was before, or the viewport calculations don't take into effect matrix state at all, or both. I have yet to pin down where the problem is, but I'm tweaking it right now. Tile rendering boundaries however are currently all kinds of messed up when I resize my window using AutoScale, even when the viewport appears to match the scissor rectangle. EDIT: I've managed to fix it on my end, adding a pull request but no guarantees it will work with whatever diddy uses to scale screens....

P.S. The scaling now seems to work. Nice! When combined with wrapping, it would be pretty neat to support layer scale metadata so that we can make even more convincing parallax scrolling effects.


Samah(Posted 2015) [#134]
At a glance I'd guess that your GetMatrix call is probably all it needs, and the screen ratio stuff can be totally ripped out. Also, wrapping works on my end...
I'll take a look tonight.


Nobuyuki(Posted 2015) [#135]
Oh, I think I'm using wrapping differently than you are. It looks like you're looking for wrap properties on the map level, whereas I'm setting the properties on the layer level, and wrapping seems to be done on the map level as well, but not on the individual layer level!


Nobuyuki(Posted 2015) [#136]
I've updated my pull request to the develop branch to include individual layer control for wrapping.


Samah(Posted 2015) [#137]
...and wrapping seems to be done on the map level as well, but not on the individual layer level!

Wow... that was a pretty dumb mistake. XD
Thanks. :)

Edit: Merged.


Nobuyuki(Posted 2015) [#138]
Cool.

One last thing I did, I added better support for relative and hardcoded paths into the thing, since the diddy example I believe relies on atlases. I haven't gotten around to messing around with my version to support atlas overrides, yet, but the non-atlas support in the file is a bit fragile and likes to explode on relative paths due to the use of StripDir(). Since the fix is not something I'm comfortable putting directly on the diddy fork, I'm providing you a diff between the previous version of my fork, and the version with the fixed graphicsPath support. Please consider adding it, or adding a routine to check if the file exists in a few locations before crapping out:

https://www.diffchecker.com/g9rhpr0w

the block near line 429 (or 227) is where I'd normally do the "safe" check but since the preloader and attribute crap is all separated out into other objects, doing this would break your encapsulation philosophy a bit, since checking if a file exists would require checking for null using mojo's LoadImage, unless you use another module :P


Samah(Posted 2015) [#139]
I've just done a minor refactor on the tile module to allow the usage of Skn3's XML module without importing diddy.xml.
Since it imports framework it will still get the Diddy XML module, but I'm working on removing that dependency too.
The catch is, you have to import and extend DiddyTiledTileMapLoader or Skn3TiledTileMapLoader. Neither of them are automatically imported by tile.monkey, to avoid dependencies.

format_code('Import diddy.tile
Class MyLoader Extends TiledTileMapLoader
' ...
End')
Becomes:
format_code('Import diddy.tile
Import diddy.tile.diddyloader
Class MyLoader Extends DiddyTiledTileMapLoader
' ...
End')
Or:
format_code('Import diddy.tile
Import diddy.tile.skn3loader
Class MyLoader Extends Skn3TiledTileMapLoader
' ...
End')


Samah(Posted 2015) [#140]
"Fixed" an issue with the XML readers. LoadMap now only supports direct XML strings, not filenames. This is because LoadString() is in Mojo for everything but stdcpp and glfw.
I've also applied this to Diddy's XML parser, so that ParseFile is essentially disabled unless you provide the preprocessor statement #XML_USE_LOADSTRING=True in your game. I removed a bunch of dependencies in diddy.xml too, such as the screen framework and container modules. It's just about standalone now.


Samah(Posted 2015) [#141]
As mentioned here: http://www.monkey-x.com/Community/posts.php?topic=8816&post=109218
I've removed the screen framework dependency from the tile engine, and fixed some compilation errors.


Nobuyuki(Posted 2015) [#142]
any suggestions on how to reduce/eliminate stitching when scaling the map? I was thinking of disabling image filtering for my project, but I'm wondering if there'd be a fast way to batch the tiles without having to go to mojo2 for draw surface support.


Samah(Posted 2015) [#143]
Hmm.... I can only think of manual pixel manipulation, or maybe use raw OpenGL commands to load/draw the tileset. Then you could manually set the texture filter for the tileset to nearest neighbour.


Nobuyuki(Posted 2015) [#144]
I wonder if increasing a tileset's padding in Tiled while extruding out each tile's edge pixels could possibly work. Not sure if this would translate to less visible seams, but it's kinda a PITA to do this without a special tool like TexturePacker. Annoying moreso because the bin-packing routine doesn't have a high level of control over what goes where...


Samah(Posted 2015) [#145]
As per a suggestion from therevills, I've moved the Diddy examples to a separate repository.
Core: https://github.com/swoolcock/diddy
Examples: https://github.com/swoolcock/diddy-examples


Nobuyuki(Posted 2015) [#146]
I've written a tool to extrude tiles out in a tileset. However, when specifying spacing and margin parameters for a tileset, it causes Diddy's calculations to chuff up and ultimately crash with an array index out of range error. Here is an example map with an extruded tileset:

https://www.mediafire.com/?omccqkloplaf9gj

Can you confirm the bug?


Samah(Posted 2015) [#147]
Yeah broken on my end too. I'll take a look at it.


Samah(Posted 2015) [#148]
Fixed. It was calculating the tile count incorrectly. Note that scaling still looks a bit strange, but I think that might be a combination of a poor tileset and Mojo's image filtering. It's certainly a lot better than it was!


Nobuyuki(Posted 2015) [#149]
I've added some bugfixes to renderer and diddyreader. There should be two pull requests pending.


Nobuyuki(Posted 2015) [#150]
Been cracking at it again, this time writing a custom TileMapLoader to turn dynamically-generated dungeons from an array into a fully-fledged tilemap based on some default metadata. What an absolute pain in the ass! Anyway, because the maps have to have a set size, and my generator tends to wander around a lot, I decided to (at first) take the "safe" approach and make really huge arrays that are sparsely populated.


I didn't expect it, but it seems that this brings my game's speed to a crawl. Doesn't tilemap cull rendering that is out of the viewing plane? I'm guessing this isn't my problem, since I'm missing my update target as well on the large maps (150x150 tiles, 48x48px each, 2 layers), not just my render target. What is looped through the most here? I noticed that I have to make a lot of TileMapCells for everything to display properly. Maybe ?? Any advice you may have would be helpful.

For reference, my uFPS is about 31 (half of what it needs to be) and rFPS is 10 (1/6th). Confirmed similar results on another person's machine, a recent (~2yrs) build.


Edit: Embarrassingly, the majority of the slowdown was due to the rendering of a minimap I was using to debug for crashes / missing tiles.... Please disregard.


rIKmAN(Posted 2015) [#151]
Has something changed with diddy.collections or IComparable in more recent versions?

I'm getting "Type IComparable not found" in some old code that was working, and the same with working example code given by Samah and therevills in part 7 of this thread - it was to do with z-sorting.

edit: Fixed - needed to change IComparable to IDepComparable, I must have missed a change in between updates.


Samah(Posted 2015) [#152]
@rIKmAN: Fixed - needed to change IComparable to IDepComparable.

Yeah, when I introduced the containers module I had to deprecate some of the collections interface names to reuse them. I could have used a different name, but: a) I couldn't think of anything other than IComparable, b) It's a minor change to existing code.

Having said that, you should probably be using the containers module rather than collections. It gives you better interoperability with the official Monkey classes and has a helluva lot more functionality. Just use DiddyStack instead of ArrayList.


rIKmAN(Posted 2015) [#153]
Ahhh I missed the introduction of containers so didn't realise anything had been deprecated - thanks Samah.

Just use DiddyStack instead of ArrayList


Is this the only change needed to my code?


Samah(Posted 2015) [#154]
@rIKmAN: Is this the only change needed to my code?

I've updated the containers wiki with a migration section at the bottom.
https://github.com/swoolcock/diddy/blob/wiki/Containers.md


Paul - Taiphoz(Posted 2015) [#155]
does diddy play nice with mojo2 ?


Nobuyuki(Posted 2015) [#156]
Quick Q: What's the secret to getting animated tiles? I can see something in the code for it, but I don't wanna spend all day trying different things just to find out it's not complete if it isn't (this is for the game jam!)

Sorry for the laziness, hopefully there's an easy answer on how to make it work :)


therevills(Posted 2015) [#157]
does diddy play nice with mojo2 ?

Havent tried it yet... but I dont think so. Watch out for Samah's new project ;)

What's the secret to getting animated tiles?

Samah did have an example a year or so ago... but I cant find it....


Paul - Taiphoz(Posted 2015) [#158]
Where is the diddy repo at the moment is it still being worked on or is the one on google code the most upto date ? iv not touched it in months so suspect my version is way out of date/.


Paul - Taiphoz(Posted 2015) [#159]
Nvm found it on git.


therevills(Posted 2015) [#160]
More work added to the JSON loader for the SimpleGUI added, it now can load in Sliders as well as Buttons. Still WIP, but committed to GIT.

Sample JSON file:
format_code('
{
"menu": {
"y": 210,
"buttons": {
"button": [
{
"name": "Resume",
"image": "button1",
"offsetY": 10,
"redText": 255,
"blueText": 255,
"greenText": 255
},
{
"name": "Quit",
"image": "button1",
"offsetY": 10,
"redText": 255,
"blueText": 255,
"greenText": 255
}
]
},
"sliders": {
"slider": [
{
"name": "Sound",
"image": "slider",
"borderX": 35,
"borderY": 20,
"x": 100,
"y": 100
}
]
}
}
}
')


malublu(Posted 2015) [#161]
There is a bug in the GUI module.
I only run the GUI example and ist crashed, beause they could not find button_enter.wav
It should not requierd or?
After i added an wav (copy paste the example file and renamed it)
it works

Also the loading example not working
Should it work with LoadingScreen.Progress?

I try it out. :)
I hope it is not my ERROR ^^

Okay its work :)
You should update your example! :)

I maked a pull request :)


therevills(Posted 2015) [#162]
I only run the GUI example and ist crashed, beause they could not find button_enter.wav

We removed some of the sound file formats to reduce the size of the repo.

I maked a pull request :)

Ta :)


Paul - Taiphoz(Posted 2015) [#163]
What did you do to fix the loading screen because mine wont work either the progress bar just jumps to full after a long pause during which time i guess its loading in all the assets.


malublu(Posted 2015) [#164]
look @ github
https://github.com/malublu/diddy-examples/commit/67188f9953f0a409e9d3bd057dd0b73cc28eabe3

In the tile system is also a bug.
I check it to.
And sorry for my bad english ^^


malublu(Posted 2015) [#165]
Okay i fix the imporet in the example.
You could also edit the source file
(diddy)

I also edit the example with the new map and the new loader:
https://github.com/swoolcock/diddy-examples/pull/2/files


therevills(Posted 2015) [#166]
What did you do to fix the loading screen because mine wont work either the progress bar just jumps to full after a long pause during which time i guess its loading in all the assets.

Because Diddy doesnt use the Async loader you have to do it manually, something like this:

format_code('Class MyGame Extends DiddyApp
Method Create:Void()
SetDeviceWindow(1366, 768, 4)
SetScreenSize(1366, 768, True)
diddyGame.loadingScreen.Init("graphics/loading/Loadingscreen.jpg", "graphics/loading/loadingbar.png", "graphics/loading/loadingbarempty.png", 10, -1, 700)
diddyGame.loadingScreen.destination = TitleScreen.GetInstance()
diddyGame.loadingScreen.loadingScreenDelegate = New MyLoadingScreenDelegate()
Start(MySplashScreen.GetInstance())
End
End

Class MyLoadingScreenDelegate Extends LoadingScreenDelegate
Field i:Int = 0
Field delay:Float = 0
Field load:Bool
Field fadeDelay:Float

Method Load:Void()
Local tmpImage:Image
If Not load
delay += 1 * dt.delta
If delay > 1 Then
i += 1
delay = 0
load = True
End
End

If load
Select i
Case 1
game.font = New BitmapFont("fonts/font.txt", True)
diddyGame.loadingScreen.Progress()
load = False
Case 2
game.buttonFont = New BitmapFont("fonts/buttonFont.txt", True)
diddyGame.loadingScreen.Progress()
load = False
Case 3
diddyGame.images.LoadAnim("game/cardAtlas1.png", 136, 195, 52, tmpImage)
diddyGame.loadingScreen.Progress()
load = False
Case 4
diddyGame.images.Load("game/backcard1.png")
diddyGame.images.Load("game/wild1.png")
diddyGame.loadingScreen.Progress()
load = False
Case 5
diddyGame.images.Load("game/progress_bar_empty.png", "", False)
diddyGame.loadingScreen.Progress()
load = False
Case 6
diddyGame.images.Load("game/progress_bar_fullpng.png", "", False)
diddyGame.loadingScreen.Progress()
load = False
Case 7
diddyGame.images.Load("game/PanelTop.png", "", False)
diddyGame.loadingScreen.Progress()
load = False
Case 8
diddyGame.images.LoadAnim("game/stars.png", 38, 38, 2, tmpImage)
diddyGame.loadingScreen.Progress()
load = False
Case 9
diddyGame.images.LoadAnim("game/menuboard.png", 200, 215, 2, tmpImage)
diddyGame.loadingScreen.Progress()
load = False
Case 10
diddyGame.loadingScreen.Progress()
load = False
End
End
End

Method Draw:Void()
If game.font <> Null Then
game.font.DrawText("Loading...", SCREEN_WIDTH2, SCREEN_HEIGHT2, eDrawAlign.CENTER)
End
End
End
')

@malublu - Yeah the examples are out of date, thanks for your input :)


Samah(Posted 2015) [#167]
@therevills: I'll handle the pull requests, but could you test the example for me, please?

@therevills: I cherry picked the commits to develop. Don't merge with master until they're tested, please. :)
Also please work from develop and not master, and pull before committing anything that would inadvertently create a new branch.


Paul - Taiphoz(Posted 2015) [#168]
Thanks for that therevills, seems ok for small things with only a few sprites but seems a little OTT for larger projects with lots of assets, any reason you don't do it async?


malublu(Posted 2015) [#169]
@therevills: No Problem :)
What means TA? ^^


therevills(Posted 2015) [#170]
@Samah - but could you test the example for me, please?

Ah you still look here :) When I get time...

@Paul - any reason you don't do it async?

Havent needed it yet and they were new commands to Monkey... Diddy normally gets enhancements when we need to add something to it. For example when I'm actually working on a game :)

@Malublu - What means TA? ^^

English slang for "Thanks".


Paul - Taiphoz(Posted 2015) [#171]
My loading bar gets to step 9 of 12 using your code above therevills, I only added a few extra steps but it halts on step 9, any clues?


Paul - Taiphoz(Posted 2015) [#172]
Lol forgot to call diddyGame.loadingScreen.Progress() on the additional steps my bad.


Samah(Posted 2015) [#173]
@therevills: When I get time...

You make it sound like I have time myself. XD

format_code('[samah conformsToProtocol:@protocol(FreeTime)]')
Resolves to NO. ;)


malublu(Posted 2015) [#174]
format_code('
Method LoadMap:TileMap(xmlString:String)
' look for the data encoding, if we cant find it assume its RAW XML and thats just too slow!
Local findData:Int = xmlString.Find("<data encoding")
If findData = -1
Error("Tiled Raw XML is not supported!")
End
')

You should allow the Raw XML, with an extra function like:
format_code('
Method LoadMap:TileMap(xmlString:String, allowRaw:Bool)
' look for the data encoding, if we cant find it assume its RAW XML and thats just too slow!
If Not allowRaw
Local findData:Int = xmlString.Find("<data encoding")
If findData = -1
Error("Tiled Raw XML is not supported!")
End
End
')

Because if you use only the object zone, you dont have an tile layer.
Why? Okay its a bit dirty, because a tiled map is only for tiled map. But you can reusing it for other stuff.
Only a improvement :)


therevills(Posted 2015) [#175]
We found that Tiled Raw XML was way to slow to parse, thats why Diddy doesnt support it. Also with Tiled it really easy to save your levels as base64.


malublu(Posted 2015) [#176]
but if you not have a tiled layer? ;)
So its not working.
Like here:
format_code('
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="100" height="100" tilewidth="32" tileheight="32" nextobjectid="8">
<tileset firstgid="1" name="test" tilewidth="871" tileheight="919" tilecount="5">
<tile id="0">
<image width="625" height="229" source="test.png"/>
</tile>
</tileset>
<objectgroup name="Objektebene 1">
<object id="1" gid="1" x="1839" y="1214" width="625" height="229"/>
</objectgroup>
</map>
')


Samah(Posted 2015) [#177]
It might be easier to convert it to the new SAX parser and just throw an exception if it tries to read a raw layer.


malublu(Posted 2015) [#178]
objectgroup is every time raw. (xml)
only the tile is base64 encoded.
So if you try an file that not have an tile layer.
Only a group or image layer, thats crashet.
You can throw anm error if the tile layer not encoded
Like:
format_code('
<layer name="Kachelebene 1" width="100" height="100">
<data encoding="base64" compression="zlib">
eJztwTEBAAAAwqD1T+1lC6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAbnEAAAQ==
</data>
</layer>
')

So thats not working:
format_code('
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="100" height="100" tilewidth="32" tileheight="32" nextobjectid="8">
<tileset firstgid="1" name="test" tilewidth="871" tileheight="919" tilecount="5">
<tile id="0">
<image width="625" height="229" source="test.png"/>
</tile>
</tileset>
<objectgroup name="Objektebene 1">
<object id="1" gid="1" x="1839" y="1214" width="625" height="229"/>
</objectgroup>
</map>
')

but that:
format_code('
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="100" height="100" tilewidth="32" tileheight="32" nextobjectid="8">
<tileset firstgid="1" name="test" tilewidth="871" tileheight="919" tilecount="5">
<tile id="0">
<image width="625" height="229" source="test.png"/>
</tile>
</tileset>
<objectgroup name="Objektebene 1">
<object id="1" gid="1" x="1839" y="1214" width="625" height="229"/>
</objectgroup>
<layer name="Kachelebene 1" width="100" height="100">
<data encoding="base64" compression="zlib">
eJztwTEBAAAAwqD1T+1lC6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAbnEAAAQ==
</data>
</layer>
</map>
')

You see it is not the best soluion to test on <data encoding. It should be testet if layer exist.
You know what I mean?


k.o.g.(Posted 2015) [#179]
@off topic
Hi malublu, is there any chance to contact you on skype?


therevills(Posted 2015) [#180]
format_code('<data encoding="base64" compression="zlib">')
Diddy doesnt support the compression flags of TIled, you need to select Tile layer format as Base64 (uncompressed) or CSV.


malublu(Posted 2015) [#181]
Its only an example!
About the object Group,not about the compression.
If there are no tiled layer the code does not work.
But a map can have only an object layer.
So thats not working:
format_code('
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="100" height="100" tilewidth="32" tileheight="32" nextobjectid="8">
<tileset firstgid="1" name="test" tilewidth="871" tileheight="919" tilecount="5">
<tile id="0">
<image width="625" height="229" source="test.png"/>
</tile>
</tileset>
<objectgroup name="Objektebene 1">
<object id="1" gid="1" x="1839" y="1214" width="625" height="229"/>
</objectgroup>
</map>
')

It needs an <data encoding

@k.o.g
yes of course but my english is not perfect.
Skype: format_code('removed')


Nobuyuki(Posted 2015) [#182]
Raw XML may be faster to parse when using the new skn3 XML library, if the speed issues were related to string operations. A warning would be preferable to throwing an error on a raw layer, considering reading a raw XML layer shouldn't be that big of a problem...


k.o.g.(Posted 2015) [#183]
Another Topic:

Is it possible to split tile engine of diddy and remove all graphic parts?
For my server i need a TileD parser without graphics, but now i must remove all Parts from diddy renderer & co. ;)


Samah(Posted 2015) [#184]
@k.o.g.: Is it possible to split tile engine of diddy and remove all graphic parts?

I'm pretty busy at the moment, but I could probably look at refactoring it out.


therevills(Posted 2015) [#185]
but I could probably look at refactoring it out.

I dont think its worth it. The code is there and if k.o.g just needs the parser he/she can alter the code for their own needs.


CGV(Posted 2016) [#186]
Upgraded my box with an SSD and forgot how daunting it would be to get all my development tools reinstalled but I thought Monkey would be the easy one. No such luck.

I reinstalled the lasted Monkey (85e) and downloaded the lasted Diddy from github, using the zip.
I think I was still using Monkey 78h and the equivalent Diddy before.

I'm able to build and run all the bananas examples so Monkey's working.

When I tried to build a game of mine that was building fine before, I got this error:
--> Unable to find overload for AddButton(GameImage,GameImage,String) <--

But when I check Diddy's source code, the overloaded function is there. So, what do I need to do to get my program running?


EDIT:
Just discovered that Diddy's platformer example is returning this error:
Type 'TiledTileMapReader' not found.

Did I download the wrong version of Diddy? I could have sworn the github repo is the correct one.


therevills(Posted 2016) [#187]
What URL did you use? Also did you get the Master or the Dev build?

Also where'd you get the platfomer example from?


CGV(Posted 2016) [#188]
https://github.com/swoolcock/diddy and the plalformer example from https://github.com/swoolcock/diddy-examples

both masters.


therevills(Posted 2016) [#189]
Can you try to Dev versions?


CGV(Posted 2016) [#190]
Tried the dev versions.

My game still returns the same error.
The dev version of the platformer now builds but after the title screen, when I hit space to play, It just goes black and gives the following error:

Debug version error:
Monkey Runtime Error : Tiled Raw XML is not supported!
C:/Program Files (x86)/MonkeyXPro85e/modules/diddy/tile/diddyreader.monkey<23>

Release version error:
AssertException: Error loading Atlas graphics/gripe.xml 0=0

EDIT: Just noticed that the data folder disappears when I build for release.


therevills(Posted 2016) [#191]
That's very odd...

[edit]Could you put MonkeyX and Diddy is a folder structure without spaces and try again?[/edit]


CGV(Posted 2016) [#192]
Moved everything, including the source code, to folder structures without spaces but no difference.

The really odd thing is that this is happening on two different computers. But they're both running Windows 10.

Could that be the problem?

EDIT: I downloaded the IngnitionX and Pyro 30 day trial versions that Playniax recently offered and they both function fine so this seems to specifically be a Diddy issue.


therevills(Posted 2016) [#193]
Okay... when Samah changed the readers he didnt fix up that example, he did fix up the "Tiled" example though.

This is what you need to do:

main.monkey
Add the following after #TEXT_FILES:
format_code('#TILEMAP_USE_DIDDYGAME=True')

screens.monkey
Add LoadString as the parameter of LoadMap... (really dont like this change!)
format_code('Local tm:TileMap = reader.LoadMap(LoadString("levels/level1.tmx"))')
Change the tilemap.RenderMap call:
format_code('tilemap.RenderMap(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 1, 1, diddyGame.scrollX, diddyGame.scrollY)')

level.monkey
Remove the DrawTile method.

When I get time I'll commit this...


CGV(Posted 2016) [#194]
Thanks, that fixed the platformer example.

As for my own game, I'm also having trouble with my haxe written games so there seems to be some glitch in my os install.

I'm going to wipe my ssd and reinstall.


Matiaz(Posted 2016) [#195]
with last version of diddy and last free version of monkeyx (v84f) when i compile the example testsimpleGUI i received the error "Error : Unable to find overload for AddButton(GameImage,GameImage,String)" ... how can i fix this? i've try both version of diddy (master and dev) downloaded from https://github.com/swoolcock/diddy


ratking(Posted 2016) [#196]
Seems like someone forgot to add the " = Null" standard values for the last 2 parameters of AddButton(GameImage,...) - just add them on line 234 in simplegui.monkey, and open an issue at github.


Matiaz(Posted 2016) [#197]
Thanks now it works!


therevills(Posted 2016) [#198]
Thanks for the bug report (here... cant see a github issue). I've fixed it and pushed it. Also merged the master with dev branch as its been awhile.


ratking(Posted 2016) [#199]
Did you have a look at my issue? https://github.com/swoolcock/diddy/issues/57


therevills(Posted 2016) [#200]
I havent looked at the new Tween stuff and Samah has kind of abandoned Monkey (for a while at least)....

Okay, not sure if his version is totally complete. I've looked at the source of the Java version and its got this method:
format_code('public Object getUserData() {
return userData;
}')

The MX version isnt a one to one with the Java version anyway... I've added a property getter to BaseTween for userdata:

format_code('Method UserData:Object() Property
Return userData
End')

Pushed to the dev branch.


Samah(Posted 2016) [#201]
@threvills: Add LoadString as the parameter of LoadMap... (really dont like this change!)

I haven't used Monkey in a while, is LoadString still dependent on Mojo? It's the main reason I removed it, so that you could use it as a pure parser. If LoadString was in monkey.lang I would have left it.

@therevills: Also merged the master with dev branch as its been awhile.

We use git-flow on all our projects, so master pretty much never gets touched until you want to do a release. Much cleaner imo. If you frequently merge develop into master, you may as well not even have two branches.
http://nvie.com/posts/a-successful-git-branching-model/

@therevills: ...Samah has kind of abandoned Monkey (for a while at least)....

I actually have work to do now, no slacking off. :)

@therevills: The MX version isnt a one to one with the Java version anyway...

A lot of it was language limitations. I dislike the way I implemented some of the chaining, but Monkey doesn't support cyclic generics or wildcards. It's the reasoning behind the protected underscore methods. A bit ugly, but the public API is fairly elegant, and yay for encapsulation!

@therevills: I've added a property getter to BaseTween for userdata:

Huh... I must have missed that one. Thanks.


therevills(Posted 2016) [#202]
Samah....


Who are you? ;)


Samah(Posted 2016) [#203]
@therevills:
I've set "develop" as the default branch, which means:
1) It's the one you'll see on GitHub if you just click the link to Diddy
2) It's the one you'll get when you clone the repo unless you specify master
3) It's the one that pull requests will default to

So from now on, we can leave master alone. :)


therevills(Posted 2016) [#204]
Fair enough... do you still want to use the master branch at all?


Samah(Posted 2016) [#205]
@therevills: Fair enough... do you still want to use the master branch at all?

Not really, unless we start doing version numbers. It might be good to look at doing that as major Monkey version releases happen, as long as they're tested. Anything that could potentially break or is uncompiled shouldn't be merged into master. If you're working on something new (use your best judgment) create a feature branch. Once you're happy, merge it into develop.

Check that branching model I linked before, if you're curious. It's a best practice that a lot of companies (including ours) uses.


Paul - Taiphoz(Posted 2016) [#206]
@therevills do you have any plans to add zooming in and out psudo camera controls to diddy ?


therevills(Posted 2016) [#207]
Not at the moment, but should be pretty straight forward by messing with the matrix commands... just need to make sure the virtual resolution stuff still works afterwards!

Edit: There is already some panning stuff in the tiled code.


Samah(Posted 2016) [#208]
@therevills: ... but should be pretty straight forward by messing with the matrix commands...

My initial thoughts too, but I was chatting with Taiphoz about this, and I'm not sure it's as easy as it sounds. The dev isn't going to want a global zoom to apply to their UI, for example, but the virtual resolution should. So the dev should be able to turn it on and off multiple times per loop.


therevills(Posted 2016) [#209]
Chef Solitaire USA: TriPeaks now on GooglePlay - using 100% MonkeyX and 100% Diddy:

https://play.google.com/store/apps/details?id=com.therevillsgames.csusatripeaks


Paul - Taiphoz(Posted 2016) [#210]
I found it a little annoying , I found that when I tied the zoom factor I was going from scale .8 to scale 1 as pulling out .8 was more than enough for my game, that it seemed to me like the offset to center the new translated screen wasnt as simple as a 1:1 move if you follow me, in the end I got frustraited with fighting with is and I manually set the zoom to each stage .81 .82 .83 etc and then manually centered the offset values to center the screen I then took note of all 20 needed values and filled an array which I then use when doing the zoom to make sure the screen is always centered.

I think it your not so worried about the screen being centered over your player it's probably not as big an issue, what I found odd and could not wrap my head around , or my math brain around was that the offset was not fixed in steps it trended toward 0 or 1 take a look at my array/.

So these are the x,y values that I needed to offset my world by after a zoom with the last element being zero zoom or scale of 1
format_code('
Field ZoomOffeset:int[] =[98, 92, 86, 80, 75, 69, 64, 58, 53, 48, 43, 38, 33, 29, 24, 20, 15, 11, 7, 3, -1]
')

and if you look at the amount of change between 1 zoom level to the next you can see I found the values a little odd.

format_code('
[xx, -6, -6, -6, -5, -6, -5, -6, -5, -5, -5, -5, -5, -4, -5, -4, -5, -4,-4,-4, -4 ]
[98, 92, 86, 80, 75, 69, 64, 58, 53, 48, 43, 38, 33, 29, 24, 20, 15, 11, 7, 3, -1]
')

I'm sure some one with a better mathy brain than me will look at this and go "Oh duh" and it will be something easily fixed, in the mean time I will use my little pre-calced array. :)


Rieha(Posted 2016) [#211]
Hi there dear Diddyguys! I'd appreciate your help.

Should the Game Service module work with the latest version of Monkey? It would be super nice if someone who knows how to use it could try it with v87x and confirm if I'm just doing something wrong. Posted about this here already.

The module is also quite old - has there been any major improvements to Game Services which make it unwise to use?

Thanks!


therevills(Posted 2016) [#212]
Sorry Rieha, I havent got the time to look into this at the moment. Maybe after Xmas...


Rieha(Posted 2016) [#213]
It's ok. I have to come up with some solution a lot sooner, but thanks anyway!


therevills(Posted 2016) [#214]
Again sorry, I've got so much to do and so little time these days :(


Rieha(Posted 2016) [#215]
I got it working already so no worries at all! Thanks for the awesome module! I have to play some Chef Solitaire as a thank you when I have a moment of free time. :)


therevills(Posted 2016) [#216]
Excellent! Let us know how you fixed it, I'm sure others would love to know too :)


Rieha(Posted 2016) [#217]
I decided to use the older compatible version of Game Services library. Checked what has changed with the Android target (not much) and copy/pasted any bug fixes to the older target. That wouldn't work with AdMob as it requires the newer library, I think, so anyone using it would probably like to have an updated module, but I'm happy with the current one (almost) as it is. Works like it should, but haven't tested much yet. :)