struct WEAPON
{
char name[20];
int damage;
int cost;
};
WEAPON w[5];
void SetWeapon(int instance,char *weaponname, int damage,int cost)
{
w[instance].name = weaponname;
w[instance].damage = damage;
w[instance].cost = cost;
}
void InitWeapons(void)
{
SetWeapon(0,"bare hands",0,0);
SetWeapon(1,"knife",2,10);
SetWeapon(2,"dagger",4,100);
SetWeapon(3,"short sword",6,500);
SetWeapon(4,"sword",8,1000);
}
2. How can i get the text to work in the window the same way it did in dos? in dos it used to scroll down the screen automatically as you printed more text, but with drawtext, you have to give pixel co-ordinates.
I haven''t been able to find any good tutorials on this, everywhere I look, they teach you how to make a basic window, then jump to direct draw, or adavanced windows stuff and mfc.
🔒 Locked
Simple Textgame programming
Advertisement
Original Post
I''ve been trying to make some text rpg games like I used to in QBasic with Borland''s free compiler, and for windows.
1. I can''t get this code to compile
, what is the right way to assign strings?
Does the code just not work, or do you get a compiler error? If it is an error, post the error message.
If you are doing strictly a text based game, an easier way to do is just to do a console app. This way, your entry point is main(), not winmain() and you just have to use printf and scanf/getch for console stuff. If you want to use windows and output to a window, I don''t remember at the moment. I''ll have to look it up.
---
Make it work.
Make it fast.
If you are doing strictly a text based game, an easier way to do is just to do a console app. This way, your entry point is main(), not winmain() and you just have to use printf and scanf/getch for console stuff. If you want to use windows and output to a window, I don''t remember at the moment. I''ll have to look it up.
---
Make it work.
Make it fast.
if you are using char arrays for strings, you have to #include < string.h> or , and then use the string functions in there. these include strcpy (to copy a string), strcat (to concatenate(sp?) - add to the end of an existing string).
some people would say use the STL strings, as they are fun and easy.
--- krez (krezisback@aol.com)
some people would say use the STL strings, as they are fun and easy.
--- krez (krezisback@aol.com)
www.geocities.com/promitr/DrugWars.zip
I wrote it myself for ppl who need stuff like this. VERY heavily commented, and uses the a little bit. It''s source and works in MSVC6, i dont know if Borlan will run it.
-----------------------------
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.
I wrote it myself for ppl who need stuff like this. VERY heavily commented, and uses the
-----------------------------
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.
I''m not making a console app, the whole point of this is to learn windows.
the error is something about needing an lvalue
i''ve tried w[instance].name = weaponname;
w[instance].name = &weaponname
w[instance].name = *weaponname;
same error.
Thanks promit, I''m looking through your file now
the error is something about needing an lvalue
i''ve tried w[instance].name = weaponname;
w[instance].name = &weaponname
w[instance].name = *weaponname;
same error.
Thanks promit, I''m looking through your file now
the console does it just like it did in DOS (ok, well not exactly, i heard someone mutter... but damn close anyways). if you feel you must do it with windows, you are going to have to work out all the details yourself, just to emulate something that you already have.
--- krez (krezisback@aol.com)
--- krez (krezisback@aol.com)
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement