Jump to content
  • Advertisement
Sign in to follow this  
wioneo

Strange Error

This topic is 2900 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

I am trying to work through this turtorial, andVisual studio is giving me a warning that I do not understand.


//
#include "c_game.h"
#ifndef LINUX
#include <windows.h>
#endif

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
IO io;
int screen_height=io.GetScreenHeight();

c_piece piece;

c_board board(&piece,screen_height);//<- red squiggle here
c_game game(&board,&piece,&io,screen_height);
}





I am getting a req squiggle under the ampersand for the first argument for the 'c_board,' constructor, "piece." The error says...

"Error: no instance of constructor "c_board::c_board" matches the argument list"

Here is the constructor for 'c_board'...

c_board(c_piece *ppiece, int screen_height);





Am I missing something obvious?

Also, slightly related, does Visual Studio 10 have a feature to search specifically for syntax errors? I remember another much simpler language compiler had a tool like that that seemed very useful.

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure what you mean, did you want me to post all of the headers in the project?

I noticed that if I use...

#include "c_game.h"
#include "c_board.h"



...in that order, the red squiggle switched to the ampersand before 'board' in c_game's constructor.

Share this post


Link to post
Share on other sites
Ok, this is c_board...


#include "c_piece.h"

#define board_line_width 6
#define block_size 16
#define window_pos 100
#define board_width 10
#define board_height 20
#define min_margin 20
#define piece_blocks 5

class c_board
{
public:
c_board(c_piece *ppiece, int screen_height);

enum {pos_free,pos_filled};
int grid[board_width][board_height];
c_piece *ppiece;
int screen_height;

int get_xpos(int bx)
{
return window_pos + (bx*block_size);
}
int get_ypos(int by)
{
return window_pos + (by*block_size);
}
bool is_free(int bx,int by)
{
if (grid[bx][by]==pos_filled)
{return true;}
else{return false;}
}
bool can_move(int px,int py,int type,int rot)//need second look
{
for (int ix1=px, ix2=0; ix1<px+piece_blocks; ix1++, ix2++)
{
for (int iy1=py, iy2=0; iy1<py+piece_blocks; iy1++, iy2++)
{
if (ix1<0 || ix1>(board_width-1) || iy1>(board_height-1))
{
if (ppiece->get_block_type(type,rot,ix2,iy2)!=0)
{
return false;
}
}
if (iy1>=0)
{
if (ppiece->get_block_type(type,rot,ix2,iy2)!=0
&& !is_free(ix1,iy1))
{
return false;
}
}
}
}
return true;
}
void store_piece(int px,int py,int type,int rot)
{
for (int ix1=px, ix2=0; ix1<px+piece_blocks; ix1++,ix2++)
{
for (int iy1=py, iy2=0; iy1<py+piece_blocks; iy1++,iy2++)
{
if (ppiece->get_block_type(type,rot,ix2,iy2)!=0)
{
grid[ix1][iy1]=pos_filled;
}
}
}
}
void check_lines()
{
for (int iy=0; iy<board_height; iy++)
{
int icheck=0;
for (int ix=0; ix<board_width; ix++)
{
if (grid[ix][iy]!=pos_filled)
{
break;
}
icheck++;
if (icheck==board_width)
{
delete_line(iy);
}
}
}
}
bool game_over()
{
for (int i=0; i<board_width; i++)
{
if (grid[0]==pos_filled)
{
return true;
}
return false;
}
}
void ini_board()
{
for (int i=0; i<board_width; i++)
{
for (int ii=0; ii<board_height; ii++)
{
grid[ii]=pos_free;
}
}
}
void delete_line(int py)
{
for (int iy=py; iy>0; iy--)
{
for (int ix=0; ix<board_width; ix++)
{
grid[ix][iy]=grid[ix][iy-1];
}
}
}
};



This is c_game....

#pragma once

#include "c_board.h"
#include "c_piece.h"
#include "IO.h"
#include <time.h>

#define step 700

