ForumSite Announcements ► <crayon> tag tutorial
All information moved here!
They told me you had died.
I'm trying to compile the sample project and I'm getting an error "File must be a CBX file." I didn't modify anything with the build file except adding the directory of the SDK.

Is this a dumb error? Have I embarrassed myself?
They told me you had died.

Eric-616 said:
I'm getting an error "File must be a CBX file."

What exactly did you type to run it and from which directory? Which directory is the .build file in?
I extracted the project in its own folder called TwoCansSampleProject exactly as it came in the zip and tried to run "crayon" in that folder from the command line. I'm pretty sure I followed exactly what this guide told me to do. What's weird is I did the same thing on my laptop and it compiled just fine.
HYPE. I like the new API.

I am however confused at a couple steps. I tried adding the crayonpath (pointing to my TwoCansSDK folder) to my existing Reversi project, expecting it to fail to compile since I'm not using the new API. But when I ran "crayon.exe .\", it ran just fine.

I'm also confused at this step:
Blake said:

  • Click Upload new version
  • Go back to the project page and refresh the page until compilation completes.

What should we be uploading? I arbitrarily tried compiling the sample project and uploading output/UntitledGame.cbx. But now it's stuck in the compiler queue. 🙁 Did I break everything?
I didn't leave the compiler running this morning, but you need to upload a zip of the source code. I'll update the instructions when I get home from work and restart the compiler service.

Also, right now the Game/Graphics2D libraries are allowed. Soon, I'll be banning them so the game will have to be written with the TwoCans API exclusively.
Gotcha. I love replacing my own code with standardized libraries (less stuff for me to maintain), and it seems I can eliminate my input manager and color type. 👍

Looks like I missed the compiler boat again though. 😢 Is it running on a machine that's not always online or something?
Yes, now that the runner is a little more stable, I need to set up the laptop I don't pack up and carry around to run this. Sometimes it'll just crash in the middle of the night.
Is the compiler ported to Crayon yet?
That probably won't happen for a while. There's two major projects preventing me from doing that:

  • Adding C as a target for export (otherwise there will still be awkward dependencies)
  • Adding a new frontend language that compiles to the same bytecode. This new language will likely be a clean subset of C# such that I can still use the VS debugger for development and there will be little to no changes to the actual compiler codebase.
Is there (or will there be) a replacement for the functionality of Graphics2DText? I.e., is there any way to render text with the TwoCans SDK?
Not yet.

I'm a little afraid of throwing in a bunch of functionality without designing it properly since API's are hard to change. I'm currently migrating one of my more complicated former PyWeek games to use the TwoCans API as a test to make sure that it's actually useful and not wonky to use. I'll be completing that this weekend.
From error message:
source/main.cry, Line: 1, Col: 1, Unrecognized namespace or library: 'TwoCansAlpha1'
From the server or when running locally?

From the server! Fix imminent. Fixed.

I reset the compilation status on the last version you uploaded. It is now ready for public consumption.
Couple of major things I'm planning on doing soon:
  • Changing the TwoCans API. I'm starting to realize that radically diverging from the built-in API's is probably not a good idea, since basically it becomes 2 API's I have to maintain and online references would be like JavaScript where there's always a jQuery answer and a normal JavaScript answer. I'm going to wrap the Game/Gamepad API's, but allow direct access to the Graphics2D and Audio libraries. This especially makes converting non-TwoCans to TwoCans difficult. Since I chose the scene management approach for the SDK, what I'll do is still include it as an optional (and highly encouraged library) for those writing code from scratch directly for TwoCans.
  • I'm going to change the build file format from XML to JSON. This has been a pain point for a while, and it seems like the sort of change that's better to fix now than before too many people start creating projects.
Cool! Is the compiler server up still? I want to upload a better version.

And 👍 for JSON!
It is right now, but it's still the laptop I carry around, so there are sometimes periods of radio silence.
Would it be possible to specify the window size in the build file or something? It's currently hard-coded at 640 x 480. (I actually want to reduce the window size, in case you're worried I'll explode the forum formatting.)
Yeah, I can do that.

From the new API:
const SCREEN_WIDTH = $var['screen_width'] ?? 640;
const SCREEN_HEIGHT = $var['screen_height'] ?? 480;


width = Math.floor(SCREEN_WIDTH);
height = Math.floor(SCREEN_HEIGHT);
if (width > 640|| height > 480) throw new InvalidArgumentException("Game screen size must be smaller than 640 x 480 to fit site UI");
if (width < 256|| height < 224) throw new InvalidArgumentException("This screen size is too small");
if (width / height < .5) throw new InvalidArgumentException("This screen size is too tall.");
if (width / height > 2) throw new InvalidArgumentException("This screen size is too wide.");

This will be in TwoCansAlpha2, which will remove all layer silliness and just rely on Graphics2D calls directly.
TwoCansAlpha2 SDK is now out! Same download links. Documentation has been updated. Sample project has been updated as well.

Notably layers have been removed entirely. Just make calls to the built in Graphics2D and Graphics2DText libraries.
Another couple pretty-please feature requests for the SDK:

1) Access to mouse input via the inputManager (as opposed to only through events)
2) A function that reports whether a given key/mouse button was pressed this frame

Currently we have to keep track of which buttons were pressed last frame if we want to do something upon a button press.
New TwoCansAlpha2 SDK uploaded! I didn't change the name/version, but it has these new methods in InputManager.

New InputManager methods:
  • isKeyPressedThisFrame(key) --> boolean
  • isKeyReleasedThisFrame(key) --> boolean
  • getMousePosition() --> returns coordinates as a list of two integers
  • isMouseOver(left, top, width, height) --> boolean, true if mouse is over the given rectangle
  • didMouseClickHere(left, top, width, height) --> boolean, true if mouse clicked in the rectangle in the current frame

Old methods are still there:
  • isKeyPressed(key) --> boolean
  • isShiftPressed() --> boolean
  • isCtrlPressed() --> boolean
Games is now one of the main links at the top of the page. It lists all the games that have a public version.
I greatly anticipate playing them. Will you add the old ones to that section?
Forum > Site Announcements > <crayon> tag tutorial