Re: Sphere v2 API discussion
Reply #43 –
Alright, I added a screen.fullScreen property. You'll be able to set it to true or false to control the engine's fullscreen mode at runtime.
I reorganized the file API a bit: Instead of FS.openFile() (which is awkward to explain to newbies: what does it mean to "open" a file? It's not a folder.), you now do instead:
import { FileReader, FileWriter } from 'struct';
function saveGame(world)
{
var stream = new FileStream("~/saveFile.dat", FileMode.Write);
var fw = new FileWriter(stream);
fw.writeString8(world.playerName);
// etc. etc.
}
There are no more obscure C fopen() mode strings, it uses easy-to-understand FileMode constants now. And while it seems superficial, the rename from FS.openFile() to new FileStream() is actually pretty significant: It takes the concept of "opening a file" completely out of the equation. That makes it much simpler to explain to new users: you create a new FileStream which provides streaming access to the data stored in the file.
This kind of thing is a delicate balance to strike: You want the code calling these API functions to be self-documenting (so that less experienced users can read it and see what's going on, and thus learn from it), but at the same time you don't want to dumb it down and take power away from more advanced users. That sometimes requires a lot of thought, but in the end I think the work has paid off. For many, Sphere 1.x served as a "gateway drug" into programming. I think I've been able to preserve that gateway potential in Sphere v2, but only time will tell.