díky už to de...škoda že to jen nedělá to co bych chtěl... :(
Příspěvky odeslané z IP adresy 194.212.94.–
ne díky gamemaker fakt ne...
hadas sparavne, vůbec sem nepochopil co wizard napsal...
no tak už to skoro funguje, ale eště něco se kompilátoru nelíbí:
[Linker error] undefined reference to `create_bitmap'
[Linker error] undefined reference to `_imp__screen'
[Linker error] undefined reference to `blit'
[Linker error] undefined reference to `_imp__key'
[Linker error] undefined reference to `_WinMain'
[Linker error] undefined reference to `_install_allegro_version_check'
[Linker error] undefined reference to `set_color_depth'
a asi ještě 50 dalších věcí.....
tak se to zkusil zkompilovat a napsalo mi to:
139: error: new types may not be defined in a return type
139: error: two or more data types in declaration of `deinit'
In function `void deinit()':
192: error: new declaration `void deinit()'
139: error: ambiguates old declaration `Clovek deinit()'
díky moc
sem začátečník no...a nemohl by si tady napsat eště jednou ten kód a bez chyb?
moc prosím...
všechno sem dal do main.cpp, který teď vypadá takto:
#include <allegro.h>
class Clovek{
private:
int x2;
int y2;
BITMAP *BMclovek;
public:
void setY2(int my){
y2 = my;
};
void setX2(int mx){
x2 = mx;
};
int getY(){
return mouse_y;
};
int getX(){
return mouse_x;
};
int getY2(){
return y2;
};
int getX2(){
return x2;
};
void init(){
BMclovek = load_bitmap("clovek.bmp", NULL);
setY2(700);
setX2(700);
};
void draw(){
masked_blit(BMclovek, screen,0,0,getX(),getY(),47,39);
};
void draw2(){
masked_blit(BMclovek, screen,0,0,getX2(),getY2(),47,39);
};
void hide(){
//rectfill(canvas, 512-23, getY(), 512+24, getY()+39, makecol(0,0,0));
};
void moveDown2(){
hide();
y2 += 6;
if (y2 > 750) y2 = 750;
draw2();
};
void moveUp2(){
hide();
y2 -= 6;
if (y2 < 10) y2 = 10;
draw2();
};
void moveLeft2(){
hide();
x2 -= 6;
if (x2 < 10) x2 = 10;
draw2();
};
void moveRight2(){
hide();
x2 += 6;
if (x2 > 1020) x2 = 1020;
draw2();
};
void move(){
if (mouse_b & 2){
if (mouse_x < x2 && mouse_y < y2){
while (mouse_x == x2 || mouse_y == y2){
moveRight2();
moveDown2();
};
if (mouse_x == x2){
while (mouse_y == y2){
moveDown2();
};
if (mouse_y == y2){
while (mouse_y == y2){
moveRight2();
};
if (mouse_x < x2 && mouse_y > y2){
while (mouse_x == x2 || mouse_y == y2){
moveRight2();
moveUp2();
};
if (mouse_x == x2){
while (mouse_y == y2){
moveUp2();
};
if (mouse_y == y2){
while (mouse_y == y2){
moveRight2();
};
if (mouse_x > x2 && mouse_y < y2){
while (mouse_x == x2 || mouse_y == y2){
moveLeft2();
moveDown2();
};
if (mouse_x == x2){
while (mouse_y == y2){
moveDown2();
};
if (mouse_y == y2){
while (mouse_y == y2){
moveLeft2();
};
if (mouse_x > x2 && mouse_y > y2){
while (mouse_x == x2 || mouse_y == y2){
moveLeft2();
moveUp2();
};
if (mouse_x == x2){
while (mouse_y == y2){
moveUp2();
};
if (mouse_y == y2){
while (mouse_y == y2){
moveLeft2();
};
if (mouse_x == x2 && mouse_y == y2){
draw();
};
};
};
void deinit();
Clovek *ptr;
ptr = new Clovek();
void InitDoubleBuffering()
{
obrazovka = create_bitmap(1024, 768);
};
void VykresliBuffer()
{
blit(obrazovka, screen,0,0,0,0,1024,768);
};
int main() {
init();
InitDoubleBuffering();
clovek->init(obrazovka);
while (!key[KEY_ESC]) {
clovek->move();
};
deinit();
return 0;
}
void init() {
int depth, res;
allegro_init();
depth = desktop_color_depth();
if (depth == 0) depth = 32;
set_color_depth(depth);
res = set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 0);
if (res != 0) {
allegro_message(allegro_error);
exit(-1)
};
install_timer();
install_keyboard();
install_mouse();
/* add other initializations here */
};
void deinit() {
clear_keybuf();
/* add other deinitializations here */
}}}}}}}}}}}}}};
a pořád to hlásí tyto chyby:
main.cpp: In member function `void Clovek::move()':
main.cpp:163: error: expected primary-expression before "void"
main.cpp:163: error: expected `;' before "void"
main.cpp:168: error: expected primary-expression before "void"
main.cpp:168: error: expected `;' before "void"
main.cpp:173: error: expected primary-expression before "int"
main.cpp:173: error: expected `;' before "int"
main.cpp:190: error: expected primary-expression before "void"
main.cpp:190: error: expected `;' before "void"
main.cpp:208: error: expected primary-expression before "void"
main.cpp:208: error: expected `;' before "void"
make.exe: *** [main.o] Error 1
možná se budete divit ale zkusil jsem obojí a pořád stejná chyba...
no ale co s tim mam teda dělat?
mě připadají ty chyby úplně nesmyslný...
mám zatím jen začátek programu a už mi to nejde zkompilovat, projekt má zatím 2 soubory: main.cpp a clovek.h
zdrojový kód main.cpp vypadá takto:
#include <allegro.h>
#include "clovek.h"
void init();
void deinit();
Clovek *clovek = new Clovek();
void InitDoubleBuffering()
{
obrazovka = create_bitmap(1024, 768);
}
void VykresliBuffer()
{
blit(obrazovka, screen,0,0,0,0,1024,768);
}
int main() {
init();
InitDoubleBuffering();
clovek->init(obrazovka);
while (!key[KEY_ESC]) {
clovek->move();
}
deinit();
return 0;
}
void init() {
int depth, res;
allegro_init();
depth = desktop_color_depth();
if (depth == 0) depth = 32;
set_color_depth(depth);
res = set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 0);
if (res != 0) {
allegro_message(allegro_error);
exit(-1)
};
install_timer();
install_keyboard();
install_mouse();
}
void deinit() {
clear_keybuf();
}}}}}}}}}}}}}};
a když to chci zkompilovat hlásí to tyto chyby:
main.cpp: In member function `void Clovek::move()':
main.cpp:9: error: expected primary-expression before "void"
main.cpp:9: error: expected `;' before "void"
main.cpp:14: error: expected primary-expression before "void"
main.cpp:14: error: expected `;' before "void"
main.cpp:19: error: expected primary-expression before "int"
main.cpp:19: error: expected `;' before "int"
main.cpp:36: error: expected primary-expression before "void"
main.cpp:36: error: expected `;' before "void"
main.cpp:54: error: expected primary-expression before "void"
main.cpp:54: error: expected `;' before "void"
make.exe: *** [main.o] Error 1
prosím nevíte někdo co s tím, předem díky...