Was having a good old discussion on enhancements to the framework with Asimov and wanted to pick his brain more on what he's done to make a more robust game using the framework.
So, Asimov, first off congrats on catching that little break There aren't many feelings in this life greater than solving a frustrating glitch in your program and seeing it perform exactly as you intended. Can't wait to see where you take this little game.
Your last post on the framework enhancments you've made to make this game possible was:
I was curious about this. You say you call the function with "Turret.Sprite(380,520,100,&gfx);", but this seems to be a different function than the one in your code block. Is there another function that calls the SpriteLoader::Sprite function?I learnt a lot from watching Chillis tutorials, and found I was confident enough to write my own sprite routine. I made a sprite class. My class will handle animated sprites, and non animated sprites.
I load in the sprite sheet and my routine basically offsets to the next image. When it gets to the end it begins again.
I call my animated sprite with this
Turret.Sprite(380,520,100,&gfx);
and here is a section of my sprite class
Code:
bool SpriteLoader::Sprite(double x,double y, float Frametime,int delay,D3DGraphics* gfx, Timer timetest[])
{
DrawSprite((int)x,(int)y,gfx);
timetest[2].StartTimer(delay);
if (timetest[2].TimerCheck())
{
if (Time==0)
{
endtime= clock()+Frametime;
Time=1;
}
if (clock()>=endtime) {
Frame=Frame+1;
Time=0;
}
if (Frame==NumberOfFrames) {
Frame=0;
timetest[2].ResetTimer();
return false;
} // This starts the animation again
}
return true;
}
However my sprite class is huge now, as I have written all kinds of stuff in there. I also wrote my own font class which does non proportional fonts.
As for sound I started with chillis original class and added new functions to do sound looping, and to play and stop sound.
Couldn't have done it without chilli though.
Also I am curious about what your Timer class is doing in this function. I can see you've got an instance of Timer you are using called timetest[2]. It seems at least in this function you only use one, are there other places you need this to be an array? Or is there really no reason for it not to be just Timer timetest? So you have a function called Timer.StartTimer(delay). What does delay do? Make the timer wait a period of time before starting? Same with TimerCheck(). What is it looking/checking for? Because it is in an if statement I am guessing it returns a true/false bool?
Sorry for the long windedness, trying to step through this code and see what's happening. I can see how you are stepping through each frame using the clock(). I am guessing the variable Time, not Timer (as in if (Time==0)) is acting as an on/off switch (bool).
As I read it, this function gets called once a frame? It immediately Draws the sprite at x,y, then makes it's changes for next frame. Am I close here?
LASTLY lol, I can see from Missle Command you are making good use of the resource file . I am using XN Resource Editor and am curious as to how you do transparent colors for cons and such. I am guessing you have loaded the mountains and background and cities and such using resource files. Could you point me to any tutorials or good links or have any advice on using the editor and resource file effectively in express? I have loaded ICONS, but can't get transparency. Have not yet attempted anything beyond that and would greatly appreciate any help you can offer in this arena.
Thanks!!!
Toddfather.