Published on

how did i make a simple desktop application using dotnet and godot game engine ?

Authors

my experience

godot is a game engine that has a support for dotnet so people can write the game logic using c#. and i just wanted to use dotnet in godot to see how the developer experience is. i did try godot in the past and it has built-in scripting language called gdscript which is so powerful. it has a similar syntax like python. and overall godot experience was so smooth for me because everything is in one place; animation, shader editor, coding, exporting, documentation etc. so you don't have to leave godot game engine in order to create stuff you can just make everything in it. i tried other game engines also in the past and it all have that separation, when you write a script you have to choose some ide to write, test your code. for example if you write your games in unity you have to use visual studio in it because at the time unity didn't had support for debugging in the game engine. and i still didn't check it if it has or not.

another cool thing that godot does better than others in my opinion was producing smaller built sizes. i remember when i first try to create a simple cubicle game in unity and exported in my phone so i can see how it looks like, exported built size was 250mb+. this was insane to me because game had nothing in it, actually it wasn't even a game because i just added some cubicle to the main screen and exported it so i didn't expect the built size to be this much bigger. when i try to create games in godot when you export the game it is much smaller sizes than unity. like if you have full support for 3d,2d engines etc. you will have 50mb+ size which is 5x smaller than unity. and also you can optimize your export by disabling some of the features that you didn't use in the game so you can have much more smaller sizes. for a simple 2d mobile game you can get around 10mb+ in my experience.

dotnet in godot

first of all if you want to use dotnet in godot you need a specific version for that because main version has default support for gdscript. after you install that version you can use it directly. when you create a script for a node you have two options one for gdscript, one for c#. after you click the attach script button you can see the default script code that is generated. it has similar syntax to gdscript. i have experience mostly in c#, js so i just use it directly and there was no learning curve for me. and also if you get stuck for something you can look at the documentation to see the example usage of a node etc. there is code examples for both gdscript and c# so you won't get a trouble.

some use cases

when you use dotnet in godot this is not only limited to using the language, you can use the dotnet libraries also. some good libraries that comes to mind are httpclient, signalr, refit, masstransit. so for example if you want to create a multiplayer game you have to use a websocket server in order to handle realtime communication. you can have multiple part of this realtime communication in games; chat, realtime player interactions etc. so if you have an experience in signalr or you want to use signalr in this case you have access to these libraries. also i find it easy when you want to make a http request to apis in dotnet. you can use libraries like polly in order to handle resiliency also.

application

i had a simple idea for this application, it is video compressor application that uses ffmpeg core library. video compression can be done with online tools but when it comes to security and handling large size files you can't use an online tool. so i created a simple application that you can use offline in order to compress videos. you can export it to different video formats that ffmpeg supports and you have other options for compression.

the application currently have a retro theme like windows 3.11 and can be used only in windows. godot is cross-platform game engine so i can export it to different os if necessary.

Here are some pics from app:

app1
app4
app3
app2

Installation

this application requires ffmpeg. if you prefer to manually download them, visit ffbinaries or zeranoe Windows builds.

Windows (using choco)

command: choco install ffmpeg -y

location: C:\ProgramData\chocolatey\lib\ffmpeg\tools\ffmpeg\bin

Mac OSX

command: brew install ffmpeg mono-libgdiplus

location: /usr/local/bin

Ubuntu

command: sudo apt-get install -y ffmpeg libgdiplus

location: /usr/bin

I publishd this application here if you want to test it.

https://eminvergil.itch.io/videocompressor

Resources: