*edited everything clean so I can post my new problem hehe.
Printable View
*edited everything clean so I can post my new problem hehe.
>>y=ROWS//2;
You have an extra slash there.
Thanks.
And here is my Compile error. the problem is is that it is saying there is a problem with text that isnt there.Code:#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <dos.h>
#define FACE 0x08 //Face Character number
#define BLANKSPACE 0x08 //Backspace charactor
#define BLANK 0x20 //Blacnk character number
#define LOOP 100 //number of faces to dispay
#define PAUSE 150000 //pause time (0-16,000,000)
#define VIDEO 0x10 //video interrupt
#define COLS 80 //screen width
#define ROWS 25 //Screen rows
void cls(void);
void locate(int col , int row);
int rnd(int range);
void main ()
{
int t,x,y;
unsigned long p; //p=pause loop
cls(); //clear the screen
seedrnd(); //set randomizer
// start at the center of the screen
x=COLS/2; //half screen width
y=ROWS/2; //half screen hight
//move the drunk LOOP number of times
for (t=0;t<LOOP;t++)
{
locate(x.y); //move cursor
putchar(FACE); //be happy
for(p=0;p<PAUSE;p++); //pause
/*
SCript above moves the drunk dude RYCHER
all around. it will be funny
*/
x+=(rnd(3)-1); //new random x
y+=(rnd(3)-1); //new random y
/*These next things make sure RYCHER
doesnt float off the screen on accident
*/
if(x<1) x=80; //wrap left
if(x>80) x=1; //wrap right
if(x<1) y=25; //wrap to the bottom
if(x>25) y=1; //wrap top
/*This part next will make him
appear back in the middle
*/
putchar(BACKSPACE); //back up
putchar(BLANK); //and erace the drunk
}
}
void cls(void)
{
union REDS reds;
regs.h.ah=0x06; //call function 6, scroll window
regs.h.al=0.x00; //clear screen
regs.h.bh=0x07; //make screen blank color
regs.h.ch=0x00; //upper left row
regs.h.cl=0x00; //upper left column
regs.h.dh=ROWS-1; //lower right roow
regs.h.dl=cols-1; //lower right column
int86(VIDEO,®s,®s);
locate(0,0); //Home the cursor
}
void locate(int col,int row)
{
union REGS regs;
regs.h.ah=0x02; //video function 2, move the cursor
regs.h.bh=0x00; //videos screen which is always 0
regs.h.dh=row; //cursors column position
regs.h.dl=col: //cursors row position
int86(VIDEO,®s,®s);
}
int rnd(int range)
{
int r;
r=rand()%range; //split up a random number
}
void seedrnd(void)
{
srand((unsigned)time(NULL);
}
Why is it missing the dos.h file? And why am I having wrong code in blank space. Man this stuff is annoying.Code:Miracle C Compiler (r3.2), written by bts.
line 4: #include dos.h ignored--file not found.
Compiling c:\documents and settings\justin\desktop\compiled files\drunkdude.c
main
c:\documents and settings\justin\desktop\compiled files\drunkdude.c: line 36: bad . ref
'{ locate(x.y)'
aborting compile
>>locate(x.y)
You should have a comma, not a period.
thats the new compiler error.Code:unrecognised types in comparison 'for(p=0'
Im really trying not to be too much of a pain in the ass but this is really confusing me. Its talking about the pause part i presume. Ugh what a pain.
You might run into problems using this program on OSes such as Win2k, NT, or XP (?). You *might* consider an older dos compiler since one will have the functions that you're using int86 on now, and it will have dos.h.
You can download the relic Turbo C for free, but you must register first. Look in the museum afterwards.
pause may be the problem since you also have stdlib included. Try renaming that. I'd use a delay function from time.h instead of a loop since the loop will run at different speeds depending on the speed of the user's processor.
HTH
Actually I am teaching myself over the summer and I picked up an old C book and flipped through it. (C for Dummies Vol one.) They have some sourse code in the back and I just entered it into one because it looked cool. But Ill get a different compiler too.
>>*edited everything clean so I can post my new problem hehe.<<
Err, please don't delete posts that are relevant to the thread unless you really have to. Other people learn from your questions too, or at least, they would if they can read them ;)
Ok. Sorry about that I just didnt want to put too much code onto this thread and make it confusing.Quote:
Originally posted by Hammer
>>*edited everything clean so I can post my new problem hehe.<<
Err, please don't delete posts that are relevant to the thread unless you really have to. Other people learn from your questions too, or at least, they would if they can read them ;)