delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/03/20/17:32:50

Message-ID: <20010320223103.87893.qmail@web13301.mail.yahoo.com>
Date: Tue, 20 Mar 2001 14:31:03 -0800 (PST)
From: Rafael Frongillo <rmf9 AT yahoo DOT com>
Subject: parse error before class definition
To: djgpp AT delorie DOT com
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

Hello

I am writing a program that uses class declaration and
inheritance, the latter of which shouldn't really
influence to my problem. When I compile the following
files (actually the last one that I am sending), I get
an error that says "walls.h:8: parse error before
`{'". I know what a parse error is, but I can't see
where I messed up, or if I did. I tried installing the
compiler again, renaming the file, putting a
semi-colon before the file, and other exotic attemps
at solving the problem, but all for naught. Please
tell me what I should do.

Thanks!

-Rafael Frongillo

***The problem file:

#ifndef WALLS_H

#include <stdlib.h>
#include <math.h>
#include <allegro.h>
#include "guy.h"

class wall {	//walls.h:8: parse error before `{'
	public:
	
	wall();
	wall(int x, int y, int w, int h, int u, int d, int l,
int r, int t);

	void draw(int b);
	int check(int x, int y, BITMAP *chpic);
	int check(int &xx, int &yy, int ww, int hh, int &dd);
	int checkg(int &gx, int &gy, int gw, int gh, int
dir3d);
	void destroy();

	int x,y,w,h,up,dn,lf,rt,typ,fake;

};

wall walls[MAXWALL];

#define WALLS_H
#endif

***The file it #includes:

#ifndef GUY_H

#include <allegro.h>

#define RT			1
#define LF			-1
#define UP			2
#define DN			3
#define FD			4

#define FB			0
#define FF			-1
#define F1			1
#define F2			2
#define F3			3
#define w1			-2
#define w2			-3
#define W1			11
#define W2			12
#define W3			13
#define EX			100
#define XF			101
#define	XN			102
#define DD			89
#define D0			90
#define D1			91
#define D2			92
#define D3			93
#define D4			94
#define D5			95
#define D6			96
#define D7			97
#define D8			98
#define D9			99

#define MAXWALL		200
#define MAXDOOR		10
#define MAXMSL		10
#define MAXLEV		2

#define G1			0
#define B1			1

#define GH			14
#define GW			25

struct MSL {
	int x,y,w,h,d,typ,range,pn,dx,dy,exp; BITMAP *ch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FB,FB,
FB,FB,FB,FB,FB, FB,FB,FB,FB,W2 },
{ W1,F1,F1,F1,F1, F1,F1,F1,F1,DD, F1,F1,F1,F1,F1,
F1,F1,F1,F1,F1, F1,F1,F1,F1,W1}},

{{W1,F1,FF,F1,F1, F1,FB,w2,FB,F1, F1,F1,FB,FB,F1,
F1,F1,F1,F1,F1, FF,F1,FB,FB,F1 },
{ w2,FB,FF,W2,FB, FB,FB,W1,FB,W1, F1,W1,FB,FB,w2,
FB,FB,W1,FB,w1, F1,W1,FB,FB,W2 },
{ W2,F1,FF,W2,F1, F1,F1,F1,FB,F1, F1,FB,F1,F1,W1,
F1,F1,FB,FB,F1, F1,F1,F1,F1,W2 },
{ W2,F1,FF,W2,FB, F1,F1,W2,FB,F1, F1,FB,FB,FB,XF,
F1,FB,FB,F1,F1, F1,F1,FB,F1,w2 },
{ W1,F1,F1,W1,FB, F1,FB,W1,F1,W1, F1,W1,FB,FB,W2,
FB,FB,W1,FB,W1, F1,W1,F1,F1,W1}}
};

int doorgrid[MAXLEV][MAXDOOR][2] = { //type, dest
(index)
	{{ D1, 1 }, { D1, 3 }, { EX, EX }, { D1, 4 }, { D1, 0
}}
};

int bgs[11][10] = {
	{ 11 },
	{ G1,0,0,5,1,1 },
	{ G1,40,0,6,1,1 },
	{ G1,50,0,5,1,1 },
	{ G1,80,0,4,1,1 },
	{ G1,100,0,3,1,1 },
	{ G1,120,0,7,1,1 },
	{ G1,200,0,5,1,1 },
	{ G1,220,0,3,1,1 },
	{ G1,240,0,6,1,1 },
	{ G1,300,0,4,1,1 }
};

BITMAP *buf, *exitp, *door1,
	*wallpics, *fswall, *bswall, *ftwall, *btwall,
*fplank, *bplank;

int wallnum, doornum, scrx, scry, width = GW*30+20,
height = GH*88+100;;
const int pink = makecol16(255,0,255), white =
makecol16(255,255,255),
	black = makecol16(0,0,0), innerw = 600, innerh = 400,
	

#define GUY_H
#endif

***The files that #include the problem file:

#include <stdio.h>
#include <allegro.h>
#include "walls.h"

wall::wall() {}
wall::wall(int xx, int yy, int ww, int hh, int uu, int
dd, int ll, int rr, int tt) {
	x = xx; y = yy; w = ww; h = hh; up = uu; dn = dd; lf
= ll; rt = rr; typ = tt;
	switch (typ) {
		case FF :
		case w1 :
		case w2 : fake = 1; break;
		default : fake = 0; break;
	}
}

void wall::draw(int b) {
	if (scrx-30<x+w && scrx+innerw+30>x && scry-30<y+h &&
scry+innerh+30>y) {
	if (b) {
		switch (typ) {
			case F1 : 
			case FF : 
			
masked_blit(bplank,buf,0,0,x-5,y-10,bplank->w,bplank->h);
				break;
			case w1 :
			case W1 :
			
masked_blit(bswall,buf,0,0,x-5,y-10,bswall->w,bswall->h);
				break;
			case w2 :
			case W2 :
			
masked_blit(btwall,buf,0,0,x-5,y-10,btwall->w,btwall->h);
				break;
			case XF :
			
masked_blit(exitp,buf,0,0,x-5,y-10,exitp->w,exitp->h);
				break;
			case D1 :
			
masked_blit(door1,buf,0,0,x-5,y-10,door1->w,door1->h);
				break;
		}
	}
	else {
		switch (typ) {
			case F1 : 
			case FF :
			
masked_blit(fplank,buf,0,0,x-5,y-10,fplank->w,fplank->h);
				break;
			case w1 :
			case W1 :
			
masked_blit(fswall,buf,0,0,x-5,y-10,fswall->w,fswall->h);
				break;
			case w2 :
			case W2 :
			
masked_blit(ftwall,buf,0,0,x-5,y-10,ftwall->w,ftwall->h);
				break;
		}
	}}
}

int wall::check(int &xx, int &yy, int ww, int hh, int
&dd) {
	if (xx+ww-4>x && xx<x+w-4 && yy+hh-2>y && yy<y+h-2) {
		switch (dd) {
			case RT : if (!rt||fake) { xx = x - ww; dd = LF;
return 1; } break;
			case LF : if (!lf||fake) { xx = x + w; dd = RT;
return 1; } break;
			case DN : if (!dn||fake) { yy = y - hh; return 1; }
break;
			case UP : if (!up||fake) { yy = y + h; return 1; }
break;
		}
	}
	return 0;
}

int wall::checkg(int &gx, int &gy, int gw, int gh, int
dir3d) {
	if (gx+gw/4>x && gx-gw/4<x+w && gy+gh>y && gy<y+h) {
		switch (dir3d) {
			case RT : if (!rt) { gx = x - gw/4; return 1; }
break;
			case LF : if (!lf) { gx = x + w + gw/4; return 1; }
break;
			case DN : if (!dn) { gy = y - gh; return 1; }
break;
			case UP : if (!up) { gy = y + h; return 1; } break;
		}
	}
	return 0;
}
int wall::check(int xx, int yy, BITMAP *chpic) {
	for (int i=0; i<chpic->w; i++) {
		for (int j=0; j<chpic->h; j++) {
			if (xx+i>x && xx+i<x+w && yy+j>y && yy+j<y+h) {
				if (getpixel(chpic,i,j)==black) return 1;
	}	}	}
	return 0;
}

void wall::destroy() {
	x = y = w = h = up = dn = lf = rt = typ = fake = 0;
}

***

#include <stdlib.h>
#include <stdio.h>
#include <iostream.h>
#include <allegro.h>
#include "black1.cpp"
#include "green1.cpp"
#include "bg.cpp"
#include "guy.cpp"

void reset();
int main() {
	int delay=5;
	scrx = 0, scry = 0;

	PALLETE pall;
	BITMAP *back1;

	allegro_init();
	install_keyboard(); 
	install_timer();

	set_color_depth(16);
	set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
	set_color_conversion(COLORCONV_TOTAL);

	data = load_datafile("main.dat");

	back1 = (BITMAP *)data[BACK1].dat;
	buf = create_bitmap(width,height);
	rectfill(buf,0,0,width,height,white);
	rectfill(screen,0,0,640,480,pink);

	Green1 green[10] = {
		Green1(40,100,5,1,1),
		Green1(40,0,6,1,1),
		Green1(50,50,5,1,1),
		Green1(80,0,4,1,1),
		Green1(100,0,3,1,1),
		Green1(120,0,7,1,1),
		Green1(200,80,5,1,1),
		Green1(220,0,3,1,1),
		Green1(240,80,6,1,1),
		Green1(300,88,4,1,1)
	};

	loadIms();
	makeWalls();
	setBgs();
	for (int i=0; i<10; i++) {
		green[i].dead=0;
	}

	generate_332_palette(pall);

	while (!key[KEY_ENTER] && !dead) {
		rest(delay);
	
rectfill(buf,scrx-100,scry-100,scrx+innerw+100,scry+innerh+100,white);
//		blit(back1,buf,0,0,0,0,300,300);
		drawWalls(1);
		if (key[KEY_RIGHT] || key[KEY_PGDN]) {
			d = 1; running = 1;
		}
		if (key[KEY_LEFT] || key[KEY_DEL]) {
			d = -1; running = 1;
		}
		if (key[KEY_UP] || key[KEY_HOME]) {
			if (key[KEY_LSHIFT]) { d = FD; }
			else if (canjump) { jumping=1; picn=0;}
		}
		if (key[KEY_DOWN] || key[KEY_END]) {

		}
		if (key[KEY_G]) {
			if (!godmode) { godmode=1;
textout(screen,font,"godmode on ",100,400,pink); }
			else { godmode=0; textout(screen,font,"godmode
off",100,400,pink); }
		}
		if (key[KEY_SPACE]) {
			if (canfire) fire();
			canfire=0;

		} else canfire=1;
		for (int i = 0; i<10; i++) {
			if (green[i].dead!=1) {
				green[i].move();
				for (int j=0; j<MAXMSL; j++) {
					if (msls[j].exp==1 && msls[j].d!=0) {
						if (green[i].check(msls[j])) explode(msls[j]);
					}
				}
				if (green[i].check(x-cval,y,checkp) && !godmode)
die();
			}
		}
		move();
		drawWalls(0);
		blit(buf,screen,scrx,scry,10,10,innerw,innerh);
		textprintf(screen,font,10,450,1000,"ammo: %i",
ammo[weapon]);
		if (resetv) {
			makeWalls();
			setBgs();
			for (int i = 0; i<10; i++) {
				green[i].dead=0;
			}
			for (int i = 0; i<wallnum; i++) {
				walls[i].destroy();
			}
			for (int i = 0; i<doornum; i++) {
				doors[i].destroy();
			}
			rectfill(buf,0,0,width,height,white);
			rectfill(screen,0,0,640,480,pink);
			scrx = 0, scry = 0;
		}
	}

	textout(screen,font,"YOU LOSE",200,200,1000);

	clear_keybuf();
	readkey();

	allegro_exit();

	return 0;

}

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019