Jump to content
  • Advertisement
Sign in to follow this  

C-Lesh Game Interpreter in JavaScript

This topic is 2272 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is a project that I've been tackling for the past few years. This is currently version 3 of C-Lesh. So what is C-Lesh? It's a programming language much like basic that is geared towards creating 2D games for www.c-lesh.net and publishing them on the site. Now for a little bit of history.

I started this project way back... probably like in 2005. Originally, I wanted to create an interpreter for the Calc Basic language. For those of you who don't know what that is it's basically the language of the TI-82 calculator. Anyways, this is relevent to me because I started programming on the TI-82. So I created this thing in C++. It was crude but could run text games on the terminal window. For those of you who remember Worm-Lang many many years ago (Does anyone remember?) you'll know what I'm talking about. However, the first version of C-Lesh could not output pixels - just text. I then proceeded to work on another version of C-Lesh and released the old one on SourceForge sometimes in 2008.

The first version of C-Lesh was crude. All variable were predefined as letters like in Calc Basic and there were no lists so programming was a challenge. This sucked so I began working on C-Lesh 2. The newer version included lists which could be configured to a specified size. It could also output graphics. I did manage to write a game in this language but it was sloppy. Like the first version the language has no subroutines, jumps, or memory allocation. All memory is fixed and defined by the programmer. This may seem to suck but on the bright side there is no need for garbage collection or freeing of memory.

So now there is this version of C-Lesh written entirely in JavaScript. I originally wrote version 3 in Java using an applet to implement the interpreter but that caused problems with porting. So I decided to do the thing in JavaScript and challenge myself. The compiler and interpreter are all written in JavaScript. JavaScript has gotten fast and there is even an NES emulator written in it that runs at a decent speed. This is one of the things that inspired me to do this.

C-Lesh 3 is much like basic but with fixed memory. As mentioned before there are no subroutines, jumps, or dynamic memory allocations. Basic control structures like if...else...end-if and while...end-while exist. All statements are in command format as so: output [STR_HELLO] at 0 0 C-Lesh does not do string processing just numbers so strings must be loaded at initialization time. There are also commands to deal with lists which are called segments in this language. C-Lesh outputs to the HTML 5 canvas which is embedded in the page - much better than using Java applets. They suck! You can also create text maps for levels like this:

x p x
x x

x = wall
p = player

These can then be loaded into the game.

You can write your games online test them. You can pull the code from the site because it's saved. Just download <your program>.clsh. If you have any questions, comments, or want tutorials just send a message to me. As a side note I haven't fully tested the language and it is still a work in progress so let me know.

The interpreter resides on my website. You can get there via the link in my signature. You do not need to register an account or anything. Have fun!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!