Doing stuff on ya own is hard (directx)

The Partridge Family were neither partridges nor a family. Discuss.
User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Doing stuff on ya own is hard (directx)

Post by LuX » June 26th, 2013, 9:50 am

Asimov wrote:Big problem with rastertek is that is a direct10 tutorial and I have been learning directx9.
Also it is such a lot of code, and I don't understand the majority of it.
DirectInput is direct8 so it doesn't matter what version you use. DirectX will only come in when it's about graphics, everything else will be the same.

Don't worry about not understanding the code. Most of DirectX stuff is just standard code you have to type so understanding it immediately is hard and not even necessary. After you get it working you can start to look at the code and try to figure out what it all means.
ʕ •ᴥ•ʔ

User avatar
Asimov
Posts: 814
Joined: May 19th, 2012, 11:38 pm

Re: Doing stuff on ya own is hard (directx)

Post by Asimov » June 26th, 2013, 3:35 pm

Hi Shaki,

I understand your key stuff, but still scratching my head at the virtual void. I will have another look when I am less tired, but my brain is not taking it in at the moment.

Thanks
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk

User avatar
Asimov
Posts: 814
Joined: May 19th, 2012, 11:38 pm

Re: Doing stuff on ya own is hard (directx)

Post by Asimov » June 26th, 2013, 4:46 pm

Hi Lux,

I will look into it again then. Although I did get lost with it heh heh.
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Doing stuff on ya own is hard (directx)

Post by albinopapa » June 27th, 2013, 8:08 pm

Shaki wrote: Also virtuals are used in polymorphism, as if you have something with a non-true type you can set a function as virtual so that the current type will always run the function.

an example of a virtual is this:

Code: Select all

class Mother{
public:
Mother();
~Mother();
void doStuff();
};

class Child{
public:
Child();
~Child();
virtual void doStuff();
};

Child * kid = new Child;
Mother * mother = new Mother;
Mother * kid2 = new Child;
This means that the true type is more important now.
So even though its a 'Mother' pointer, it's value is child, and it will run the child's virtual function over the mother function..

If that made sense :p.
Using some of the situation from above it goes like this.

class Mother
{
public:
void breathing();
void sleeping();
void eating();
virtual void urinating();
};

class Child : public Mother
{
void urinating();
};

Mother and child would have the same functions and the difference would be breathing, eating and sleeping would be carried out the same for both the only differences would be the members ( sizeofbite, LengthOfSleep, or BreathsPerMin ). Whereas, urinating, where if child is a male and of course mother being female the process to urinate is different, but they both urinate.

The project I am working on with cameron, another user on this forum, he has setup his project so that he defined a base class that does the bulk of the work, and there are virtual functions for just a few different class type ( derivative classes ). The virtual functions are listed in the base class, and the altered functions go in the derivative ( child ) classes is what I really was trying to get at.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
Asimov
Posts: 814
Joined: May 19th, 2012, 11:38 pm

Re: Doing stuff on ya own is hard (directx)

Post by Asimov » June 27th, 2013, 8:26 pm

Hi albinopapa,

So is void urinating(); the original one and the virtual void urinating(); a virtual one that shares the same functions as the one in child.

So would you actually only put the method in the one class? eg the parent class.
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Doing stuff on ya own is hard (directx)

Post by albinopapa » June 27th, 2013, 8:34 pm

virtual void functionname( );

This is declared in the parent class, it tells the compiler that derivative classes will have their own way of dealing with the function. You also don't have to even have it defined in the parent class

virtual void functionname( ) = 0;

This statement means the default function is the one defined in the child class.

EDIT:
Just to expand a bit, the project cameron and I are working on, we have 9 or 10 child classes and only 2 of those classes have functions that need to do something different. One child class has to change from attacking to moving or vice versa and it take about 3 seconds to do so. So the move and attack functions are different than the parent class move and attack functions to check which state the unit is in. Also, it has different draw states for the different states it's in. One of the units is stationary so we didn't need a move function in it's list of possible states ( searching, attacking or dead ) so the function we use to choose the actions is different than the parent class. All the other functions that are shared and don't need to be different are defined in the parent class and are used by all the child classes, such as Adding a unit, deleting a unit, assessing and choosing what actions to take when it's that units turn.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: Doing stuff on ya own is hard (directx)

Post by LuisR14 » June 28th, 2013, 9:41 am

albinopapa wrote:You also don't have to even have it defined in the parent class

virtual void functionname( ) = 0;

This statement means the default function is the one defined in the child class.
tho you can't use the parent class directly using this method :P (class becomes an abstract class)
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

Post Reply