Mail Archives: djgpp/2001/01/13/19:06:29
From: | "Jose MF" <josemataf AT hotmail DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | little problem
|
Date: | Sat, 13 Jan 2001 16:22:00 -0000
|
Organization: | Netvisao NNTPCache
|
Lines: | 140
|
Message-ID: | <979430743.366296@news>
|
NNTP-Posting-Host: | 213.228.128.15
|
Mime-Version: | 1.0
|
X-Trace: | sagan.global-one.pt 979434399 29786 213.228.128.15 (14 Jan 2001 01:06:39 GMT)
|
X-Complaints-To: | abuse AT global-one DOT pt
|
NNTP-Posting-Date: | 14 Jan 2001 01:06:39 GMT
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Newsreader: | Microsoft Outlook Express 5.50.4133.2400
|
X-MimeOLE: | Produced By Microsoft MimeOLE V5.50.4133.2400
|
Cache-Post-Path: | news!unknown AT 213 DOT 228 DOT 145 DOT 187
|
X-Cache: | nntpcache 2.4.0b5 (see http://www.nntpcache.org/)
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
hail to all
I'm making a game and I would want to use allegro libraries to make it, I
was doing the source code for it, and I was testing it, using normal
textmode, whitout allegro, it worked.
But when I insert the - include "allegro.h" -, whitout making any changes,
the compiler got some errors:
Code:
#include <iostream.h>
#include <conio.h>
#include <dos.h>
#include "allegro.h"
#include "snake.h"
#include "screen.h"
Tela tela;
Snake *snake;
void play()
{
Tela tela;
char keyP='d';
int end=0;
clrscr();
while(!end)
{
while(!kbhit())
{
delay(100);
tela.clrSnake(*snake);
snake->makeBizz(keyP);
tela.makeBizz(*snake);
end=snake->actTouch(tela.chkTouch(*snake));
}
keyP=getch();
if(keyP == 'q') end=1;
}
}
void main()
{
snake=new Snake();
play();
}
Error:
Compiling: ASnake.cpp(8) Error: syntax error before ';'
In function 'void play()' :
ASnake.cpp(12) Error: 'Tela' undeclared (first use this function)
ASnake.cpp(12) Error: (Each undeclared identifier is reported only once
ASnake.cpp(12) Error: for each function it appears in.)
ASnake.cpp(12) : parse error before ';'
ASnake.cpp(21) 'tela' undeclared (first use this function)
That is!! I thing it something about first error, I'm gona share 'Tela'
Class:
- screen.h -
#include <stdlib.h>
#include <conio.h>
#include "snake.h"
#ifndef SCREEN_H
#define SCREEN_H
class Tela {
Coord item;
void drawSnake(Snake snake);
public :
Tela();
void makeBizz(Snake snake);
void clrSnake(Snake snake);
void genItem();
void drawItem();
int chkTouch(Snake snake);
};
#endif
- screen.cpp -
#include "screen.h"
Tela::Tela()
{
genItem();
}
//Snake Stuff
void Tela::makeBizz(Snake snake)
{
this->drawSnake(snake);
}
void Tela::drawSnake(Snake snake)
{
Coord member;
for(int cont=0;cont<snake.nMemb;++cont)
{
member=snake.member[cont]->retMember();
gotoxy(member.x, member.y);
cprintf("#");
}
}
void Tela::clrSnake(Snake snake)
{
Coord member;
for(int cont=0;cont<snake.nMemb;++cont)
{
member=snake.member[cont]->retMember();
gotoxy(member.x, member.y);
cprintf(" ");
}
drawItem();
}
int Tela::chkTouch(Snake snake)
{
Coord head;
head=snake.member[0]->retMember();
if(head.x==item.x && head.y==item.y)
{
genItem();
return 1;
}
return 0;
}
//Item Stuff
void Tela::genItem()
{
item.x=(random() % 80)+1;
item.y=(random() % 25)+1;
}
void Tela::drawItem()
{
// genItem();
gotoxy(item.x, item.y);
textcolor(RED);
cprintf("0");
textcolor(WHITE);
}
-------------------------------
Its all, Tanks in advance - note that this program runs whitout - include
"allegro.h"
Hail to all
- Raw text -