• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

kingpinzs

how do you use a delay in c++

15 posts in this topic

How do I use a delay I tryed this and I get that it is undeclared delay(DELAY); I am using dev-cpp
0

Share this post


Link to post
Share on other sites

void display_logo()
{

cout<<" EEEEEEEE L IIIIIII ZZZZZZZ AAA "<<endl;
delay(DELAY);
cout<<" E L I Z A A "<<endl;
delay(DELAY);
cout<<" E L I Z A A "<<endl;
delay(DELAY);
cout<<" EEEEE L I Z A A "<<endl;
delay(DELAY);
cout<<" E L I Z AAAAAAA "<<endl;
delay(DELAY);
cout<<" E L I Z A A "<<endl;
delay(DELAY);
cout<<" EEEEEEEE LLLLLLLL IIIIIII ZZZZZZ A A "<<endl;
}

delay(RanNum(DELAY));


[edited by - kingpinzs on February 9, 2004 10:15:27 PM]
0

Share this post


Link to post
Share on other sites
wtf is that ?

"A soldier is a part of the 1% of the population that keeps the other 99% free" - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA
0

Share this post


Link to post
Share on other sites
there is no fuction Delay or RandNum! Wtf book you been reading.

C++ DOESNT HAVE JUST ANY NAMED FUNTION!


0

Share this post


Link to post
Share on other sites
I got it from
HERE
http://www.pscode.com/vb/scripts/ShowCode.asp?lngWId=3&txtCodeId=5369
I downloaded the source and I cant get it to run
0

Share this post


Link to post
Share on other sites
It looks like ranNum might just be a user defined function, but its nowhere in the code. same thing with delay and DELAY might be a preprocessor macro that the author should have made..but again its not there.
0

Share this post


Link to post
Share on other sites
quote:
Original post by kingpinzs
I got it from
HERE
http://www.pscode.com/vb/scripts/ShowCode.asp?lngWId=3&txtCodeId=5369
I downloaded the source and I cant get it to run


I REVISED THE CODE TO SOMETHING THAT WORKS!
REPLACE THE WHOLE SOURCE FILE THITH THIS!

/* Including Files */
# include<iostream>
# include<conio.c>
# include<string>
# include<time.h>
# include<math.h>
# include<stdlib.h>
# include<windows.h>
# include<stdio.h>
# include<fstream>

/* Defining Costants*/
// Max. length in characters of any automated reply ( Keyword only)

# define MAX_RESP_LEN 65
// Max. number of responses for any keyword

# define MAX_RESP_NO 20
// Max. number of keywords

# define MAX_KEY 13
// Max. number of Transpositions

# define TRANSPOSE 12
// Max. Size Of User Input

# define MAX_USER_INPUT 100
// Max. Length of Keyword

# define MAX_KWD_LEN 20
// Delay involved in typing (in ms)

# define DELAY 20

/* Defining Global Variables */

using namespace std;
char user[30];
// for word transpositions

char wordin[TRANSPOSE][MAX_RESP_LEN];
char wordout[TRANSPOSE][MAX_RESP_LEN];
int RanNum(int max);
void initialize_global();

class progstr
{
public:
char userip[MAX_USER_INPUT];
char keyword[30];
int keyfound;
int keyno;
int nullip;
// constructor

progstr()
{
keyno=-1;
nullip=0;
}
}ip;

class resp
{
int tot_resp;
int last_resp;
char replys[MAX_RESP_NO][MAX_RESP_LEN];
char word[MAX_KWD_LEN];
public:
// constructor

resp()
{
tot_resp=0;
last_resp=-1;
}
int getcount()
{
return last_resp;
}
void addword(char str[MAX_KWD_LEN])
{
strcpy(word,str);
}
char * getword()
{
return word;
}
void addresp(char str[MAX_RESP_LEN])
{
strcpy(replys[++last_resp],str);
}
void display_resp(int num);
void quit_display_resp(int num);

};
void display_logo()
{

cout<<" EEEEEEEE L IIIIIII ZZZZZZZ AAA "<<endl;
Sleep(DELAY);
cout<<" E L I Z A A "<<endl;
Sleep(DELAY);
cout<<" E L I Z A A "<<endl;
Sleep(DELAY);
cout<<" EEEEE L I Z A A "<<endl;
Sleep(DELAY);
cout<<" E L I Z AAAAAAA "<<endl;
Sleep(DELAY);
cout<<" E L I Z A A "<<endl;
Sleep(DELAY);
cout<<" EEEEEEEE LLLLLLLL IIIIIII ZZZZZZ A A "<<endl;
}
void display_line()
{
int width=80;
int i=0;
int x=wherex();
int y=wherey()+1;
x=40;
for(int k=0;k<40;k++)
{
Sleep(DELAY);
gotoxy(x+k,y);
cout<<(char)240;
gotoxy(x-k,y);
Sleep(DELAY);
cout<<(char)240;
}
cout<<"\n";
}

void resp :: display_resp(int num)
{
cout<<"ELIZA > ";
for(int i=0;i<strlen(replys[num]);i++)
{
// for deliberate typing errors

if(RanNum(6)==0)
{ char c=RanNum(100);
if(c==''\n'' || c==''\b'' || c==13)
cout<<"w";
else
cout<<c;
Sleep(RanNum(DELAY));
cout<<"\b";
}

if(replys[num][i]==''*'')
{
char * s1=ip.userip+strlen(ip.keyword);
short int flag=0;
for(int m=0;m<TRANSPOSE;m++)
{
char * s2=wordin[m];
char *ptr=NULL;
ptr=strstr(s1,s2);

if(ptr!=NULL)
{
// transposition word found in the

// user input

flag=1;

// printing text before wordin[m]

int times=ptr-s1;
for(int i=0;i<times;i++)
{
Sleep(DELAY);
cout<<ip.userip[strlen(ip.keyword)+i];
}
// printing the wordout

cout<<wordout[m];
// printing the left overs

char c;
c=*(ptr+strlen(wordin[m]));
int t=0;
while(c!=''\0'')
{
cout<<*(ptr+strlen(wordin[m])+t);
t++;
c=*(ptr+strlen(wordin[m])+t);
}
}
} // end of for

// if flag is still zero , this means no transpose.

if(0==flag)
{
char c;
c=*(s1+strlen(ip.keyword));
int t=0;
while(c!=''\0'')
{
cout<<*(s1+t);
t++;
c=*(s1+t);
}
} // end of if

break;
}
else
{
cout<<replys[num][i];
Sleep(RanNum(DELAY));
}
} // end of for

cout<<"\n"<<user<<" > ";
}
void resp :: quit_display_resp(int num)
{
cout<<"ELIZA > ";
for(int i=0;i<strlen(replys[num]);i++)
{
// for deliberate typing errors

if(RanNum(6)==0)
{ char c=RanNum(100);
if(c==''\n'' || c==''\b'' || c==13)
cout<<"w";
else
cout<<c;
Sleep(RanNum(DELAY));
cout<<"\b";
}
cout<<replys[num][i];
Sleep(RanNum(DELAY));
} // end of for

}
resp keys[MAX_KEY];
int RanNum(int max)
{
//randomize();

return rand() % max;
}
void find_keyword()
{
int len=0;
int lenkey=0;
int key_no=0;
char teststr[50];
while((ip.keyfound==0) &&(key_no!=MAX_KEY))
{
// getting the length of the keyword

lenkey=strlen(keys[key_no].getword());

char *ptr=NULL;
ptr=strstr(ip.userip,keys[key_no].getword());
if (ptr!=NULL)
{
// keyword found !

ip.keyfound=1;
ip.keyno=key_no;
strcpy(ip.keyword,keys[key_no].getword());
break;
}
/*//////////////////////////////////////////
for(int i=0;i<lenkey;i++)
{
teststr[i]=ip.userip[i];
}
teststr[i]=''\0'';
if (strcmp(teststr,keys[key_no].getword())==0)
{
ip.keyfound=1;
ip.keyno=key_no;
strcpy(ip.keyword,keys[key_no].getword());
}
//////////////////////////////////////////*/


key_no++;
}
}

void read_from_file()
{
ifstream fin;
int index=-1;
fin.open("eliza.dat");
char line[MAX_RESP_LEN];
while(fin)
{
fin.getline(line,MAX_RESP_LEN);
char *ptr=NULL;
ptr=strstr("@KWD@",line);
if(strlen(line)<1)
{
break;
}
else if(ptr!=NULL)
{
// the next line is a keyword

fin.getline(line,MAX_RESP_LEN);
keys[++index].addword(line);
}
else
{
// it is a response

keys[index].addresp(line);
}

} // end of while

} // end of function


int main()
{
clrscr();

display_line();
display_logo();
display_line();
// for initializing the global variables

initialize_global();

// for no response by the user.

resp null_resp;
null_resp.addresp("HUH ?");
null_resp.addresp("WHAT ?");
null_resp.addresp("COME AGAIN ?");
null_resp.addresp("HOW I AM SUPPOSED TO TALK IF YOU DON''T SAY ANYTHING ?");

// upon logging in

resp signon;
signon.addresp("HI, I''M ELIZA. WHAT DO YOU WANT TO TALK ABOUT ?");
signon.addresp("SO HOW ARE YOU DOING TODAY ?");
signon.addresp("HELLO, WHAT''S UP TODAY ?");

// when no key found

resp no_key;
no_key.addresp("PLEASE GO ON...");
no_key.addresp("WHAT DOES THAT SUGGEST TO YOU ?");
no_key.addresp("I SEE");
no_key.addresp("I''M NOT SURE I KNOW WHAT YOU ARE TALKING ABOUT ");
no_key.addresp("WHAT''S THAT SUPPOSED TO MEAN ?");
no_key.addresp("CAN YOU CLARIFY THAT A BIT ?");
no_key.addresp("THAT''S INTERESTING...");
no_key.addresp("AND ????");

resp bye;
bye.addresp("GOOD BYE, HAVE A NICE DAY...");
bye.addresp("BYE, HOPE TO SEE YOU SOON...");
bye.addresp("BYE AND KEEP IN TOUCH...");
// reading data from dictionary

read_from_file();

// STARTING CONVERSATION WITH THE USER

// welcoming the user


cout<<"ELIZA > (PLEASE TYPE IN ALL CAPS) WHAT''S YOUR NAME DEAR ?\n";
cin>>user;
signon.display_resp(RanNum(signon.getcount()));
fflush(stdin);
gets(ip.userip);
strcpy(ip.userip,strupr(ip.userip));
while(strcmp(ip.userip,"BYE")!=0)
{
find_keyword();
if(strlen(ip.userip)<1)
{
null_resp.display_resp(RanNum(null_resp.getcount()));
}
else if(ip.keyfound==1)
{
keys[ip.keyno].display_resp(RanNum(keys[ip.keyno].getcount()));
}
else
{
no_key.display_resp(RanNum(no_key.getcount()));
}
// again returning to normal values of the data items

strcpy(ip.userip," ");
ip.keyno=-1;
ip.keyfound=0;
fflush(stdin);
gets(ip.userip);
strcpy(ip.userip,strupr(ip.userip));
} // end of while

bye.quit_display_resp(RanNum(null_resp.getcount()));
cout<<endl;
display_line();
cout<<"\t\t\tIMPORTANT\n\nPlease note that the current functionality and \
features of this program are very limited and they are just for \
accompanying the article that I posted on Planet Source Code. If you want \
to make this program more intelligent, make entries in Eliza.Dat file. \
\n You can also increase the string manipulation power of the program, \
like considering multiple lines from the user, etc. I had written this code in 1 1/2 hr. \
just to make it more easier for the readers of my article about what is \
happening.\n\n HOW SMART YOU MAKE YOUR ELIZA DEPENDS ON HOW FAR YOU EXTEND \
THIS PROGRAM. THERE IS PRACTICALLY NO LIMIT ! \n\n\n\
THIS CODE IS THE MINIMAL WORKING SKELETON !!\n\n"
;
display_line();
getch();
}


