Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

the_moo

function argument problem

This topic is 5280 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi all, this problem might seem a little hard to believe but hear me out. i''ve got a function that takes care of all the game play in my game (drawing, destroying, all those sorts of things). when i use it with one set of variables (all are referenced by the function) it works fine, the game plays as it should, but when i use another set of functions that are pretty much the same as the first set (i.e. they are designed for 2nd player data so they are just named differently), none of the stuff that''s supposed to happen happens... the function is called with the first set of variables, then the second set, but no matter which order, the first set will work and the second won''t. please, anyone who can, shed some light on this for me (and help me if you can) thanx

Share this post


Link to post
Share on other sites
Advertisement
Sorry. You have not described your problem in a way that will even let us begin to figure out what the problem may be. There is no way for us to help you until you do so. A minimal (we don''t want your whole project) but complete (compiles, runs, demonstrates the bug) code example would be a good place to start.


“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
— Brian W. Kernighan

Share this post


Link to post
Share on other sites
sorry i tried to explain it as best i could without giving code for two reasons:
1. even a sample of just the code that is messing up is will be a lot,
2. either way i give the code (whole or just the problem) you wont be able to run it because like i said, its a game, you wont have the graphics etc.

since you say you cant help though ill ignore my first reason for now. hope it can help show the problem.

this is the function that gets called twice:

void Play(Block &preview, Block &control, Switcher &swap,
Field &playf, int fieldnum, BBlock &firstsplit,
BBlock &secondsplit, int &breaknum, int &fallnum,
int &score, int &oppdamage, int &storenum, int &storefall,
bool &freeze, int &stopup, int &move, POINT &boom,
int &playmode, bool &change, bool &playit,
int &total, bool &explode, int &dropsp)
{
//Show PL preview blocks

preview.ShowBlocks(lptemp,lpddsback);
//Show PL controlled blocks

if(playmode == 1)
{control.ShowBlocks(lptemp,lpddsback);}
else
{swap.Show(lptemp,lpddsback);}
//Store the block data in the field object

if (!control.CollisionTest(0,1,playf))
{
control.Split(firstsplit,secondsplit);
playf.SetBlocks(fieldnum,firstsplit,secondsplit);
playf.dropping = TRUE;
control.ResetData();
}
if (dropsp == 0 && breaknum == 0)
{//Drop blocks

playf.DropBlocks();
}
if(!playf.dropping)
{for (int count2 = 1; count2 <= 126; ++count2)
{if(playf.Link
(count2,playf.blockdata[count2].colour) >= 4)
{playf.DestroyBlocks
(state,breaknum,fallnum,oppdamage,score,&boom,total);}
else
{for (int count = 1; count <= 126; ++count)
{if (playf.blockdata[count].linked == 1)
{playf.blockdata[count].linked = 0;}
}
}
if(playf.blockdata[count2].colour > 0 &&
count2 == 122)
{GameOver();}
}
}
if(dropsp == 0)
{
if(!playf.dropping)
{if(!control.CollisionTest(0,1,playf))
{if(fallnum > 1)
{dmperf->PlaySegmentEx(chain,NULL,NULL,DMUS_SEGF_SECONDARY,
0,NULL,NULL,NULL);
}
fallnum = 0;
if(!change)
{if(playmode == 1 && !end)
{//Setup position of PL1 new blocks

control.MakeControl(preview,fieldnum);
preview.MakePreview(fieldnum);}
}
else
{if(playmode == 1)
{playmode = 2;
swap.Setup(fieldnum);}
else
{playmode = 1;}
change = FALSE;
}
}
}
dropsp = 8;
}
--dropsp;
playf.ShowField(lptemp,lpddsback);
if(playmode == 1)
{animspeed = 11;}
if(playmode == 2)
{animspeed = 18;}
POINT *spare = &boom;
for (int count = 1; count <= total; ++count)
{int cell = blockdie.Animate(lpddsback,lptemp,animspeed,
spare[count].x-4,spare[count].y);
if(cell == 0)
{explode = TRUE;
breaknum = 0;
total = 0;}
if(cell == 1)
{dmperf->PlaySegmentEx(kill,NULL,NULL,DMUS_SEGF_SECONDARY,0,
NULL,NULL,NULL);}
}
if(explode && state == story)
{int cell = blueboom.Animate(lpddsback,lpanims,4,spare[2].x,
spare[2].y-5);
if(cell == 0)
{explode = FALSE;}
}
if(breaknum > 3)
{storenum = breaknum;
stopup = 75;
move = 0;
storefall = fallnum;
if(fallnum > 1)
{if(playmode == 1)
{score = score+((storefall*7)^2);}
if(playmode == 2)
{score = score+((storefall)^2);}
}
}
if(stopup > 0)
{if(move != -50)
{--move;}
if(storenum > 4)
{ComboShow(storenum,moveup,&boom,playit);}
if(storefall > 1 && storenum > 3)
{ChainShow(storenum,storefall,moveup,&boom);}
--stopup;
}
else
{storenum = 0;
storefall = 0;
playit = FALSE;
fallnum = 0;}
}


and this is how it is called:

Play(preview1,control1,switch1,fplay1,1,split1,split2,
num,dropnum,score1,damage2,store,storedrop,stop,
blockup,moveup,*blow1,pl1mode,modechange,play,tot1,
explode1,dropspeed);
Play(preview2,control2,switch2,fplay2,3,split3,split4,
num2,dropnum2,score2,damage1,store2,storedrop2,stop2,
blockup2,moveup2,*blow2,pl2mode,mode2,play2,
tot2,explode2,dropspeed2);


as you can see in both calls the variables are just named differently.

thanx again for any suggestions

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!