Mail Archives: djgpp/1997/11/03/13:15:22
From: | Fleminge <fleminge AT agri DOT huji DOT ac DOT il>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | strange parse error
|
Date: | Mon, 03 Nov 1997 17:05:28 -0800
|
Organization: | The hebrew University of Jerusalem
|
Lines: | 181
|
Message-ID: | <345E74D8.6D04B23B@agri.huji.ac.il>
|
NNTP-Posting-Host: | dial-6.agri.huji.ac.il
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
This is a multi-part message in MIME format.
--------------2F178722AC3CF6D2F93B2C7A
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I am writing a game using djgpp,allegro and rhide. When I write:
struct ball{int x,y;} i get a "parse error before {". if i change the
name from "ball" to somthing else, like "ball_" this problem disappers,
but i get a "parse error before ."when i try to acces the variables in
the "ball_" struct. can someone please help me out?
i am attaching the file to this meesage.
--------------2F178722AC3CF6D2F93B2C7A
Content-Type: text/plain; charset=us-ascii; name="BLOKDS.CC"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="BLOKDS.CC"
#include "gameart.h"
#include <allegro.h>
/*FUNCTION DECLERATION*/
void initialize_phase();
void erase_everything();
void draw_everything();
void move_bar();
void move_ball();
void play_game();
typedef struct {float x,y,x_vel,y_vel,angle; int dead; } ball;
typedef struct {int x_pos,hit_pos; } bar;
volatile int counter=0;
void time_count(...)
{
counter=0;
}
END_OF_FUNCTION(time_count);
BITMAP *buffer=create_bitmap(640,480);
DATAFILE *art=load_datafile("gameart.dat");
main(void)
{
/* INITIALIZATION */
allegro_init();
install_timer();
install_keyboard();
/* end of initalization */
/* STRUCTURES & VARIABLES */
int y;
int selection=0;
y=222+selection*68;
set_gfx_mode(GFX_AUTODETECT,640,480,0,0);
set_pallete(black_pallete);
blit((BITMAP *)art[main_menu].dat,buffer,0,0,0,0,640,480);
draw_compiled_sprite(buffer,(COMPILED_SPRITE *)art[ball].dat,80,y);
blit(buffer,screen,0,0,0,0,640,480);
fade_in((PALLETE)art[gamepal].dat,10);
LOCK_VARIABLE(counter);
LOCK_FUNCTION(time_count);
/**********************************************************************/
install_int(time_count,120);
while (!(key[KEY_ESC])) /* MAIN PROGRAM LOOP */
{
blit((BITMAP *)art[main_menu].dat,buffer,80,y,80,y,15,15); /*erase ball*/
y=222+selection*68;
if (key[KEY_DOWN]) /* CHANGE MENU SELECTION */
{if (selection!=3)
selection++;
else
selection=0; }
if (key[KEY_UP])
{if (selection!=0)
selection--;
else
selection=3; }
draw_compiled_sprite(buffer,(COMPILED_SPRITE *)art[ball].dat,80,y); /*draw the ball*/
blit(buffer,screen,80,222,80,222,15,219);/*blit to screen*/
counter++;
while (counter!=0){};
if (key[KEY_ENTER])
{
fade_out(10);
/*if (selection==0)
play_game(); /* play the game */
/*if (selection==1)
set_options(); /* go to the options screen*/
/*if (selection==2)
hall(); /* go to hall of fame */
if (selection==3)
break;
} /* END OF CONDITION */
} /* END OF THE PROGRAM LOOP */
return 0;
} /* END OF MAIN*/
void play_game()
{
initialize_phase();
int blocks[12][10];
int score=0;
draw_everything();
while (!key[KEY_SPACE]) {};
erase_everything();
move_bar();
move_ball();
draw_everything();
} /*end of function play_game*/
void draw_everything()
{
/*draw ball*/
draw_compiled_sprite(buffer,(COMPILED_SPRITE *)art[ball].dat,(int)ball.x,(int)ball.y);
/*draw bar*/
draw_compiled_sprite(buffer,(COMPILED_SPRITE *)art[bar].dat,bar.x_pos,450);
}
void move_ball()
{
if (ball.y>=435) /*check if ball hit bar*/
{
bar.hit_pos=(int)(ball.x-bar.x_pos);
if ((bar.hit_pos<0) || (bar.hit_pos>90))
ball.dead=true;
else
ball.angle=405-angle-bar.hit_pos;
}
if ((ball.x==0) || (ball.x>624)) /*if ball hits the wall*/
ball.angle=180-ball.angle;
if (ball.y==0) /*if ball hits the top of the screen*/
ball.angle-=360;
if (ball.angle<0) ball.angle+=360;
if (ball.angle>360) ball.angle-=360;
ball.x_vel=cos(ball.angle);
ball.y_vel=sin(ball.angle);
ball.x+=x_vel;
ball.y+=y_vel;
} /* end of function move_ball() */
void move_bar()
{
if (key[KEY_LEFT]) bar.x_pos--;
if (key[KEY_RIGHT]) bar.x_pos++;
} /*end of function move_bar() */
void erase_everything()
{
/* erase the ball*/
blit((BITMAP *)art[back],buffer,ball.x,ball.y,15,15);
/*erase the bar*/
blit((BITMAP *)art[back],buffer,bar.x_pos,450,bar.x_pos,450,64,20);
} /*end of erase_everything*/
void initialize_phase()
{ int i,j;
bar.x_pos=288;
ball.x=312;
ball.y=435;
ball.angle=270;
ball.dead=false;
}
--------------2F178722AC3CF6D2F93B2C7A--
- Raw text -