• Advertisement

Archived

This topic is now archived and is closed to further replies.

I can't find the bug...MS VC++ 6.0

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

When I compile this code, MS VC++ 6.0 says this: error output: C:\Programme\Microsoft Visual Studio\MyProjects\cRPG\engine.cpp(159) : error C2143: syntax error : missing ';' before '.' C:\Programme\Microsoft Visual Studio\MyProjects\cRPG\engine.cpp(159) : error C2182: 'npc' : illegal use of type 'void' C:\Programme\Microsoft Visual Studio\MyProjects\cRPG\engine.cpp(159) : error C2350: '_engine::npc' is not a static member C:\Programme\Microsoft Visual Studio\MyProjects\cRPG\engine.cpp(159) : error C2143: syntax error : missing ';' before '.' C:\Programme\Microsoft Visual Studio\MyProjects\cRPG\engine.cpp(159) : error C2143: syntax error : missing ';' before '{' C:\Programme\Microsoft Visual Studio\MyProjects\cRPG\engine.cpp(159) : error C2447: missing function header (old-style formal list?) Line 160 is this: "void _engine::npc.move() {" code: #define ALLEGRO_STATICLINK #define ALLEGRO_USE_CONSOLE #define ALLEGRO_NO_CLEAR_BITMAP_ALIAS #include <iostream.h> #include <fstream.h> #include <stdlib.h> #include "allegro.h" class _npc { public: // Constructor / Deconstructor _npc() {}; ~_npc() {}; // Variables int x_pos[100]; int y_pos[100]; int x_pix[100]; int y_pix[100]; int x_way[100]; int y_way[100]; // Functions void move(); }; class _cam { public: //Variables int x_pos; int y_pos; int x_pix; int y_pix; int x_wide; int y_wide; }; class _engine { public: // Constructor / Deconstructor _engine(); ~_engine() {}; // Variables int screen_x_wide; int screen_y_wide; int screen_x_wide_v; int screen_y_wide_v; int screen_bit_depth; int sprite_x_wide; int sprite_y_wide; int npc_sprite_x_wide; int npc_sprite_y_wide; char map_data[100][100][3]; bool map_walkable[100][100]; int map_x_wide; int map_y_wide; int map_num_layer; int npc_num; BITMAP *buffer; BITMAP *sprites; BITMAP *npc_sprites[100]; // Functions void get_game_info(); void draw_map(); void load_map(char * file); // Classes _npc npc; _cam cam; }; _engine::_engine() { allegro_init(); install_keyboard(); screen_x_wide = 320; screen_y_wide = 240; screen_x_wide_v = 320; screen_y_wide_v = 240; screen_bit_depth = 8; sprite_x_wide = 16; sprite_y_wide = 16; npc_sprite_x_wide = 16; npc_sprite_y_wide = 24; set_color_depth(screen_bit_depth); set_gfx_mode(GFX_AUTODETECT_FULLSCREEN , screen_x_wide, screen_y_wide, screen_x_wide_v, screen_y_wide_v); set_display_switch_mode(SWITCH_PAUSE); // Allocate Memory buffer = create_bitmap(screen_x_wide, screen_y_wide); sprites = create_bitmap(1024, 768); for (int n = 0; n < 100; n++) { npc_sprites[n] = create_bitmap(1024, 768); } } void _engine::get_game_info() { char command; ifstream file("game.dat"); while (!file.eof()) { // Read File } file.close(); } void _engine::draw_map() { int gx,gy; for (int z = 0; z < map_num_layer; z++) { for (int x = cam.x_pos; x < cam.x_wide + cam.x_pos; x++) { for (int y = cam.y_pos; y < cam.y_wide + cam.y_pos; y++) { gx = sprite_x_wide * (x - cam.x_pos) + cam.x_pix; gy = sprite_y_wide * (y - cam.y_pos) + cam.y_pix; blit(sprites, buffer, 1024 % sprite_x_wide, int(1024 / sprite_y_wide) , gx, gy, sprite_x_wide, sprite_y_wide); } } } } void _engine::load_map(char * file) { } void _engine::npc.move() { } int main() { _engine engine; return 0; } END_OF_MAIN(); end code But I don't know where's the error. Please help me!!! QB 4 EVER [edited by - akOOma on August 16, 2003 4:49:28 PM] [edited by - akOOma on August 16, 2003 4:50:25 PM]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
quote:

void _engine::npc.move() {
}



i''m not sure wtf you are trying to do, but that isn''t right.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
quote:

void _engine::npc.move() {
}



i''m not sure wtf you are trying to do, but that isn''t right.



In the class _engine I declare the class _npc as npc:

class _engine {

_npc npc;

};

Ok??

And in the class _npc there''s the function npc

And this...:

void _engine::npc.move() {
}

... is the function, but without any code within

Share this post


Link to post
Share on other sites
perhaps you mean

void npc::move()
{
...

instead of

void _engine::npc.move()
{
...

The class npc is not a member of _engine.

[edited by - VolkerG on August 16, 2003 5:02:27 PM]

Share this post


Link to post
Share on other sites
Yeah,..., I''ve just noticed that...stupid me...sorry for bothering you all

Share this post


Link to post
Share on other sites

  • Advertisement