Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

[Allegro] Programowanie obiektowe

Ostatnio zmodyfikowano 2009-02-24 19:37
Autor Wiadomość
Ju1ian
Temat założony przez niniejszego użytkownika
[Allegro] Programowanie obiektowe
» 2009-02-24 15:24:59
Tworzę swoją grę lecz od początku nie miałem tam klas i obiektów. Dzisiaj postanowiłem to zmienić. Gdy wszystko przemieniłem itd. i skompilowałem wyskoczyła mi masa błędów. Daję kod i log kompilacji:
C/C++
// Includowanie
#include <allegro.h>

// Inicjowanie timera
volatile long speed = 0;
void increment_speed()
{
    speed++;
}
END_OF_FUNCTION( increment_speed );
LOCK_VARIABLE( speed );
LOCK_FUNCTION( increment_speed );

// Zmienne potrzebne do mapy
int mapa_x = 0, mapa_y = 1;

// Klasy
class CPlayer {
private:
    int x, y;
    int sila;
    int obrona;
    int health;
public:
    CPlayer() { x = y = sila = obrona = health = 0; }
};
CPlayer player;
CPlayer troll;

// Zmienne wspolrzednych bitmap
player.x = 240;
player.y = 160;
int hp_x = 505, hp_y = 70;
int eq_x = 520, eq_y = 90;
int zadanie_x = 60, zadanie_y = 40;
int tablica_x = 20, tablica_y = 375;
troll.x = 360;
troll.y = 320;

// Zmienne główne
player.health = 40;
troll.health = 100;
int scrolling_x = 0, scrolling_y = 0;
int alpha = 0;
float licznik = 0.0f;

// Zmienne bitmap
BITMAP * zadanie = NULL;
BITMAP * ludek = NULL;
BITMAP * hp = NULL;
BITMAP * pelne_hp = NULL;
BITMAP * eq = NULL;
BITMAP * gui = NULL;
BITMAP * teren = NULL;
BITMAP * bufor = NULL;
BITMAP * tablica = NULL;
BITMAP * czarne = NULL;
BITMAP * trollik = NULL;
BITMAP * troll_atak = NULL;

// Funkcje

bool kolizja_w_prawo() {
    if(( player.x ==( troll.x - scrolling_x - 40 ) ) &&( player.y ==( troll.y - scrolling_y ) ) )
         return true;
    else return false;
   
}
bool kolizja_w_lewo() {
    if(( player.x ==( troll.x - scrolling_x + 40 ) ) &&( player.y ==( troll.y - scrolling_y ) ) ) return true;
    else return false;
   
}
bool kolizja_w_dol() {
    if(( player.x ==( troll.x - scrolling_x ) ) &&( player.y ==( troll.y - scrolling_y - 40 ) ) ) return true;
    else return false;
   
}
bool kolizja_w_gore() {
    if(( player.x ==( troll.x - scrolling_x ) ) &&( player.y ==( troll.y - scrolling_y + 40 ) ) ) return true;
    else return false;
   
}
bool kolizja_prawo_gora() {
    if(( player.x ==( troll.x - scrolling_x + 40 ) ) &&( player.y ==( troll.y - scrolling_y - 40 ) ) ) return true;
    else return false;
   
}
bool kolizja_prawo_dol() {
    if(( player.x ==( troll.x - scrolling_x + 40 ) ) &&( player.y ==( troll.y - scrolling_y + 40 ) ) ) return true;
    else return false;
   
}
bool kolizja_lewo_gora() {
    if(( player.x ==( troll.x - scrolling_x - 40 ) ) &&( player.y ==( troll.y - scrolling_y - 40 ) ) ) return true;
    else return false;
   
}
bool kolizja_lewo_dol() {
    if(( player.x ==( troll.x - scrolling_x - 40 ) ) &&( player.y ==( troll.y - scrolling_y + 40 ) ) ) return true;
    else return false;
   
}

// DEFINICJA MAPY
short int map[ 18 ][ 30 ] =
{
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 4, 0, 0, 0, 0, 0, 1, 0, 3, 0, 5, 1, 4, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 7, 6, 3, 0, 0, 0, 1, 0, 2, 0, 6, 8, 7, 8, 6, 7, 6, 7, 6, 7, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 0, 7, 6, 6, 7, 6, 8, 6, 7, 6, 7, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 4, 0, 1, 0, 0, 0, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1,
    1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
    1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
   
};

// Funkcja wyświetlająca mapę:
void wys_mape()
{
    int licznik_x, licznik_y;
    for( licznik_x = 0; licznik_x < 20; licznik_x++ )
    {
        for( licznik_y = 0; licznik_y < 13; licznik_y++ )
        {
            blit( teren, bufor,
            ( map[ licznik_y + mapa_y ][ licznik_x + mapa_x ] % 4 ) * 40,
            ( map[ licznik_y + mapa_y ][ licznik_x + mapa_x ] / 4 ) * 40,
            licznik_x * 40, licznik_y * 40, 40, 40 );
        }
    }
};

