Click here to Skip to main content
15,887,350 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
www.xiquinho.com/mybooks/file/599/PDF[^]

This book goes over DirectInput, how to load & play force effect and has demo code. I followed the book, wrote the loading/playing code, and it runs without error. However it is not doing anything with the joystick. So, I followed the demo code also, but I'm having trouble with this part. The Demo is in page 213. Do I continue writing the code after public void Start(int iterations, bool restart), inside public class ForceEffect{}? When I try to do foreach() code in page 214, foreach goes outside of public class ForceEffect.


public class ForceEffect
{
System.Collections.ArrayList effectlist;
string name;
public string Name
{
get { return name; }
}
public ForceEffect( string filename, string name, Device device)
{
// save the name
this.name = name;
effectlist = new System.Collections.ArrayList();
EffectList effects;
effects = device.GetEffects(filename, FileEffectsFlags.ModifyIfNeeded);
foreach( FileEffect e in effects)
{
EffectObject effect = new EffectObject(e.EffectGuid, e.EffectStruct, device);

effectlist.Add(effect);
}
}
public void Start(int iterations, bool restart)
{
foreach(EffectObject effect in effectlist)
{
if(!effect.EffectStatus.Playing || restart)
{
effect.Start(iterations, 0);
}
}
}

/*
ForceEffect[] effects;
string instructions;
int currenteffect;
bool lastfiring = false;
bool lastchanging = false;
*/
}
Posted
Comments
Sergey Alexandrovich Kryukov 22-Feb-15 17:09pm    
Would you rather ask the book's author? Fast look at this not properly structured book gave me big doubt about its quality. The author should take responsibility for the code written in the book. Why should we even look at it?
—SA
Kuthuparakkal 22-Feb-15 17:16pm    
Yes, I do agree SA! Why should we bother.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900