3

I'm working on a game where the player writes some basic AI that plays "instead of" him. So an algorithm written by the user must be executable right after he saves it.

The game is written in C++ using Qt framework.

I don't want to scare players with programming so I want to provide them some easy drag'n'drop visual programming editor (like in this CodeSpells game). Blockly looks like exactly what I wanted since it can generate Lua scripts that can be used/executed in C++ code (I need to learn more about this, but that's not for this question).

What I don't know is how to create/integrate this editor in C++. Their documentation says only about web, android and ios.

So my question is: how to integrate Blockly editor to a C++ project?

EDIT :

I wrote to CodeSpells devs. This is the important part of answer:

"For CodeSpells, we used a product called CoherentUI -- which is for Unity. For subsequent projects, we've been using the cheaper Unity product: https://www.assetstore.unity3d.com/en/#!/content/55459"

Can the Blockly editor be integrated in a Qt C++ project using embedded browse? For example like this? (I never worked with it)

ph_0
  • 617
  • 8
  • 27
Pyro2266
  • 310
  • 2
  • 5
  • 18
  • A Blockly dev may wander through here at some point and provide an brilliant answer, but you may get a faster response by contacting them directly. It also looks like they are seeking contributors. Could be fun. – user4581301 Nov 01 '16 at 18:11
  • Blockly is specifically designed for web use. Your best bet is probably to either find a different library or port the whole project to C++ (good luck!) – 0x5453 Nov 01 '16 at 18:13
  • Ah, I hate when people downvote my posts without commenting what I did wrong. Anyway I wrote to CodeSpells devs. This is important part of answer: _"For CodeSpells, we used a product called CoherentUI -- which is for Unity. For subsequent projects, we've been using the cheaper Unity product: https://www.assetstore.unity3d.com/en/#!/content/55459"_. So maybe [this](http://doc.qt.io/qt-5/activeqt-activeqt-webbrowser-example.html) may be answer to my question. – Pyro2266 Nov 01 '16 at 18:20

1 Answers1

3

So, this can be done using embedded browser. I saved Blockly web editor in resources. Then I used QWebEngineView to display editor from resources.

Here is similar tutorial.

Pyro2266
  • 310
  • 2
  • 5
  • 18
  • Interesting! I was looking for a way to extend Scratch and new Blockly. How dows it store the programs then? Is it a documented format that you can parse and converto to your language? – Valentin H Nov 12 '18 at 14:12
  • To be honest I don't really know. This was more than two years ago and I did not even used this solution since it was really slow. I ended up by writing my own "visual programming language". – Pyro2266 Nov 13 '18 at 09:38