Translate This Page

Saturday, October 13, 2012

Advancing ComputerCraft Graphics




Graphical Class and Frame-Buffers
An idea for ComputerCraft Development.
An idea for the development of ComputerCraft.
By: Sledger721

        I was thinking about the graphics of which were recently introduced to ComputerCraft. They're simple, 16-bit colors on a 50x18 screen. Nothing special, but still astounding. One thing that I love about new technologies: the APIs.
        The APIs that pop up to simplify things are amazing, and my favorite part, just to see what the community has mustered up between the time of the release and the time of me checking the forums. For example, with the release of colors and graphics came this astounding API:
Color Tags API. This API provides many amazing features, but primarily an image format.

        I've always thought it would be kind of cool to have image formats, but in such a simply system they've constantly rendered themselves unnecessary. The lack of necessity is what tends to kill things in a programmer's environment (with the exception of bacon. Wait a second, bacon is a necessity). In a text-based, command line system such as CraftOS, or any OS on ComputerCraft for that matter, file formats are nearly always useless.

        However, this format changed my mind. Most people tend to dislike formats because of how they aren't needed, but this is an area with an extremely high demand for a file format. One thing that got me is that they used the .png extension, already taken bros :\. Other than that, nice job :). I must say, keep working on that, I'll be expecting 3D graphics by December.
        I had a marvelous idea for the graphics systems of ComputerCraft though, classes. Two classes, one for the screen, one for the frame buffer. Here is an example of what I had thought up: Pastebin Link to Ideas.

        Now, lets go ahead and tear that apart piece-by-piece, line-by-line. The first two lines are simply initiating things and setting variables before hand, just for the sake of security. Observe line 6 to see where content is placed in, with a common character (;) to parse it all.

        At line 8 the main loop begins. The first if statement in there says that if the ready switch for the buffer is on, parse the contents of the buffer and then move the parsed contents onto the screen. The next if statement states that if there is content in the frame buffer class, set the switch to true.

        The entire purpose of that second if statement from the top is just to keep things running as fast and seamless as possible. Without it things would just keep on stacking and stacking, leading to lag and major amounts of image corruption within the frame buffer class. The last two functions are just drawing and buffing the classes, maintaining them through the state of the loop.

        I hope that this has managed to get you to think a little bit about the advancement of graphics within ComputerCraft, or anything else related. Thanks for reading :).
-Sledger721


No comments:

Post a Comment