Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.