Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: tstringlist (help plz, im a noob)

  1. #1

    tstringlist (help plz, im a noob)

    how does the tstringlist work? is it a component? I'm new to delphi & dont have enough knowledge on strings.

    i need to know to set one up and use it. thanx

  2. #2

    Re: tstringlist (help plz, im a noob)

    Quote Originally Posted by bekuzofu
    how does the tstringlist work? is it a component? I'm new to delphi & dont have enough knowledge on strings.

    i need to know to set one up and use it. thanx
    TStringList is a class, which in a sense is very similar to a component. Anyways, here's how to create/use one:

    Code:
    procedure MyProc;
    var
      S: TStringList;
    begin
      S := TStringList.Create; // This is the class's constructor, all classes need this to be called in order to have the object instantiated
      S.Add('Cheese');
      S.Add('Fromage');
      S.Strings[0] := 'A small houseboat';
      S.Sort;
    
      S.Free;  // Don't forget to deallocate!
    end;
    Game-Dev Journal: http://skirmish.dreamhosters.com/devlog/

  3. #3

    tstringlist (help plz, im a noob)

    so what happens if i want to load the strings from textfile when the application runs, and how to save them? this will help me alot thanx.

  4. #4

    tstringlist (help plz, im a noob)

    Loading is just as easy. TStringList contains a LoadFromFile method...

    [pascal]
    procedure MyProc;
    var
    S: TStringList;
    begin
    S := TStringList.Create; // constructor
    S.LoadFromFile('LoadMyStrings.txt'); // Load our file
    ShowMessage( S.Strings[0] );// Show first element in the list
    S.Free; // Free Memory when you no longer need it, this calls the destructor.
    end;
    [/pascal]
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  5. #5

    tstringlist (help plz, im a noob)

    this is helping me alot and i thank you.

    but what happens if i want the strings to be read on a txt file, line by line, as if it were a scripting language?
    EDIT:
    actually...i kinda got it
    but how do i create a new folder in the script?
    and how do i get the script to read unlimited strings?

    off topic:
    on my game that i'm creating, how do i use collision detection between 2 images so they do not collide with each other?
    how do i make so the movements dont flicker?
    how do i use the keyboard and assign keys for movement?

    my next subject....how do i use delphix? or animation

  6. #6

    tstringlist (help plz, im a noob)

    Quote Originally Posted by bekuzofu
    but how do i create a new folder in the script?
    Check out the MkDir procedure.

    and how do i get the script to read unlimited strings?
    You mean read strings until it reaches the end? The 'Count' member of at TStringList tells you how many strings are present inside the stringlist, so you'll know how many strings to read in.

    on my game that i'm creating, how do i use collision detection between 2 images so they do not collide with each other?
    Ehm. How can you use collision detection to keep things from colliding with eachother? There'd be nothing to detect. ;)

    Okay, okay. Fine. No more sarcasm. A common method is the usage of bounding boxes, which is an imaginary box around a sprite. To determine if there's a collision, check if those two rectangles intersect.

    how do i make so the movements dont flicker?
    Assuming you're using GDI+ for your drawing, it's because you're clearing the whole screen and then drawing your new moved sprite. Within that time that the screen was cleared you're seeing that flicker. The easiest solution for this is to make use of a backbuffer. This would be an image (not visible to the user) that you'd draw your whole scene onto, and then draw that image onto the screen, so you don't see any flickering.

    how do i use the keyboard and assign keys for movement?
    Take a look at the TForm's events, OnKeyPress. Within those events you can check if the desired keys are being pressed.

    Sorry if my responses are a bit vague -- you really asked a whole lot of things that were very broad in category. If you were to be a bit more specific in what exactly you want to know, then I'm sure myself and the other forum-mongers would be glad to help. :)
    Game-Dev Journal: http://skirmish.dreamhosters.com/devlog/

  7. #7

    tstringlist (help plz, im a noob)

    Quote Originally Posted by HopeDagger
    Quote Originally Posted by bekuzofu
    but how do i create a new folder in the script?
    Check out the MkDir procedure.

    and how do i get the script to read unlimited strings?
    You mean read strings until it reaches the end? The 'Count' member of at TStringList tells you how many strings are present inside the stringlist, so you'll know how many strings to read in.

    on my game that i'm creating, how do i use collision detection between 2 images so they do not collide with each other?
    Ehm. How can you use collision detection to keep things from colliding with eachother? There'd be nothing to detect.

    Okay, okay. Fine. No more sarcasm. A common method is the usage of bounding boxes, which is an imaginary box around a sprite. To determine if there's a collision, check if those two rectangles intersect.

    how do i make so the movements dont flicker?
    Assuming you're using GDI+ for your drawing, it's because you're clearing the whole screen and then drawing your new moved sprite. Within that time that the screen was cleared you're seeing that flicker. The easiest solution for this is to make use of a backbuffer. This would be an image (not visible to the user) that you'd draw your whole scene onto, and then draw that image onto the screen, so you don't see any flickering.

    how do i use the keyboard and assign keys for movement?
    Take a look at the TForm's events, OnKeyPress. Within those events you can check if the desired keys are being pressed.

    Sorry if my responses are a bit vague -- you really asked a whole lot of things that were very broad in category. If you were to be a bit more specific in what exactly you want to know, then I'm sure myself and the other forum-mongers would be glad to help.
    can i have a sample of the The 'Count' member of at TStringList? (hope u know what i mean), and can i have one of gdi backbuffering example with collision detection. I think if i solve those two, i am set to go. Through this forums, I have learned to use strings and i'm glad people here can help me even though i'm a noob. Once i'm finished learning gdi, i'll go onto delphix. Thanx to all.

  8. #8

    tstringlist (help plz, im a noob)

    Quote Originally Posted by bekuzofu
    can i have a sample of the The 'Count' member of at TStringList? (hope u know what i mean)
    Alright, I think I know what you mean. ;) Here's an example of reading all of the strings from a file you've loaded:

    [pascal]
    procedure MyProc;
    var
    a: integer;
    S: TStringList;
    begin
    S := TStringList.Create;
    S.LoadFromFile("myfile.txt");
    for a := 0 to S.Count-1 do
    begin
    SomeMemo.Lines.Append(S.Strings[a]);
    end;
    end;
    [/pascal]

    and can i have one of gdi backbuffering example with collision detection.
    Hopefully someboy else will be generous to help you out on those last two -- it's late here. ;)
    Game-Dev Journal: http://skirmish.dreamhosters.com/devlog/

  9. #9

    tstringlist (help plz, im a noob)

    and can i have one of gdi backbuffering example with collision detection.
    You may want to check out this tutorial http://lionprod.f2o.org/articl...

    Alternatively, I'd recommend checking out delphix or omega. As you get a lot of stuff, like collision detection for free.

  10. #10

    tstringlist (help plz, im a noob)

    I'm currently trying to make a scripting language. I have 3 things to ask.

    First of all. Using a tstringlist, how do i make it so that I can read a specific line and tell it do a command.

    Example:

    if i made a command called #text(hi);

    The string would first read the first word to know what type of command, in this case its to show text somewhere in the program. the bracket will tell it what to type or what file.

    and all together if executed, the screen will show:

    hi


    my second question, is if u understand on queston1, but if u get what i mean, how do i make a scripting language wuth commands such as while/loop, do/loop, if/then .etc?

    my last question, is how do make files so that when i click on the file, it opens up my program? and how do i make .exe files that are made by the user?

    This is what i am stuck on, plz help me on this one thanx.

Page 1 of 3 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
  •