Hello! I’ve made some Twine games in the past, and as of now, I’ve only used Harlowe for making them. I was thinking about a game where a map is given to you, and I wanted people to be able to draw in the map. As I come from Unity-based games, my first thought was that I was better off using that engine for this idea, but then I realized Twine is very configurable.
I found 1 post that talked about this, but I’m not very familiar with integrating things into Twine. Also, I don’t know if Harlowe would be the best for this.
Basically: I want to include some type of drawing canvas in a Twine game.
Edit: I wrote this at 3am and just noticed the typos haha.
I just edited them out.
Harlowe is never the best if more than very basic JavaScript is involved. That said, as long as whatever you’re doing does not require you to hook into Harlowe’s internals, then it should probably work out in the end.
In this case, it depends on exactly how much interaction with the story format your idea will need. If you just want to use a <canvas> element, and maybe some associated JavaScript, then you should be fine with Harlowe. If you want a lot of interaction between the story format and the <canvas> element, then you may be better off with another story format.
I took the time to do a deep dive into Harlowe. It can do what you need it to. Particularly, the last two sections in the following link may prove useful for you to setup HTML canvas code.
That said, many here would argue that SugarCube is the most robust format to work in. If you like Harlowe, then continue with it. If you are having second thoughts, check out SugarCube. If you are hardcore, Snowman.
As of now, I’m not thinking about too much interaction, really. The idea as of now involves going to a passage where a map is given to the player. The player then can draw on top of it, but then the drawings get saved. That part may be the tricky one? But the drawing wouldn’t really interact with the story per se.
Anyways, I should maybe look into SugarCube as @HAL9000 points out. The thing is, I was just started to feel comfortable with Harlowe and I’m somehow afraid that SugarCube will be another giant mountain to climb, but I’ll be looking into it.
I’m not much of a programmer. I can do basic stuff, so I was kinda hopeful some simpler solution existed, but I’ll be reading it nonetheless and looking for more help in the future.
That was my trap too. Then I moved onto Chapbook and really like it for it’s simplicity.
The thing with SugarCube is that it doesn’t have any syntax highlighting in the Twine editor. This means you have to use VSCode (or Notepad++), find a syntax highlighting add-on and setup + use Tweego as a compiler. It’s quite daunting for me so I still haven’t set it up to give it a proper go.
Edit: I should mention that Twine has not exposed it’s syntax highlighting API to the story formats properly, from my understanding. This is why SugarCube does not have the highlighting. Harlowe and Chapbook sort of hack Twine to make it happen.
Regarding your need to save the image the user creates in the HTML canvas, Twine stories use the browser’s local storage so you’ll need to do something along the lines of…
…but save the image variable into the Twine story’s storage. Harlowe allows you to save a story variable in JavaScript. Not too sure if there are limitations to the type of variable that can be stored, but a Base64 should work because it’s just a long string.
I love it when people do unique things in their games. Good luck!
This used to be true, but there’s an official API for this along with other ways to extend Twine as of version 2.4. Docs for those interested are here.