// Funkcja Główna
int main()
{
    // Inicjalizacja wszystkiego
    allegro_init();
    install_keyboard();
    set_color_depth( 16 );
    set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0 );
    install_timer();
    install_int_ex( increment_speed, BPS_TO_TIMER( 40 ) );
   
    // Tworzenie bufora
    bufor = create_bitmap( 640, 480 );
    if( !bufor )
    {
        set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 );
        allegro_message( "Nie mogę utworzyć bufora !" );
        allegro_exit();
        return 0;
    }
   
    // Ładowanie grafiki
    teren = load_bmp( "teren.bmp", default_palette );
    ludek = load_bmp( "ludek.bmp", default_palette );
    gui = load_bmp( "gui.bmp", default_palette );
    hp = load_bmp( "hp.bmp", default_palette );
    pelne_hp = load_bmp( "pelne_hp.bmp", default_palette );
    eq = load_bmp( "eq.bmp", default_palette );
    zadanie = load_bmp( "zadanie.bmp", default_palette );
    tablica = load_bmp( "tablica.bmp", default_palette );
    czarne = load_bmp( "czarne.bmp", default_palette );
    trollik = load_bmp( "troll.bmp", default_palette );
    troll_atak = load_bmp( "troll_atak.bmp", default_palette );
   
    // Dopóki nie jest naciśnięty Escape
    while( !key[ KEY_ESC ] )
    {
        licznik += 1.0f;
        while( speed > 0 )
        {
            // SCROLLOWANIE MAPY Z KOLIZJĄ
            if( player.health > 0 ) {
                if(( key[ KEY_RIGHT ] ) &&( mapa_x < 20 ) ) {
                    if(((( map[ mapa_y + 4 ][ mapa_x + 1 + 6 ] ) == 0 ) ||(( map[ mapa_y + 4 ][ mapa_x + 1 + 6 ] ) == 2 ) ||(( map[ mapa_y + 4 ][ mapa_x + 1 + 6 ] ) == 6 ) ||(( map[ mapa_y + 4 ][ mapa_x + 1 + 6 ] ) == 7 ) ||(( map[ mapa_y + 4 ][ mapa_x + 1 + 6 ] ) == 8 ) ) &&( !kolizja_w_prawo() ) ) {
                        mapa_x = mapa_x + 1;
                        scrolling_x += 40;
                    }
                    else {
                        mapa_x = mapa_x;
                    }
                } else
                if(( key[ KEY_LEFT ] ) &&( mapa_x > 0 ) ) {
                    if(((( map[ mapa_y + 4 ][ mapa_x - 1 + 6 ] ) == 0 ) ||(( map[ mapa_y + 4 ][ mapa_x - 1 + 6 ] ) == 2 ) ||(( map[ mapa_y + 4 ][ mapa_x - 1 + 6 ] ) == 6 ) ||(( map[ mapa_y + 4 ][ mapa_x - 1 + 6 ] ) == 7 ) ||(( map[ mapa_y + 4 ][ mapa_x - 1 + 6 ] ) == 8 ) ) &&( !kolizja_w_lewo() ) ) {
                        mapa_x = mapa_x - 1;
                        scrolling_x -= 40;
                    }
                    else {
                        mapa_x = mapa_x;
                    }
                } else
                if(( key[ KEY_DOWN ] ) &&( mapa_y < 8 ) ) {
                    if(((( map[ mapa_y + 1 + 4 ][ mapa_x + 6 ] ) == 0 ) ||(( map[ mapa_y + 1 + 4 ][ mapa_x + 6 ] ) == 2 ) ||(( map[ mapa_y + 1 + 4 ][ mapa_x + 6 ] ) == 6 ) ||(( map[ mapa_y + 1 + 4 ][ mapa_x + 6 ] ) == 7 ) ||(( map[ mapa_y + 1 + 4 ][ mapa_x + 6 ] ) == 8 ) ) &&( !kolizja_w_dol() ) ) {
                        mapa_y = mapa_y + 1;
                        scrolling_y += 40;
                    }
                    else {
                        mapa_y = mapa_y;
                    }
                   
                } else
                if(( key[ KEY_UP ] ) &&( mapa_y > 0 ) ) {
                    if(((( map[ mapa_y - 1 + 4 ][ mapa_x + 6 ] ) == 0 ) ||(( map[ mapa_y - 1 + 4 ][ mapa_x + 6 ] ) == 2 ) ||(( map[ mapa_y - 1 + 4 ][ mapa_x + 6 ] ) == 6 ) ||(( map[ mapa_y - 1 + 4 ][ mapa_x + 6 ] ) == 7 ) ||(( map[ mapa_y - 1 + 4 ][ mapa_x + 6 ] ) == 8 ) ) &&( !kolizja_w_gore() ) ) {
                        mapa_y = mapa_y - 1;
                        scrolling_y -= 40;
                    }
                    else {
                        mapa_y = mapa_y;
                    }
                }
            }
            speed -= 2;
        }
       
        // Czyszczenie bufora
        clear_to_color( bufor, makecol( 150, 150, 150 ) );
       
        // Wyświetlanie mapy
        wys_mape();
       
        // Wyświetlanie bitmap
        masked_blit( trollik, bufor, 0, 0, troll.x - scrolling_x, troll.y - scrolling_y, troll->w, troll->h );
        masked_blit( ludek, bufor, 0, 0, player.x, player.y, troll->w, troll->h );
       
        // Dalsze bitmapy
        masked_blit( gui, bufor, 0, 0, 0, 0, gui->w, gui->h );
        masked_blit( hp, bufor, 0, 0, hp_x, hp_y, hp->w, hp->h );
        masked_blit( eq, bufor, 0, 0, eq_x, eq_y, eq->w, eq->h );
        masked_blit( pelne_hp, bufor, 0, 0, hp_x, hp_y, player.health, pelne_hp->h );
       
        // Zadanie z tablicy
        if( map[ mapa_y + 4 ][ mapa_x + 6 ] == 2 ) {
            blit( tablica, bufor, 0, 0, tablica_x, tablica_y, tablica->w, tablica->h );
            if( key[ KEY_P ] ) {
                masked_blit( zadanie, bufor, 0, 0, zadanie_x, zadanie_y, zadanie->w, zadanie->h );
            }
        }
        // Atak
        if(( kolizja_w_lewo() ) ||( kolizja_w_prawo() ) ||( kolizja_w_dol() ) ||( kolizja_w_gore() ) ||( kolizja_prawo_gora() ) ||( kolizja_prawo_dol() ) ||( kolizja_lewo_gora() ) ||( kolizja_lewo_dol() ) ) {
            blit( troll_atak, bufor, 0, 0, tablica_x, tablica_y, tablica->w, tablica->h );
            textprintf_ex( bufor, font, tablica_x + 15, tablica_y + 40, makecol( 0, 0, 0 ), - 1, "%d / 100", troll.health );
        }
       
        // Wyswietlamy tekst
        textprintf_ex( bufor, font, 610, 74, makecol( 255, 255, 255 ), - 1, "%d", player.health );
        textprintf_ex( bufor, font, 20, 20, makecol( 0, 0, 0 ), - 1, "ludek.x = %d, ludek.y = %d troll.x = %d, troll.y = %d", player.x, player.y, troll.x - scrolling_x, troll.y - scrolling_y );
        textprintf_ex( bufor, font, 20, 40, makecol( 0, 0, 0 ), - 1, "mapa_x = %d, mapa_y = %d", mapa_x, mapa_y );
        if( licznik >= 1 && alpha <= 255 )
        {
            alpha += 1;
            licznik = 0.0f;
        }
        // Jeśli nie żyjesz
        if( player.health == 0 ) {
            set_trans_blender( 0, 0, 0, alpha );
            draw_trans_sprite( bufor, czarne, 0, 0 );
            textprintf_ex( bufor, font, 180, 180, makecol( 255, 255, 255 ), - 1, "Niestety nie zyjesz!" );
        }
       
        // Wyswietlamy bufor
        blit( bufor, screen, 0, 0, 0, 0, 640, 480 );
    }
    // Usuwanie wszystkiego z pamięci.
    remove_int( increment_speed );
    destroy_bitmap( teren );
    destroy_bitmap( ludek );
    destroy_bitmap( gui );
    destroy_bitmap( hp );
    destroy_bitmap( bufor );
    destroy_bitmap( zadanie );
    destroy_bitmap( eq );
    destroy_bitmap( pelne_hp );
    destroy_bitmap( trollik );
    destroy_bitmap( troll_atak );
    allegro_exit();
    return 0;
}
// Koniec INT_MAIN
END_OF_MAIN();
Log:
C/C++
Kompilator: Default compiler
Building Makefile: "C:\Documents and Settings\Frankie\Pulpit\kod\Makefile.win"
Wykonywanie make...
make.exe - f "C:\Documents and Settings\Frankie\Pulpit\kod\Makefile.win" all
g++.exe - c main.cpp - o main.o - I "C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" - I "C:/Dev-Cpp/include/c++/3.4.2/backward" - I "C:/Dev-Cpp/include/c++/3.4.2/mingw32" - I "C:/Dev-Cpp/include/c++/3.4.2" - I "C:/Dev-Cpp/include"