void initialize_global()
{
strcpy(wordin[0],"ARE");
strcpy(wordout[0],"AM");

strcpy(wordin[1],"AM");
strcpy(wordout[1],"ARE");

strcpy(wordin[2],"WERE");
strcpy(wordout[2],"WAS");

strcpy(wordin[3],"WAS");
strcpy(wordout[3],"WERE");

strcpy(wordin[4],"YOU");
strcpy(wordout[4],"ME");

strcpy(wordin[5]," I ");
strcpy(wordout[5],"YOU");

strcpy(wordin[6],"YOUR");
strcpy(wordout[6],"MY");

strcpy(wordin[7],"MY");
strcpy(wordout[7],"YOUR");

strcpy(wordin[8],"I''VE");
strcpy(wordout[8],"YOU''VE");

strcpy(wordin[9],"YOU''VE");
strcpy(wordout[9],"I''VE");

strcpy(wordin[10],"I''M");
strcpy(wordout[10],"YOU''RE");

strcpy(wordin[11],"YOU''RE");
strcpy(wordout[11],"I''M");

strcpy(wordin[12],"ME");
strcpy(wordout[12],"YOU");

strcpy(wordin[13],"YOU");
strcpy(wordout[13],"ME");

}



0

Share this post


Link to post
Share on other sites
quote:
Original post by kingpinzs
I got it from
HERE
http://www.pscode.com/vb/scripts/ShowCode.asp?lngWId=3&txtCodeId=5369
I downloaded the source and I cant get it to run


The author states he''s using Turbo C IDE 3.0. Don''t know much about it personally, but it sounds like those functions are Turbo C specific.

0

Share this post


Link to post
Share on other sites
quote:
Original post by iamjoesname
quote:
Original post by kingpinzs
I got it from
HERE
http://www.pscode.com/vb/scripts/ShowCode.asp?lngWId=3&txtCodeId=5369
I downloaded the source and I cant get it to run


The author states he''s using Turbo C IDE 3.0. Don''t know much about it personally, but it sounds like those functions are Turbo C specific.




if u would look at all the posts ude see that i ported it and it works well.


0

Share this post


Link to post
Share on other sites
quote:
Original post by DerAnged

if u would look at all the posts ude see that i ported it and it works well.



Congratulations. I was merely pointing out that perhaps the reason the author''s code won''t compile is because the Delay() and RandNum() functions are compiler specific. At no point did I even suggest that your code did not work well.
0

Share this post


Link to post
Share on other sites
quote:
Original post by iamjoesname
quote:
Original post by DerAnged

if u would look at all the posts ude see that i ported it and it works well.



Congratulations. I was merely pointing out that perhaps the reason the author''s code won''t compile is because the Delay() and RandNum() functions are compiler specific. At no point did I even suggest that your code did not work well.






0

Share this post


Link to post
Share on other sites
well you know every code works even DELAY but just not delay

but the the code DerAnged put up works greate.

I have another question how can you make it so that you input words and it will save them to the data file?
0

Share this post


Link to post
Share on other sites
quote:
Original post by kingpinzs
well you know every code works even DELAY but just not delay

but the the code DerAnged put up works greate.

I have another question how can you make it so that you input words and it will save them to the data file?


look up fstream.


0

Share this post


Link to post
Share on other sites
int main(){

double delay=0,x=0;
delay = 500000;
for(x=1;x{
}
return 0;

}

'A library consists of the actual binary code behind the API. You link your game code to the library to make everything work.'

[edited by - joeyzt on February 9, 2004 11:48:38 PM]
0

Share this post


Link to post
Share on other sites