![]() |
|
board, pawn and classes |
kosmitek
Member #8,151
December 2006
|
Please help me - I want change my code that in code were classes, constructors and destructors but I don't know where must be for example: BITMAP *board = NULL; set_color_depth(32) and other things in my code - could you change my code that it includes classes, constructors and destructors ?? Please help It is my board: It is my code:
|
Albin Engström
Member #8,110
December 2006
![]() |
MERRY CHRISTMAS!!!. HO! HO! HO!. |
kosmitek
Member #8,151
December 2006
|
marry christmas hehehe |
HardTranceFan
Member #7,317
June 2006
![]() |
Quote: But is this answer for my problem ? No. I'm guessing that Albin Engström is hinting that this may be Christmas time, but we're not feeling benevolent enough to do all the coding for you. We can help, but firstly you really need to pick up a C++ book, or check out the on-line tutorials, and try to work it out for yourself. If you get stuck, then maybe we can help you. -- |
kosmitek
Member #8,151
December 2006
|
But in c++ books don't write where should be: in classes or in main ??
|
Durnus
Member #7,997
November 2006
![]() |
For the initialization (allegro_init(), etc.), that should be in the main function. Classes (in my opinion) should just give the main function bitmaps to draw, or even just their position. Although after you initialize allegro in the main function, classes can use allegro functions. I hope this answers your question. (And I hope that my answer is valid.
|
kosmitek
Member #8,151
December 2006
|
I change my code but something is wrong - what is wrong
|
raccoon
Member #7,478
July 2006
|
are you kidding? [EDIT] also, you can't just write code into a class without putting it into a method. I think you should inform yourself about the concept of object-orientation before trying to use classes. |
LennyLen
Member #5,313
December 2004
![]() |
Quote: I change my code but something is wrong Sorry, I left my psychic powers behind somewhere. Please explain what you mean by "something is wrong."
|
X-G
Member #856
December 2000
![]() |
We will not do your homework for you, either. -- |
LennyLen
Member #5,313
December 2004
![]() |
Quote:
but to name one thing which is totally wrong: There are a few things like that in the code that are bad, and he was told about them last time he posted about his programs not working.
|
kosmitek
Member #8,151
December 2006
|
so I have questions: 1. in the class is this must be private
2. 3. constructor in the main ????- what is wrong ??: boardboard something ("board.bmp","pawn.bmp",NULL); //constructor
4. destructor in the class - what is wrong ~boardboard(a, b, c) //destructor { destroy_bitmap(board); destroy_bitmap(pawn); destroy_bitmap(buffer); }
5. destructor in main - what is wrong |
LennyLen
Member #5,313
December 2004
![]() |
Quote: in the class is this must be private or maybe something else ?? No, they don't have to be private, but they should be. Quote:
constructor in the class should be
Well for one thing, you're assingning the board pointer three different values consecutively, so the first two lines do nothing. Secondly, it should be: Quote: 4. destructor in the class - what is wrong Well, you haven't given any type information about the arguments that the function takes. I don't know what C++ defults too if you omit this information. ints? Your destructor doesn't need to take any arguments anyway (I don't even think destructors can take arguments). Quote: 5. destructor in main - what is wrong You do not call the destructor yourself. These are called automatically when you delete the object. edit: had accidentally put "*board=&a"
|
X-G
Member #856
December 2000
![]() |
Okay, I'm just going to be blunt as hell. You have no idea what the hell you are talking about. You don't know what classes or objects are, what they represent, or how to use them. And you're trying to shoehorn a paradigm that you don't understand onto existing code that you probably don't understand either. GET A C++ BOOK. FOLLOW IT. START FROM THE BOTTOM. Then come back when you have questions that make sense. -- |
Durnus
Member #7,997
November 2006
![]() |
May I suggest this C++ book? I learned from it, it has stuff about about classes and basic programming practices, such as the standard library. I highly suggest it.
|
Steve Terry
Member #1,989
March 2002
![]() |
Steve head hurt >_< ___________________________________ |
Matthew Dalrymple
Member #7,922
October 2006
![]() |
Steve smash steve go boom boom steve no likey =-----===-----===-----= |
kosmitek
Member #8,151
December 2006
|
LennyLen thank you - you are very helpful - Can I give you some points for help ? I read c++ books and now I want use my knowledge but it is now the most complicated programm which I want write so I want that you help me - do some of you have really to be such boorish ? I change my code - could you now what in this code is wrong ??
|
Durnus
Member #7,997
November 2006
![]() |
If you could please post the errors, that would be good. I, for one, do not like to take the time to compile your code. I did with yours though, just for the heck of it. [Edit:] Yes, I did just contradict myself. I spotted one problem: You did not declare your "buffer" bitmap before trying to set it to a value. The other problems I cannot figure out, because I have no clue what boardboard is, and what the point of most of the functions are. [EDIT2:] I just noticed something... you are trying to use strings as bitmaps when creating a "boardboard". This cannot be done. If you want to load a bitmap, you would want to use this. [EDIT3:] After more attempts to fix your code, I gave up. Personally, I would re-write my code and use comments more often. It seems your code is very disorganized, and you don't even use the game loop function in your main function. (At least I don't think so.)
|
BAF
Member #2,981
December 2002
![]() |
WTF is that? |
Jonatan Hedborg
Member #4,886
July 2004
![]() |
It's slightly amusing but probably more depressing, thats what it is!
|
TeamTerradactyl
Member #7,733
September 2006
![]() |
kosmitek: 1) You should probably put the class declaration in its own header (.H) file and the implementation in a .CPP file: something.h: something.cpp:
2) You should put your movement TEST routines in a regular function, not a class. You should keep your movement LOGIC routines in the class: That would also take care of the need for the GOTO statement in there: it would be processed fine without ever needing that. 3) As Durnus said, you are trying to pass strings: boardboard something ("board.bmp", "pawn.bmp", NULL); into a function that is expecting a BITMAP pointer: boardboard(BITMAP a, BITMAP b, BITMAP c) (which should be <b>boardboard(BITMAP *a, BITMAP *b, BITMAP c), by the way. You would want to change either:
...or...
4) I'm not entirely certain what you're doing with all those pointers (tab1 and tab2), but you could DEFINITELY be able to simplify those, or get rid of them entirely (why have an array with the VALUES 0..9, instead of just using "0..9" as numbers?).
|
Steve Terry
Member #1,989
March 2002
![]() |
We went through this last thread... I don't have any idea what C++ book you read but you gotta find something better. I hope it's not a Sams Teach Yourself C++ in 24hr books either. ___________________________________ |
X-G
Member #856
December 2000
![]() |
Look, the very fact that you're trying to impose an object-oriented design approach onto something that isn't designed that way in the first place is the clearest indicator we could possibly get that you just don't understand object-oriented programming. Get a different book, read it slowly, and follow the exercises if there are any. -- |
Durnus
Member #7,997
November 2006
![]() |
May I suggest my previously suggested C++ book? Durnus said: May I suggest this C++ book? I learned from it, it has stuff about about classes and basic programming practices, such as the standard library. I highly suggest it. As I have said, it doesn't include just classes, but basic C++ programming. (No offence intended with the basic stuff, but it is a very good book to learn classes from. And as X-G said, you are trying to make classes for something that doesn't need them.
|
|
|