Tuesday, July 28, 2009

Yum yum yum


In keeping with the theme of candy, sweetness, and food, the name of the scripting language that Candy runs on has a suitable moniker: Yum.

Yum is a simple scripting language that lets you do just about anything related to images, game levels, game entities, screen text, and more. It defines the logic of the game, and is incredibly useful for creating on-screen menus and cutscenes, loading game levels and their inhabitants, and queuing up interesting in-game sequences. In fact, the game engine starts by launching the game module's bootup script.

I wouldn't consider Yum a "real" language, although with a bit of work it could be. It's not very internally consistent; it's a bit ugly and incomplete in a lot of places. That said, it should get the job done for Candy.

I'll have more to say about it in this blog over the coming weeks, but today I will focus on function support. In Yum, you can define functions as you can in other languages. Functions can take parameters and can return a value. You can define as many functions as you like in a script file, but they only have scope within that file. Variables created in a function are local in scope only to that function (I will discuss variable scoping in a future post).

Today I completed support for parameter passing to functions. As soon as I finished, the first thing I tested out was a Fibonacci function. If you're not familiar with the Fibonacci sequence, go educate yourself here. (The great thing about this function is that it's recursive, so I can test not only parameter passing but variable namespaces as well.) I ran it and, of course, it didn't work the first time... After a few bug fixes, it's now working great! Here's how you define such a function in Yum:

def fib(n)

if n == 0
return 0
elsif n == 1
return 1
else
return fib(n-1) + fib(n-2)
end

end


There are a few little things I will briefly mention here. 1. The def...end block defines the function, just like in Ruby. 2. return is a keyword used for returning a value to the caller. 3. Yum is a duck-typed language. (I'll have more to say about that in the future.) 4. Finally, recursion works in Yum!

If you want to use the function above, you can just use it as you normally would in any arithmetic operation, but you already knew that:

x = fib(20) * 3 / 5


That's it for now regarding Yum.

Monday, July 20, 2009

Another screenshot

It's fun posting these, so let's have another one. This is a screenshot of multiple Abobos (from Double Dragon) and a sprite from Spider-Man (Doc Oc). The background is from Splatterhouse. You can move the Doc Oc character around and the Abobos will all follow you around.

Sunday, July 19, 2009

Here's a sneak-preview of Pong

Recently I added if-elsif-else-end statements to my scripting language that runs the game engine. The game engine also includes the ability to read mouse movements, to move images around, to set and read, and to execute multiple "threads" at the same time. With all these elements, it's possible to write Pong in the game engine.

Here's an early screen shot of the game engine in action.

Welcome!

Welcome to the Sweetness blog. Candy is a game engine I've been working on for a few years now and am ready to make public. Keep an eye on this page for more info as it becomes available.

Thanks!