main.cpp: 31: error: expected constructor, destructor, or type conversion before '.' token
main.cpp: 31: error: expected `, ' or `;' before '.' token
main.cpp: 32: error: expected constructor, destructor, or type conversion before '.' token

main.cpp: 32: error: expected `, ' or `;' before '.' token
main.cpp: 37: error: expected constructor, destructor, or type conversion before '.' token
main.cpp: 37: error: expected `, ' or `;' before '.' token
main.cpp: 38: error: expected constructor, destructor, or type conversion before '.' token
main.cpp: 38: error: expected `, ' or `;' before '.' token
main.cpp: 41: error: expected constructor, destructor, or type conversion before '.' token
main.cpp: 41: error: expected `, ' or `;' before '.' token
main.cpp: 42: error: expected constructor, destructor, or type conversion before '.' token
main.cpp: 42: error: expected `, ' or `;' before '.' token
main.cpp: In function ` bool kolizja_w_prawo() ':
main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 64
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 64
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 64
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 64
    : error
    : within this context main.cpp
    : In function ` bool kolizja_w_lewo() ': main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 69
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 69
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 69
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 69
    : error
    : within this context main.cpp
    : In function ` bool kolizja_w_dol() ': main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 73
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 73
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 73
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 73
    : error
    : within this context main.cpp
    : In function ` bool kolizja_w_gore() ': main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 77
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 77
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 77
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 77
    : error
    : within this context main.cpp
    : In function ` bool kolizja_prawo_gora() ': main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 81
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 81
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 81
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 81
    : error
    : within this context main.cpp
    : In function ` bool kolizja_prawo_dol() ': main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 85
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 85
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 85
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 85
    : error
    : within this context main.cpp
    : In function ` bool kolizja_lewo_gora() ': main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 89
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 89
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 89
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 89
    : error
    : within this context main.cpp
    : In function ` bool kolizja_lewo_dol() ': main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 93
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 93
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 93
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 93
    : error
    : within this context main.cpp
    : In function ` int _mangled_main() ': main.cpp
    : 23
    : error
    : ` int CPlayer::health ' is private main.cpp
    : 178
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 227
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 227
    : error
    : within this context main.cpp
    : 227
    : error
    : base operand of `->' has non-pointer type `CPlayer' main.cpp
    : 227
    : error
    : base operand of `->' has non-pointer type `CPlayer' main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 228
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 228
    : error
    : within this context main.cpp
    : 228
    : error
    : base operand of `->' has non-pointer type `CPlayer' main.cpp
    : 228
    : error
    : base operand of `->' has non-pointer type `CPlayer' main.cpp
    : 23
    : error
    : ` int CPlayer::health ' is private main.cpp
    : 234
    : error
    : within this context main.cpp
    : 23
    : error
    : ` int CPlayer::health ' is private main.cpp
    : 246
    : error
    : within this context main.cpp
    : 23
    : error
    : ` int CPlayer::health ' is private main.cpp
    : 250
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 251
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 251
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::x ' is private main.cpp
    : 251
    : error
    : within this context main.cpp
    : 20
    : error
    : ` int CPlayer::y ' is private main.cpp
    : 251
    : error
    : within this context main.cpp
    : 23
    : error
    : ` int CPlayer::health ' is private main.cpp
    : 259
    : error
    : within this context make.exe
    : ***[ main.o ] Error 1 Wykonanie zako ń czone
Zrobiłem tak jak było w tutku z programowaniem obiektowym. Z góry dzięki. Pozdrawiam
P-4439
DeBugger
» 2009-02-24 15:28:29
Czekaj - wiem na razie tyle(później pokombinuję resztę), że jeżeli masz private, to możesz edytować zmienne tylko za pomocą funkkcji w twojej klasie.
P-4441
Ju1ian
Temat założony przez niniejszego użytkownika
» 2009-02-24 15:29:56
Zmieniłem na public i wywaliłem konstruktora, teraz jest mniej błędów dużo mniej.
P-4442
DeBugger
» 2009-02-24 15:31:39
Konstruktora wywalać nie musisz. Tylko nie rozumiem jak on działa. ;/
P-4443
Ju1ian
Temat założony przez niniejszego użytkownika
» 2009-02-24 15:36:38
No ja też ;/
P-4444
DeBugger
» 2009-02-24 15:36:53
Dalej - staraj się tworzyć zmienne w funkcji main, i nadawać wartości "podzmiennym" właśnie w tamtej funkcji.
P-4445
Ju1ian
Temat założony przez niniejszego użytkownika
» 2009-02-24 15:40:19
Niezbyt rozumiem o co ci chodzi.
P-4446
DeBugger
» 2009-02-24 15:46:45
Deklarujesz `player` i `troll` globalnie. Spróbuj stworzyć je w funkcji main. Tam też podaj wartości elementów klasy.
P-4448
« 1 » 2 3
  Strona 1 z 3 Następna strona