After a long break, I finally brought myself to program something in Dart again. Working with Dart Editor is still a test of nerves. Looks are subjective, but even TypeScript in VS seems more comfortable to work with than Dart in Dart Editor. Not to mention that 8GB of RAM is not enough for it: either Windows keeps reporting that it is out of memory, or Dart Editor simply shuts down without saving any files. But back to the ants. I worked on them for a week. April 6 was Easter, a public holiday, and I was trying to upload updated versions of my program to my website.
Only one file was larger than the default limit of 28.6MB, and my file had 34.1MB, so every time the upload got past 28.6 MB, it reset and started uploading all over again. I wrote to ASPOne support asking whether they could raise my upload limit, and I did not expect an answer that day, since it was a public holiday. So I started programming Ants in Dart so as not to waste time sitting idle. At first I played around with the graphics, as I had no idea to what extent I would be able to crop images, because during the game both castles are always somewhere between 0 and 100%.
In the end I managed it quite simply, using the CSS properties height and top. I did the wall the same way. I took all the graphics from the original Ants. Unfortunately, the sounds were not there, and I did not manage to extract them in the visual programming tool Petr either; I could only play them there, so I recorded them from the sound card. Sadly, even though I had the volume at maximum, they are about 2x quieter than in the original game. I also got stuck for half a day on the sound. I wanted to do it with the Dart SDK package web_audio. I do not know whether I was doing it right, but I ran into the fact that I could create at most 6 “hardware contexts”, that is, sounds.
In the end I solved it by creating an HTML element <audio> for each sound and loading the sound into it. The downside is that every time a sound plays, it probably has to load the sound from the web, unless Dartium caches it somehow. Another thing: just like all my other Dart programs, these are not compiled to JS, so you can only run them in Dartium. Unfortunately, there are still no signs that Google plans to integrate the Dart VM into Chrome or Chromium, which is a pity.
In any case, you will need a fast connection and a fast PC: a fast connection for loading the images, and a fast PC for keeping up with several timers that drive the animations. It is not a 100% faithful copy of the Win32 Ants. Right now I am not sure whether the birds keep singing after the game ends (I stop them, but I do not know whether it works), drawing a new card is not animated, and if you play against the PC, the PC picks its own card before the 1s during which your card moves has passed (so effectively 2 cards move at once). Some cards have a purple color that Petr converted to gray (a shadow), the castle and the wall have no shadow, and there would be a few more things.
I already posted it on G+ last night, but today I noticed that I was getting different cards on every turn, so I fixed that as well. The weirdest thing was that I was playing it on the web and suddenly it behaved correctly, even though I had not uploaded any new files. But once it behaved correctly on localhost too, I left it the way I had fixed it. Now the Ants are perfect, at least for me. If you want to play them, you no longer need Dartium; any web browser with www.sunamo.cz open in it will do :). And I recommend playing against the PC; it seems much smarter to me than the original PC opponent :).