Jump to content

  • Log In with Google      Sign In   
  • Create Account

SonicD007

Member Since 23 Feb 2006
Offline Last Active Jun 23 2014 06:41 PM

Posts I've Made

In Topic: Having trouble accessing an objects properties.

29 December 2013 - 02:47 PM

I'm not 100% sure what the problem your running into is aside from accessing the derived classes data.

 

You could have character have a virtual method called DoAttack() where each derived class can override it to do whatever they have todo.  Another approach to the problem is to use composition and instead of creating bladewarrior, fistwarrior, drunkenwarrior, you could have a single class called GameMonster (or w.e) which would contain a pointer to another class that has more information on the type of monster it is.

 

This article should help you. http://gameprogrammingpatterns.com/type-object.html

 

The cool part about doing it that was is you can have all your different monsters in an xml file and modify attributes without having to recompile.  You can also make sub-monster types without having to specify every attribute and instead have it "inherit" from it's parent monster type.

 

EDIT: Since it's C# that you're using, you don't have to worry about pointers.  Classes are passed by reference so you can just set your monsters to have w.e monster type you want.

 

e.g. Monster m = new Monster(); //You could do it the way the article shows as well

m.SetType(new FistWarrior());

 

The only thing is that if you have custom attack patterns or something you would need to do a litle more work.  Maybe something like m.SetBehavior(new WarriorBehavior(WarriorStyle.Fist));   Just an idea, haven't gotten up to that yet in my project


In Topic: Input handling design frustration

29 December 2013 - 02:30 PM

I haven't had the time to mess with my project because of finals and it's the busy season at work, but I still need to implement input somehow in my game.  Right now this is holding me back from doing anything else (well mentally it's holding me back because I really want to get input to my game character so I can then implement collision and render my map with the player)


In Topic: Gamedev has shown me how I've grown

29 December 2013 - 02:25 PM

Great to see I'm not the only one!

 

Hodgman's little story made me laugh haha.

 

Gamedev is definitely the best community I've encountered on the internet.  When the day comes that I finish making my 2d rpg game....everyone here will know xD


In Topic: How can I use Windows Phone sensors to move an object?

26 December 2013 - 02:34 PM

I don't know how to use this formula in my code: On = On-1 + α(In – On-1)

How can I use the formula or a similar formula in my code?

I skimmed through the article and it seems they're using extrapolation to smooth out the data.  Someone else can chime in if this is too overkill for what you're doing, but the formula seems to be the formula of a line i.e. y= m(x-x1) + y1

 

If you've taken calc 1 that formula should be familiar to you (or pre calc)

I'm not sure what On-1 stands for in this context, it seems like it's an initial reading.  Maybe it's the first reading that's gotten over the  50 inputs they get?

 

In is the raw input data which the sensor would give you.  I haven't researched if the SDK gives you the reading filtered or not or if it really is raw data.  You'll have to research that.  Hopefully something on the wikipedia page can help you a bit more.

 

http://en.wikipedia.org/wiki/Extrapolation

 

The article is using linear extrapolation

 

EDIT: From what I gathered, you would use the formula to sample 50 inputs within a given amount of time and average them out using that formula to have a smooth input. alpha (α) would be 0 to 1 which is basically how much smoothing should be done.  It's a constant.


In Topic: How can I use Windows Phone sensors to move an object?

24 December 2013 - 02:56 PM

I haven't messed with the motion sensors on the windows phone, but you may need to take average out the inputs as opposed to directly translating the accelerometer input to values.  A person will not move a phone steadily.  The values will constantly move up and down which will cause your motion to be jagged and it will behave weird. 

 

I would take a couple of readings (couple of nano seconds?) and average the readings to see where it's mostly moving towards.  I would then apply that number to the acceleration for my object and update the object within the update(gameTime) method.  As for how you would implement this, I would google how others have done it.  Maybe google "interpolating accelerometer" or something of that sort would help.

 

EDIT: Actually interpolation ISN'T what you would use here.  See if this helps you out.  Also, I think you may need to call motion.Start() in your initialization code

 

http://blogs.windows.com/windows_phone/b/wpdev/archive/2010/09/08/using-the-accelerometer-on-windows-phone-7.aspx


PARTNERS