class c_game
{
public:
//public
c_game(c_board *pboard, c_piece *ppiece, IO *pio, int screen_height);

int px, py, ptype, prot;//pub
int window_height, next_px, next_py, next_ptype, next_prot;//priv

void draw_screen()
{
draw_board();
draw_piece(px,py,ptype,prot);
draw_piece(next_px,next_py,next_ptype,next_prot);
}
void create_piece()
{
ptype=next_ptype;
prot=next_prot;
px=(board_width/2)+mpiece->get_xoff(ptype,prot);
py=mpiece->get_yoff(ptype,prot);

next_ptype=get_rand(0,6);
next_prot=get_rand(0,3);
}

//private
//int window_height, next_px, next_py, next_ptype, next_prot;

c_board *mboard;
c_piece *mpiece;
IO *io;

int get_rand(int a, int b)
{
return rand() % (b-a+1) +a;
}
void ini_game()
{
srand ((unsigned int) time(NULL));

ptype=get_rand(0,6);
prot=get_rand(0,3);
px=(board_width/2)+mpiece->get_xoff(ptype,prot);
py=mpiece->get_yoff(ptype,prot);

next_ptype=get_rand(0,6);
next_prot=get_rand(0,3);
next_px=board_width+5;
next_py=5;
}
void draw_piece(int px,int py,int ptype,int prot)
{
color bcolor;
bool isblock;

int dx=(*mboard).get_xpos(px);
int dy=mboard->get_ypos(py);

for (int ix=0; ix<piece_blocks; ix++)
{
for (int iy=0; iy<piece_blocks; iy++)
{
switch (mpiece->get_block_type(ptype,prot,ix,iy))
{
case 1: bcolor=GREEN;isblock=true;break;
case 2: bcolor=BLUE;isblock=true;break;
default: isblock=false;break;
}
if (isblock)
{
io->DrawRectangle(dx+(ix*block_size),dy+(iy*block_size),
dx,dy,bcolor);
}
}
}
}
void draw_board()
{
int lwx=window_pos;
int rwx=window_pos+(board_width*block_size);
int twy=window_pos;
int bwy=window_pos+(board_height*block_size);

io->DrawRectangle(lwx-board_line_width,twy, lwx,bwy, BLUE);
io->DrawRectangle(rwx+board_line_width,twy, rwx,bwy, BLUE);

for (int ix=0; ix<board_width; ix++)
{
for (int iy=0; iy<board_height; iy++)
{
if (mboard->is_free(ix,iy)==false)
{
io->DrawRectangle(lwx+(ix*block_size),twy+(iy*block_size),
lwx+((ix+1)*block_size),twy+((iy+1)*block_size), RED);
}
}
}
}
};
[/game]

Share this post


Link to post
Share on other sites
Ok, I noticed that I had 'c_piece.h' being included twice and removed the second, unnecessary time, and the red squiggles disappered.

I have these errors...
Quote:

1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall c_game::c_game(class c_board *,class c_piece *,class IO *,int)" (??0c_game@@QAE@PAVc_board@@PAVc_piece@@PAVIO@@H@Z) referenced in function _WinMain@16
1>main.obj : error LNK2019: unresolved external symbol "public: int __thiscall IO::GetScreenHeight(void)" (?GetScreenHeight@IO@@QAEHXZ) referenced in function _WinMain@16
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall IO::IO(void)" (??0IO@@QAE@XZ) referenced in function _WinMain@16
1>C:\Documents and Settings\Owner\Desktop\Cpp\tetris\Debug\tetris.exe : fatal error LNK1120: 3 unresolved externals

...now though, and I'm not sure what they mean exactly.

EDIT: also, why is it that I get an error for...

while (io.IsKeyDown(SDLK_ESCAPE)=false)//"expression must be a modifiable lvalue"


but not for...

while (!io.IsKeyDown(SDLK_ESCAPE))


aren't those two the same thing?

[Edited by - wioneo on July 12, 2010 6:00:28 PM]

Share this post


Link to post
Share on other sites
Think i get it.

Quote:
while (io.IsKeyDown(SDLK_ESCAPE)=false)//"expression must be a modifiable lvalue"


well one = sign assigns it, double = signs checks it.

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!