I am writing an article which needs to contain a project for sprite animation. I wanted to define a Sprite Class so that all the definitions & processing for sprite animation were shown in a modern way ( everything in my non 'OO' demo works perfectly ).
Because I know very little about C++ OO design I can't get my class working properly. After many attempts I can get a class defined as a nested class within MyGame in Blit but the problems I still have are:-
1. I Don't know how to get my class to do the loadimage inside the class so currently I am creating an instance of Sprite in GameInit() containing a surface & then doing the load image in the next line
2. The Sprite defined in GameInit does not exist in GameLoop so I can't use it.
It may be that I can't use a nested class in the way I'm trying to do. As I said my non OO code all works fine and I have added various functions inside Blit which work perfectly ( for SIP keyboard & Starfield )
but I seem to be stuck trying to use a class.
Any advice would be most appreciated. I would rather not force my 1980's programming tecniques onto new coders.
Because I know very little about C++ OO design I can't get my class working properly. After many attempts I can get a class defined as a nested class within MyGame in Blit but the problems I still have are:-
1. I Don't know how to get my class to do the loadimage inside the class so currently I am creating an instance of Sprite in GameInit() containing a surface & then doing the load image in the next line
- Code:
Sprite cave(0,240,4,20,FALSE);
cave.image = LoadImage(display,IDB_CAVEMAN);
2. The Sprite defined in GameInit does not exist in GameLoop so I can't use it.
It may be that I can't use a nested class in the way I'm trying to do. As I said my non OO code all works fine and I have added various functions inside Blit which work perfectly ( for SIP keyboard & Starfield )
but I seem to be stuck trying to use a class.
Any advice would be most appreciated. I would rather not force my 1980's programming tecniques onto new coders.