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
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:Originally Posted by bekuzofu
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/
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.
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]
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
Check out the MkDir procedure.Originally Posted by bekuzofu
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.and how do i get the script to read unlimited strings?
Ehm. How can you use collision detection to keep things from colliding with eachother? There'd be nothing to detect. ;)on my game that i'm creating, how do i use collision detection between 2 images so they do not collide with each other?
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.
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 make so the movements dont flicker?
Take a look at the TForm's events, OnKeyPress. Within those events you can check if the desired keys are being pressed.how do i use the keyboard and assign keys for movement?
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/
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.Originally Posted by HopeDagger
Alright, I think I know what you mean. ;) Here's an example of reading all of the strings from a file you've loaded:Originally Posted by bekuzofu
[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]
Hopefully someboy else will be generous to help you out on those last two -- it's late here. ;)and can i have one of gdi backbuffering example with collision detection.
Game-Dev Journal: http://skirmish.dreamhosters.com/devlog/
You may want to check out this tutorial http://lionprod.f2o.org/articl...and can i have one of gdi backbuffering example with collision detection.
Alternatively, I'd recommend checking out delphix or omega. As you get a lot of stuff, like collision detection for free.
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.
Bookmarks