Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22

Thread: tstringlist (help plz, im a noob)

  1. #11
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    tstringlist (help plz, im a noob)

    Hi bekuzofu

    I am a very experienced programmer, I am also a pretty experienced game programmer. I would not consider writing a scripting language - the complexities are much greater than you can possibly imagine. (I've done a rule based AI interpreter in the past and it was really difficult)

    Fortunatly there are a number of scripting language options out there already. Have a look at Delphi Web Script, RemObjects Pascal Script, or the Pascal interpreter in the JVCL components. All of these are ready made script parsers for the pascal language.

    If you want to make your own scripting language, consider making a pre interpreter that converts your scripting language to pascal code and then using another existing interpreter to run the code.

    Instead of making EXEs consider making a single executable that runs your 'programs'. Then assosiate your scripts with this program. (Do a search on google for shell commands, or assosiate program to find out how). If neccessary you can encrypt your scripts so that other people cant change them. Another option (rather advanced coding required) is to create an exe and have your scripts as resources inside the exe.

    My suggestion is to get hold of Delphi Web Script. It includes a nice example that has an IDE and full examples of compiling and running code.

    Good Luck and have fun
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  2. #12

    tstringlist (help plz, im a noob)

    I'm just making a simple language.
    The main thing i need is to read the command which easy but instead of one simple command, i need something that is like text(hi), sorta like in qbasic with the print command.

    but i think your ideas are really good.

  3. #13
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    tstringlist (help plz, im a noob)

    The method used to break up a command into various parts is called tokenising (making into tokens).

    Ok - heres some help -

    Create a Form
    Place two TMemo components on it (Memo1, Memo2)
    Place a button on it (Button1).

    Change the strings property of Memo1 to
    Print "Hello William"
    Place the following into the Button1Click:
    [pascal]
    procedure TForm1.Button1Click(Sender: TObject);
    Var
    I : Integer;
    Cmd : String;
    Token1 : String;
    begin
    Memo2.Lines.Clear;
    For I := 0 to Memo1.Lines.Count-1 do
    Begin
    Cmd := Memo1.Lines[I];
    Token1 := Copy(Cmd,1,Pos(' ',Cmd)-1);
    Cmd := Copy(Cmd,Pos(' ',Cmd)+1,Length(Cmd));
    If UpperCase(Token1) = 'PRINT' then
    Begin
    Memo2.Lines.Add(Copy(Cmd,2,Length(Cmd)-2));
    End;
    End;
    end;
    [/pascal]

    There is a basic script interpreter - ok so it only understands one command but it is a start. Run the program and Press the button - you will see the output of the script in Memo2.

    Remember:
    :arrow: Memo.Lines is a TStrings (Almost the same as a TStringList).
    :arrow: You can load a txt file into Memo.Lines using Memo.Lines.LoadFromFile
    :arrow: Break the procedure into smaller procedures - call a seperate procedure for each command
    :arrow: You need more than 1 Token for most commands - change Token1 into an array and break the whole command into all its tokens (Anything between " and " is a single token - same goes for anything between ( and ) )
    :arrow: Add one command at a time. Dont try to do everything at once. The next step here is to tokenise the whole string.
    :arrow: The second step to do is to find a way to create variables (Create a string list and use the .Names and .Value properties to make variables) - e.g. Set A = 2 (note - this is 4 tokens)
    :arrow: Also make sure you define your language now - before you code. Make sure there are no possible conflicts in your language (In compiler theory this is called lexical parsing)
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  4. #14

    tstringlist (help plz, im a noob)

    How did u learn delphi so well? books, classes, or tutorials on the net? Can you recommend something for me to learn? thanx

  5. #15
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    tstringlist (help plz, im a noob)

    I have never been on a Delphi course. I originally learnt Turbo Pascal while at university. When I started working and Delphi came out I worked through "learn delphi in 21 days". Since then I have used Delphi almost every day. I work with Delphi at work and do my games with it while at home.

    The best way to use Delphi is to spend a lot of time unsing it.

    There are a lot of usefull delphi sites on the web. This one isn't the best for beginners but there are enough people here that are willing to help.

    Get your self a Delphi book and work through it. It will give the ground work you need to move onto more advanced stuff.
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  6. #16

    tstringlist (help plz, im a noob)

    though this forum i can actually program now .
    I'm planning to make a game maker of some sort.
    I've already made a map editor
    Now i just need to learn more on collision detection, and how to make ur own scripting language :x :cry:

  7. #17
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    tstringlist (help plz, im a noob)

    Try doing something easier than a game maker to start with Have a look on my web site at Wumpus Hunt and try doing something similar.

    Dont make your own scripting language. Use Delphi Web Script - there is an old example of getting it to work in the Tutorials section.
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  8. #18

    tstringlist (help plz, im a noob)

    hmm...i'll have research on delphiwebscript to know what it is. and i'll look at ur site too. but one thing that is bothering me, collision detection.
    my old game maker is basically a tile engine. There are 19x11 tiles in the board. I was wondering how to stop my sprite when it hits a certain tile, such as a sprite running into a wall. All my tiles are images for now. So basically i'm trying to find out how to make an image move to another image and stop after it has hit that image.


    here is what i've done in my map editor so far:




    Ok, so my problem. If i was to create a sprite, how do i make it, so that the sprite will not move ontop of the castle or water?

    p.s: where can i find tutorials on directx and delphix

    I'm gonna prob use the map editor for a simple game that i will make.
    thanx for being patient with me

  9. #19

    tstringlist (help plz, im a noob)

    Have look at the tutorials on my website. Depsite the fact that they're for delphix, I think they'll answer your questions.

  10. #20
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    tstringlist (help plz, im a noob)

    There are basically two ways of doing collision detection:

    1. When a sprite moves it first calculates where it would move to. It then checks if that space is free. If the space is free it actually does the move - if the space is blocked it does not do the move.
    2. The second method is pixel collision detection. A sprite calculates its move, then does a collision based detection against all the other sprites (or all the sprites in its area) and if there is a collision it does not move.

    Based on your screen shot your sprites are positioned in a tile - use tile based collision detection.

    When you want to create a sprite. Create it but dont allocate it to a square in the game - first choose where it should go, if that tile is empty then place it - else choose another spot.

    I dont know DirectX I use the work of other people instead - look at DelphiX - there are lots of examples around the web (Learn to use google).
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •