Parse tree for game. - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Parse tree for game.

Hi.

I am writing a game/application which gets its instructions from a file. similar

to the game RobotBattle. I have to buia parse tree of the instruction, then navigate

this tree to control the machine. Does anyone have any idea how I would go about this.

Below is an example of the simplest type of script I will be reading.



Init

{

Name( "John Doe" )



trigger = 80

goto( Move)

}

Move

{

TurnLeft( 65 )

Run( 100 )

Fire( trigger )



trigger = trigger - 20

}



Any help???

Thanks


Comments

  • : Hi.

    : I am writing a game/application which gets its instructions from a file. similar

    : to the game RobotBattle. I have to buia parse tree of the instruction, then navigate

    : this tree to control the machine. Does anyone have any idea how I would go about this.

    : Below is an example of the simplest type of script I will be reading.

    :

    : Init

    : {

    : Name( "John Doe" )

    :

    : trigger = 80

    : goto( Move)

    : }

    : Move

    : {

    : TurnLeft( 65 )

    : Run( 100 )

    : Fire( trigger )

    :

    : trigger = trigger - 20

    : }

    :

    : Any help???

    : Thanks



    I don't know, but I'm wondering how to execute instructions for a script language, as well. Interpreting them isnt too hard. Don't you wish all languages were easy like this?



    ; Cut and pasted...



    image img ; Create an image, named img

    sound sou ; And a sound, named sou



    init ; Initialize, called 1st

    menu 'File>' 'New' 'Save' 'Save As...' '-' 'Exit' 'Help>' 'Index' ; Attach menu

    if cant setres 800 600 16 ; If can't set 800X600X16. Default is 640X480X16

    exit ; End program

    load 'img.bmp' img ; Load .bmp to image

    load 'sou.wav' sou ; Load .wav to sound

    if no joydet ; If no joystick (no, not, cant, dont are all 0)

    msg 'No joystick detected' ; Message box

    play sou loop ; Play sound loop

    end ; End init



    game ; Game loop, invoked after init

    draw img center ; Draw image

    if key esc ; If Esc key

    exit ; End program

    end ; End game loop






Sign In or Register to comment.