Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 22nd, 2008, 11:36 PM   #1
francoispress
Newbie
 
Join Date: Jul 2008
Posts: 8
Rep Power: 0 francoispress is on a distinguished road
Snake in C-Lesh

I programmed a game called Snake which is a simplified version of Nibbles in a language I wrote called C-Lesh. The language is made to recreate the programming environment of the TI-28 which I enjoyed because of the challenges of programming in a minimal language. Here's my version of that called C-Lesh. Below is the Nibbles program I wrote in this language.

// Simple Snake Program
// Taken from "http://timjoh.com/simple-snake-game-in-ti-basic".
// Use the j, i, l, and m to control the worm. You can only run
// into yourself three times before losing. Good luck!

) 1 1 Snakes ) 1 2 Modified\sby\sFrancois. ) 1 3 Push\sENTER\sto\sstart.

? @k ! 13 L
[

    k => @k // Store keystroke.

]

~
m @x <= 16
m @y <= 8
m @d <= 1

? @c = 0 L // Infinite loop.
[

    m @o <= Score:\s . @s
    ) 0 0 @o
    k => @k
    
    ? @k = 106
    [
    
        m @d <= 1 // Left
    
    ]
    
    ? @k = 105
    [
    
        m @d <= 2 // Up
    
    ]
    
    ? @k = 108
    [
    
        m @d <= 3 // Right
    
    ]
    
    ? @k = 109
    [
    
        m @d <= 4 // Bottom
    
    ]
    
    ? @d = 1
    [
    
        m @x <= @x - 1
    
    ]
    
    ? @d = 2
    [
    
        m @y <= @y - 1
    
    ]
    
    ? @d = 3
    [
    
        m @x <= @x + 1
    
    ]
    
    ? @d = 4
    [
    
        m @y <= @y + 1
    
    ]
    
    t @x @y => @p
    
    ? @p = * // We hit ourselves.
    [
    
        m @a <= @a + 1
        
        ? @a > 2
        [
        
            ~ .
        
        ]
    
    ]
    
    ) @x @y *
    m @s <= @s + 1 // Raise the score for survival.
    _ 100 // Wait 100 milliseconds.

]

The interpreter is delivered as an attachment so that you can run this game. Read the docs so that you understand the language.
Attached Files
File Type: zip C_Lesh.zip (18.4 KB, 5 views)
francoispress is offline   Reply With Quote
Old Jul 23rd, 2008, 3:35 AM   #2
BstrucT
Hobbyist Programmer
 
BstrucT's Avatar
 
Join Date: Dec 2007
Location: Durban, South-Africa
Posts: 164
Rep Power: 1 BstrucT is on a distinguished road
Re: Snake in C-Lesh

" C-Lesh died with message: Missing Parameter. "
__________________
if (understanding of Pointers != Great)
{
do (.Net);
}
BstrucT is offline   Reply With Quote
Old Jul 23rd, 2008, 6:50 AM   #3
francoispress
Newbie
 
Join Date: Jul 2008
Posts: 8
Rep Power: 0 francoispress is on a distinguished road
Re: Snake in C-Lesh

Quote:
Originally Posted by BstrucT View Post
" C-Lesh died with message: Missing Parameter. "
You need to pass the path to the script file to run. i.e. c_lesh somefile.clesh
francoispress is offline   Reply With Quote
Old Jul 24th, 2008, 1:59 AM   #4
BstrucT
Hobbyist Programmer
 
BstrucT's Avatar
 
Join Date: Dec 2007
Location: Durban, South-Africa
Posts: 164
Rep Power: 1 BstrucT is on a distinguished road
Re: Snake in C-Lesh

Probably a dumb question...

How do I do that?
__________________
if (understanding of Pointers != Great)
{
do (.Net);
}
BstrucT is offline   Reply With Quote
Old Jul 24th, 2008, 2:08 AM   #5
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 998
Rep Power: 4 lectricpharaoh will become famous soon enough
Re: Snake in C-Lesh

Use the command line, or go to Start -> Run, and then type the full path to the program, and the full path to the .clesh script.

Alternatively, you could make a new shortcut, and add the script to the 'Target' line, but that's overkill. The command line is quickest and easiest, and you can go on to Microsoft's site and search for the 'create command prompt here' PowerToy. This allows you to right-click a folder in Explorer, and have a context-menu choice to open a prompt with that folder as the current working directory. For testing command-line stuff, it's rather convenient.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old Jul 24th, 2008, 4:06 AM   #6
BstrucT
Hobbyist Programmer
 
BstrucT's Avatar
 
Join Date: Dec 2007
Location: Durban, South-Africa
Posts: 164
Rep Power: 1 BstrucT is on a distinguished road
Re: Snake in C-Lesh

What I did was open the command prompt window, and drag the .exe file into it, then pressed Enter to run the application. That's when I received the error.
__________________
if (understanding of Pointers != Great)
{
do (.Net);
}
BstrucT is offline   Reply With Quote
Old Jul 24th, 2008, 7:13 AM   #7
francoispress
Newbie
 
Join Date: Jul 2008
Posts: 8
Rep Power: 0 francoispress is on a distinguished road
Re: Snake in C-Lesh

Quote:
Originally Posted by BstrucT View Post
What I did was open the command prompt window, and drag the .exe file into it, then pressed Enter to run the application. That's when I received the error.
Dragging the script onto the exe file won't work because if the path of the script contains spaces then the path can't be used. The easiest way to run the scripts are to place the interpreter in its own directory and set the PATH environment variable to point to that directory. That way you can run the script like: c_lesh <scriptname>.
If you need any more help feel free to ask. Have fun with C-Lesh!
francoispress is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Snake Game I made by my self msi_333 Java 0 May 29th, 2007 11:44 AM
Desktop Snake jeffball55 Show Off Your Open Source Projects 5 Mar 28th, 2006 3:05 AM
Turbo C++ Snake Problem lilmul123 C++ 1 Mar 17th, 2006 6:44 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:18 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC