Jump to content
  • Advertisement
Sign in to follow this  

Code feedback for console breakout game

This topic is 4945 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Details are as follows: IDE: Dev-C++ - 4.9.8.7 Language: C Tutorials/websites used: www.adrianxw.dk/SoftwareSite/index.html www.gametutorials.com - the screenbuffer and maze examples MSDN My own thoughts on the game making process is that towards the end I felt that I was just adding code to make the game work without thinking things through properly. I would appreciate if people could give me advice on the layout/readability of the code or anything else really. I am also not sure about the collision detection code which is another area where I was just adding code as it came to me without thinking about a more elegant solution. Anyway the code is as follows:
/*
 * Title: Breakout
 * Author: Popcorn
 * Version 3
*/
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

#define SCREENWIDTH 50
#define SCREENHEIGHT 20

#define BLOCKWIDTH  5
#define BLOCKHEIGHT 2

#define BALLWIDTH 2
#define BALLHEIGHT 2
#define BALLSPEED 1

#define BATWIDTH  8
#define BATHEIGHT 2
#define BATSPEED 2

#define LIVES 3

#define TRUE 1
#define FALSE 0

typedef int bool;

//block structure
typedef struct block
{
  SMALL_RECT srBlockRect;
  bool bCanCollide;
}block;

typedef struct ball
{
  SMALL_RECT srBallRect;
  SMALL_RECT srBlankBallRect;
  CHAR_INFO ciBallSprite[BALLWIDTH * BALLHEIGHT];
  CHAR_INFO ciBlankBallSprite[BALLWIDTH * BALLHEIGHT];
  int iBallSpeed;
  int iDirectionX;
  int iDirectionY;
  COORD start;
  COORD old;
  COORD gridSize;
  COORD zeroZero;
}ball;

typedef struct bat
{
  SMALL_RECT srBatRect;
  SMALL_RECT srBlankBatRect;
  CHAR_INFO ciBatSprite[BATWIDTH * BATHEIGHT];
  CHAR_INFO ciBlankBatSprite[BATWIDTH * BATHEIGHT];
  int iBatSpeed;
  COORD start;
  COORD old;
  COORD gridSize;
  COORD zeroZero;
}bat;

void initializeBall(ball *);
bool moveBall(HANDLE, ball *, int *);
void initializeBlocks(block *, int);
void drawBlocks(HANDLE, block *, int);
bool collision(SMALL_RECT, SMALL_RECT);
void initializeBat(bat *);
void moveBat(HANDLE, HANDLE, bat *);
void restartGame(HANDLE, ball *, bat *);	

int main(int argc, char *argv[])
{
  //Windows console variables
  HANDLE hOut;										
  HANDLE hIn;
  
  hIn = GetStdHandle(STD_INPUT_HANDLE);												
  hOut = GetStdHandle(STD_OUTPUT_HANDLE);
  
  CHAR_INFO ciBlankBlockSprite[BLOCKWIDTH * BLOCKHEIGHT];//memory to hold the  replacement 'sprite'
  
  //game variables
  bool bRunGame = TRUE;//the variable for
  int iCount = 0;//counts the number of blocks that have been hit
  int iLives = LIVES;
  	
  block blocks[30];
  ball ball;
  bat bat;
  
  int i;//looping variable
  int x, y;//looping variables for blankblocksprite
  COORD gridSize = {BLOCKWIDTH , BLOCKHEIGHT};
  COORD zeroZero = {0, 0};
  
  //create a small rectangle containing ' ' characters
  for(y = 0; y < gridSize.Y; y++)						
  {
    for(x = 0; x < gridSize.X; x++)				
    {												
      ciBlankBlockSprite[x + y * BLOCKWIDTH].Char.AsciiChar = ' ';
      ciBlankBlockSprite[x + y * BLOCKWIDTH].Attributes = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED;
    }
  }
  
  //seed the randam number function
  srand((unsigned)time(NULL));
  
  //game initialization
  initializeBlocks(blocks, 30);
  initializeBall(&ball);
  initializeBat(&bat);
  
  drawBlocks(hOut, blocks, 30);
  
  //game loop  
  while(bRunGame)
  {
    if(!moveBall(hOut, &ball, &iLives))
      restartGame(hOut, &ball, &bat);
    
    for(i = 0; i < 30; i++)
    {
      if(collision(ball.srBallRect, blocks.srBlockRect) && blocks.bCanCollide)
      {
        WriteConsoleOutput(hOut, ciBlankBlockSprite, gridSize, zeroZero, &blocks.srBlockRect);
        blocks.bCanCollide = FALSE;
        ball.iDirectionY = 1;
        iCount++;
      }
      if(iCount == 30)
        bRunGame = FALSE;
    }
    
    //check if there is any collision between bat and ball   
    if(collision(ball.srBallRect, bat.srBatRect))
      ball.iDirectionY = -1;//change the direction of the ball in the y-axis
    
    moveBat(hOut, hIn, &bat);
    
    //the player has run out of lives so end the game
    if(iLives == 0)
      bRunGame = FALSE;
    
    COORD test2 = {0, 22};
    SetConsoleCursorPosition(hOut, test2);
    printf("Lives Left: %d\n", iLives);
    
    sleep(100);
  }
  
  system("PAUSE");	
  return 0;
}

//function to create the ball
void initializeBall(ball *ball)
{
  int x, y;//looping variables
  
  ball->gridSize.X = BALLWIDTH;
  ball->gridSize.Y = BALLHEIGHT;
  
  ball->zeroZero.X = 0;
  ball->zeroZero.Y = 0;
  
  ball->start.X = 10;
  ball->start.Y = 10;
  
  ball->old.X = ball->start.X;
  ball->old.Y = ball->start.Y;
  	
  //create a small rectangle containing '*' characters
  for(y = 0; y < ball->gridSize.Y; y++)						
  {
    for(x = 0; x < ball->gridSize.X; x++)				
    {												
      ball->ciBallSprite[x + y * BALLWIDTH].Char.AsciiChar = '*';
      ball->ciBallSprite[x + y * BALLWIDTH].Attributes = FOREGROUND_BLUE;
    }
  }
  
  //create a small rectangle containing ' ' characters
  for(y = 0; y < ball->gridSize.Y; y++)						
  {
    for(x = 0; x < ball->gridSize.X; x++)				
    {												
      ball->ciBlankBallSprite[x + y * BALLWIDTH].Char.AsciiChar = ' ';
      ball->ciBlankBallSprite[x + y * BALLWIDTH].Attributes = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED;
    }
  }
  
  ball->iBallSpeed = BALLSPEED;
  ball->iDirectionX = 1;
  ball->iDirectionY = 1;
}

//function to move and draw the ball and check for collision with screen
bool moveBall(HANDLE hOut, ball *ball, int *iLives)
{
  //define rectangle to draw onto the screen
  ball->srBallRect.Left = ball->start.X;
  ball->srBallRect.Top = ball->start.Y;
  ball->srBallRect.Right = ball->start.X + BALLWIDTH;
  ball->srBallRect.Bottom = ball->start.Y + BALLHEIGHT;
  
  //rectangle to hold the old coordinates to draw the blank ball sprite to
  ball->srBlankBallRect.Left = ball->old.X;
  ball->srBlankBallRect.Top = ball->old.Y;
  ball->srBlankBallRect.Right = ball->old.X + BALLWIDTH;
  ball->srBlankBallRect.Bottom = ball->old.Y + BALLHEIGHT;
  
  //check for collision with the screen
  if(ball->srBallRect.Right == SCREENWIDTH - 1)
    ball->iDirectionX = -1;
        
  if(ball->srBallRect.Bottom > SCREENHEIGHT - 1)
  {
    (*iLives)--;
    return FALSE;//the ball fell off the screen
  }
      
  if(ball->srBallRect.Left <= 0)
    ball->iDirectionX = 1;
      
  if(ball->srBallRect.Top <= 0)
    ball->iDirectionY = 1;
    
  ball->old.X = ball->start.X;
  ball->old.Y = ball->start.Y;
  
  //increase the ball co-ordinate in the appropriate direction
  ball->start.X = ball->start.X + (ball->iDirectionX * ball->iBallSpeed);
  ball->start.Y = ball->start.Y + (ball->iDirectionY * ball->iBallSpeed);
   
  //draw over the old ball with the blank sprite
  WriteConsoleOutput(hOut, ball->ciBlankBallSprite, ball->gridSize, ball->zeroZero, &ball->srBlankBallRect);    
  //draw the new ball to the screen
  WriteConsoleOutput(hOut, ball->ciBallSprite, ball->gridSize, ball->zeroZero, &ball->srBallRect);
  
  //the ball was bounced back
  return TRUE;
}

//function to create the blocks
void initializeBlocks(block *blocks, int iNumOfBlocks)
{ 
  int i; //looping variable
  
  //The starting coordinates for the first rectangle
  COORD leftTop = {0, -2};
  COORD rightBottom = {BLOCKWIDTH, BLOCKHEIGHT};
   
  //create the rectangles for the blocks
  for(i = 0; i < iNumOfBlocks; i++)
  {
    if(i % 10 == 0)
    {
      leftTop.X = 0;
      rightBottom.X = BLOCKWIDTH;
      leftTop.Y = leftTop.Y + BLOCKHEIGHT;
      rightBottom.Y = rightBottom.Y + BLOCKHEIGHT;
    }
    else
    {
      leftTop.X = leftTop.X + BLOCKWIDTH;
      rightBottom.X = rightBottom.X + BLOCKWIDTH;
    }
    
    //store the values in the blocks array
    blocks.srBlockRect.Left = leftTop.X;
    blocks.srBlockRect.Top = leftTop.Y;
    blocks.srBlockRect.Right = rightBottom.X;
    blocks.srBlockRect.Bottom = rightBottom.Y;
    
  //set collide status
  blocks.bCanCollide = TRUE; 
  }
}

//function to draw the blocks to the screen
void drawBlocks(HANDLE hOut, block *blocks, int iNumOfBlocks)
{
  CHAR_INFO ciBlockSprite[BLOCKWIDTH * BLOCKHEIGHT];//memory to hold the 'sprite'
  COORD gridSize = {BLOCKWIDTH , BLOCKHEIGHT};
  COORD zeroZero = {0, 0};					
  int iColour;
  int i, x, y;//looping variables

  //fill in the CHAR_INFO structure that makes up a block
  for(i = 0; i < iNumOfBlocks; i++)
  {
    iColour = rand() % 7;//select a random colour for each block
    while(iColour == 0)
      iColour = rand() % 7;//select a random colour for each block
    for(y = 0; y < gridSize.Y; y++)						
    {
      for(x = 0; x < gridSize.X; x++)				
      {												
        ciBlockSprite[x + y * BLOCKWIDTH].Char.AsciiChar = '*';
        ciBlockSprite[x + y * BLOCKWIDTH].Attributes = iColour;
      }
    }
  //draw the block to the screen
  WriteConsoleOutput(hOut, ciBlockSprite, gridSize, zeroZero, &blocks.srBlockRect);
  }
}

//function to check for collision
bool collision(SMALL_RECT srRectangle1, SMALL_RECT srRectangle2)
{
  if((srRectangle1.Top == (srRectangle2.Bottom + 1)
    || srRectangle1.Bottom == (srRectangle2.Top - 1))
    && srRectangle1.Right >= srRectangle2.Left 
    && srRectangle1.Left <= srRectangle2.Right)
  {
    return TRUE;
  }
  else
  {
    return FALSE;
  } 
}

//creates the bat
void initializeBat(bat *bat)
{
  int x, y;//looping variables
  
  bat->gridSize.X = BATWIDTH;
  bat->gridSize.Y = BATHEIGHT;
  
  bat->zeroZero.X = 0;
  bat->zeroZero.Y = 0;
  
  bat->start.X = 20;
  bat->start.Y = 17;
  
  bat->old.X = bat->start.X;
  bat->old.Y = bat->start.Y;
  	
  //create a small rectangle containing '*' characters
  for(y = 0; y < bat->gridSize.Y; y++)						
  {
    for(x = 0; x < bat->gridSize.X; x++)				
    {												
      bat->ciBatSprite[x + y * BATWIDTH].Char.AsciiChar = '*';
      bat->ciBatSprite[x + y * BATWIDTH].Attributes = FOREGROUND_RED;
    }
  }
  
  //create a small rectangle containing ' ' characters
  for(y = 0; y < bat->gridSize.Y; y++)						
  {
    for(x = 0; x < bat->gridSize.X; x++)				
    {												
      bat->ciBlankBatSprite[x + y * BATWIDTH].Char.AsciiChar = ' ';
      bat->ciBlankBatSprite[x + y * BATWIDTH].Attributes = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED;
    }
  }
  
  bat->iBatSpeed = BATSPEED;
  
  //define the rectangle to draw to the screen
  bat->srBatRect.Left = bat->start.X;
  bat->srBatRect.Top = bat->start.Y;
  bat->srBatRect.Right = bat->start.X + BATWIDTH;
  bat->srBatRect.Bottom = bat->start.Y + BATHEIGHT;
  
  //define the rectangle to draw the 'blank sprite' to the screen  
  bat->srBlankBatRect.Left = bat->start.X;
  bat->srBlankBatRect.Top = bat->start.Y;
  bat->srBlankBatRect.Right = bat->start.X + BATWIDTH;
  bat->srBlankBatRect.Bottom = bat->start.Y + BATHEIGHT;
}

//function to move the bat
void moveBat(HANDLE hOut, HANDLE hIn, bat *bat)
{
  char userchoice;//holds the key user has pressed
  
  //draw the 'sprite over new position
  WriteConsoleOutput(hOut, bat->ciBatSprite, bat->gridSize, bat->zeroZero, &bat->srBatRect);
                    
  if(kbhit())
  {
    userchoice = getch();
    switch(userchoice)
    {
      case 'a': if(bat->srBatRect.Left == 0)
                {
                  bat->srBatRect.Left = bat->old.X;
                  bat->srBatRect.Top = bat->old.Y;
                  bat->srBatRect.Right = bat->old.X + BATWIDTH;
                  bat->srBatRect.Bottom = bat->old.Y + BATHEIGHT;
                  
                  bat->start.X = 2;
                }
                else
                {
                  bat->srBatRect.Left = bat->start.X;
                  bat->srBatRect.Top = bat->start.Y;
                  bat->srBatRect.Right = bat->start.X + BATWIDTH;
                  bat->srBatRect.Bottom = bat->start.Y + BATHEIGHT;
    
                  bat->srBlankBatRect.Left = bat->old.X;
                  bat->srBlankBatRect.Top = bat->old.Y;
                  bat->srBlankBatRect.Right = bat->old.X + BATWIDTH;
                  bat->srBlankBatRect.Bottom = bat->old.Y + BATHEIGHT;
                  
                  bat->old.X = bat->start.X;
                  bat->start.X = bat->start.X - BATSPEED;
                }
                break;
                  
      case 'd': if(bat->srBatRect.Right == SCREENWIDTH - 1)
                {
                  bat->srBatRect.Left = bat->old.X;
                  bat->srBatRect.Top = bat->old.Y;
                  bat->srBatRect.Right = bat->old.X + BATWIDTH;
                  bat->srBatRect.Bottom = bat->old.Y + BATHEIGHT;
                  
                  bat->start.X = 40;
                }
                else
                {
                  bat->srBatRect.Left = bat->start.X;
                  bat->srBatRect.Top = bat->start.Y;
                  bat->srBatRect.Right = bat->start.X + BATWIDTH;
                  bat->srBatRect.Bottom = bat->start.Y + BATHEIGHT;
    
                  bat->srBlankBatRect.Left = bat->old.X;
                  bat->srBlankBatRect.Top = bat->old.Y;
                  bat->srBlankBatRect.Right = bat->old.X + BATWIDTH;
                  bat->srBlankBatRect.Bottom = bat->old.Y + BATHEIGHT;
                  
                  bat->old.X = bat->start.X;
                  bat->start.X = bat->start.X + BATSPEED;
                }
                break;
                       
        default: printf("Please select a or d\n");
    }
      
    //draw the 'blank sprite over old position
    WriteConsoleOutput(hOut, bat->ciBlankBatSprite, bat->gridSize, bat->zeroZero, &bat->srBlankBatRect);
    //draw the 'sprite over new position
    WriteConsoleOutput(hOut, bat->ciBatSprite, bat->gridSize, bat->zeroZero, &bat->srBatRect);   
  }
}

//if the player loses a life this function sets the ball back to its original position
void restartGame(HANDLE hOut, ball *ball, bat *bat)
{
  //draw over the old ball with the blank sprite
  WriteConsoleOutput(hOut, ball->ciBlankBallSprite, ball->gridSize, ball->zeroZero, &ball->srBlankBallRect); 
  
  ball->start.X = 10;
  ball->start.Y = 10;
  
  ball->old.X = ball->start.X;
  ball->old.Y = ball->start.Y;
  
  ball->iDirectionX = 1;
  ball->iDirectionY = 1;
  
  sleep(800);//pause the game for a brief period
}




[\source]




Share this post


Link to post
Share on other sites
Advertisement
Hi,

I tried compiling your code in VC++ 6.0 and I got this:

--------------------Configuration: breakout - Win32 Debug--------------------
Compiling...
main.c
c:\program files\microsoft visual studio\myprojects\breakout\main.c(84) : error C2275: 'CHAR_INFO' : illegal use of this type as an expression
c:\program files\microsoft visual studio\vc98\include\wincon.h(138) : see declaration of 'CHAR_INFO'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(84) : error C2146: syntax error : missing ';' before identifier 'ciBlankBlockSprite'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(84) : error C2065: 'ciBlankBlockSprite' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\breakout\main.c(84) : error C2109: subscript requires array or pointer type
c:\program files\microsoft visual studio\myprojects\breakout\main.c(87) : error C2275: 'bool' : illegal use of this type as an expression
c:\program files\microsoft visual studio\myprojects\breakout\main.c(29) : see declaration of 'bool'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(87) : error C2146: syntax error : missing ';' before identifier 'bRunGame'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(87) : error C2065: 'bRunGame' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\breakout\main.c(88) : error C2143: syntax error : missing ';' before 'type'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(89) : error C2143: syntax error : missing ';' before 'type'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(91) : error C2275: 'block' : illegal use of this type as an expression
c:\program files\microsoft visual studio\myprojects\breakout\main.c(36) : see declaration of 'block'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(91) : error C2146: syntax error : missing ';' before identifier 'blocks'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(91) : error C2065: 'blocks' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\breakout\main.c(91) : error C2109: subscript requires array or pointer type
c:\program files\microsoft visual studio\myprojects\breakout\main.c(92) : error C2275: 'ball' : illegal use of this type as an expression
c:\program files\microsoft visual studio\myprojects\breakout\main.c(51) : see declaration of 'ball'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(92) : error C2146: syntax error : missing ';' before identifier 'ball'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(92) : error C2275: 'ball' : illegal use of this type as an expression
c:\program files\microsoft visual studio\myprojects\breakout\main.c(51) : see declaration of 'ball'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(93) : error C2275: 'bat' : illegal use of this type as an expression
c:\program files\microsoft visual studio\myprojects\breakout\main.c(64) : see declaration of 'bat'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(93) : error C2146: syntax error : missing ';' before identifier 'bat'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(93) : error C2275: 'bat' : illegal use of this type as an expression
c:\program files\microsoft visual studio\myprojects\breakout\main.c(64) : see declaration of 'bat'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(95) : error C2143: syntax error : missing ';' before 'type'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(96) : error C2143: syntax error : missing ';' before 'type'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(97) : error C2275: 'COORD' : illegal use of this type as an expression
c:\program files\microsoft visual studio\vc98\include\wincon.h(32) : see declaration of 'COORD'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(97) : error C2146: syntax error : missing ';' before identifier 'gridSize'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(97) : error C2065: 'gridSize' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\breakout\main.c(97) : error C2059: syntax error : '{'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(98) : error C2275: 'COORD' : illegal use of this type as an expression
c:\program files\microsoft visual studio\vc98\include\wincon.h(32) : see declaration of 'COORD'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(98) : error C2146: syntax error : missing ';' before identifier 'zeroZero'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(98) : error C2065: 'zeroZero' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\breakout\main.c(98) : error C2059: syntax error : '{'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(101) : error C2065: 'y' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\breakout\main.c(101) : error C2224: left of '.Y' must have struct/union type
c:\program files\microsoft visual studio\myprojects\breakout\main.c(103) : error C2065: 'x' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\breakout\main.c(103) : error C2224: left of '.X' must have struct/union type
c:\program files\microsoft visual studio\myprojects\breakout\main.c(105) : error C2109: subscript requires array or pointer type
c:\program files\microsoft visual studio\myprojects\breakout\main.c(105) : error C2224: left of '.Char' must have struct/union type
c:\program files\microsoft visual studio\myprojects\breakout\main.c(106) : error C2109: subscript requires array or pointer type
c:\program files\microsoft visual studio\myprojects\breakout\main.c(106) : error C2224: left of '.Attributes' must have struct/union type
c:\program files\microsoft visual studio\myprojects\breakout\main.c(111) : warning C4013: 'time' undefined; assuming extern returning int
c:\program files\microsoft visual studio\myprojects\breakout\main.c(114) : warning C4047: 'function' : 'struct block *' differs in levels of indirection from 'int '
c:\program files\microsoft visual studio\myprojects\breakout\main.c(114) : warning C4024: 'initializeBlocks' : different types for formal and actual parameter 1
c:\program files\microsoft visual studio\myprojects\breakout\main.c(115) : error C2275: 'ball' : illegal use of this type as an expression
c:\program files\microsoft visual studio\myprojects\breakout\main.c(51) : see declaration of 'ball'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(115) : error C2198: 'initializeBall' : too few actual parameters
c:\program files\microsoft visual studio\myprojects\breakout\main.c(116) : error C2275: 'bat' : illegal use of this type as an expression
c:\program files\microsoft visual studio\myprojects\breakout\main.c(64) : see declaration of 'bat'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(116) : error C2198: 'initializeBat' : too few actual parameters
c:\program files\microsoft visual studio\myprojects\breakout\main.c(118) : warning C4047: 'function' : 'struct block *' differs in levels of indirection from 'int '
c:\program files\microsoft visual studio\myprojects\breakout\main.c(118) : warning C4024: 'drawBlocks' : different types for formal and actual parameter 2
c:\program files\microsoft visual studio\myprojects\breakout\main.c(123) : error C2275: 'ball' : illegal use of this type as an expression
c:\program files\microsoft visual studio\myprojects\breakout\main.c(51) : see declaration of 'ball'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(123) : error C2065: 'iLives' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\breakout\main.c(123) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct ball *'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(123) : error C2198: 'moveBall' : too few actual parameters
c:\program files\microsoft visual studio\myprojects\breakout\main.c(124) : error C2275: 'ball' : illegal use of this type as an expression
c:\program files\microsoft visual studio\myprojects\breakout\main.c(51) : see declaration of 'ball'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(124) : error C2275: 'bat' : illegal use of this type as an expression
c:\program files\microsoft visual studio\myprojects\breakout\main.c(64) : see declaration of 'bat'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(124) : error C2198: 'restartGame' : too few actual parameters
c:\program files\microsoft visual studio\myprojects\breakout\main.c(126) : error C2065: 'i' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\breakout\main.c(128) : error C2143: syntax error : missing ')' before 'type'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(128) : error C2198: 'collision' : too few actual parameters
c:\program files\microsoft visual studio\myprojects\breakout\main.c(131) : error C2109: subscript requires array or pointer type
c:\program files\microsoft visual studio\myprojects\breakout\main.c(131) : error C2224: left of '.bCanCollide' must have struct/union type
c:\program files\microsoft visual studio\myprojects\breakout\main.c(132) : error C2275: 'ball' : illegal use of this type as an expression
c:\program files\microsoft visual studio\myprojects\breakout\main.c(51) : see declaration of 'ball'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(133) : error C2065: 'iCount' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\breakout\main.c(140) : error C2143: syntax error : missing ')' before 'type'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(140) : error C2198: 'collision' : too few actual parameters
c:\program files\microsoft visual studio\myprojects\breakout\main.c(143) : error C2275: 'bat' : illegal use of this type as an expression
c:\program files\microsoft visual studio\myprojects\breakout\main.c(64) : see declaration of 'bat'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(143) : error C2198: 'moveBat' : too few actual parameters
c:\program files\microsoft visual studio\myprojects\breakout\main.c(149) : error C2275: 'COORD' : illegal use of this type as an expression
c:\program files\microsoft visual studio\vc98\include\wincon.h(32) : see declaration of 'COORD'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(149) : error C2146: syntax error : missing ';' before identifier 'test2'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(149) : error C2065: 'test2' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\breakout\main.c(149) : error C2059: syntax error : '{'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(150) : error C2115: 'function' : incompatible types
c:\program files\microsoft visual studio\myprojects\breakout\main.c(150) : warning C4024: 'SetConsoleCursorPosition' : different types for formal and actual parameter 2
c:\program files\microsoft visual studio\myprojects\breakout\main.c(153) : warning C4013: 'sleep' undefined; assuming extern returning int
c:\program files\microsoft visual studio\myprojects\breakout\main.c(156) : error C2143: syntax error : missing ')' before 'string'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(156) : error C2143: syntax error : missing '{' before 'string'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(156) : error C2059: syntax error : '<Unknown>'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(156) : error C2059: syntax error : ')'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(157) : error C2059: syntax error : 'return'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(158) : error C2059: syntax error : '}'
c:\program files\microsoft visual studio\myprojects\breakout\main.c(389) : warning C4013: 'kbhit' undefined; assuming extern returning int
c:\program files\microsoft visual studio\myprojects\breakout\main.c(391) : warning C4013: 'getch' undefined; assuming extern returning int
Error executing cl.exe.

breakout.exe - 69 error(s), 10 warning(s)


How does yours actually work?

Share this post


Link to post
Share on other sites
The code works fine for the version of Dev-C++ that I am using. Are you sure you created a "Console" application in VC++ 6.0. Some of the functions like kbhit(), sleep() and getch() will need to be changed to _kbhit(), _sleep() and _getch(). Include the conio.h and time.h header files too.

[Edited by - popcorn on November 6, 2004 8:13:22 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!