Game Development Community

Making StarterGame 2 player?

by Ty Newton · in Torque X 2D · 01/14/2007 (9:33 pm) · 26 replies

Hi,

I'm modifying the StarterGame sample to handle 2 player input using the one keyboard: player1 = WASD, player2 = arrow keys.

I have 2 sprites in the level, both have the MovementComponent assigned to them.

When I mess around with the MovementComponent code I can't get anything to work properly. It seems like only 1 MovementComponent object is instantiated; rather than 1 for each sprite. Is this correct?

So I tried coding MovementComponent as if I was doing a fork() in C. This didn't work either.

Do I need to create a totally new component to make this work e.g. MovementComponentForPlayer2?

I tried looking at the tankbuster (I think ? I'm not at my dev machine atm) example and it is coded totally differently to StarterGame so I couldn't work out what was going on there.

Any advice?


Thanks,
T
Page«First 1 2 Next»
#21
01/23/2007 (12:48 am)
Thanks. I'll have a look at it. I must admit I never really got into it because I didn't want to learn the scripting language.
#22
01/23/2007 (3:51 am)
I just had a quick look at the code for TGB. Unfortunately like most programs I've looked at there is woeful documentation. If GG strip the in-code doco on purpose can I get an unstripped version please?

If doco isn't stripped on purpose then the project manager should be raked over the coals for not making sure the developers keep high quality source code. Many people will say "doco isn't so important as long as the code is solid". That won't help you when your key 1 or 2 staff decide to walk out the door for whatever reason...

In any case, I muddled through for a little while and came to this conclusion. Please correct me if I'm off on the wrong track.

- a scenegraph is created that abstracts a container holding all the objects in TGB
- if I were to traverse the graph I could find all the user editable controls (I may have to add a way to identify user editable controls)
- if I force all the controls to poll for their current state when 'save' or 'save as' is called then I should get fully up to date data (I may have to add a way for the controls to poll for their current state).

It looks like TGB currently has the controls telling something (not sure how this fits together) that they have been changed and this triggers their state to be retrieved when 'save' or 'save as' is called.


Perhaps I should create a new thread about this topic?
#23
01/23/2007 (10:32 am)
A new thread is probably appropriate. If the thread involves discussing inner workings of the TGB source code then it is probably appropriate to take the discussion to the private TGB engine forums.

#24
01/23/2007 (2:42 pm)
TY Newton...

I tried Thomas's solution, and it worked. Stop wasting everyone's time trying to comeup with your own home-brewed solution. I also learned alot from it... and plan on implementing it soon.
#25
01/23/2007 (9:47 pm)
Hi Modern1,

Thanks for the rude reply. You're the first person on these forums to be a ass. I hope you're the last as well.

If this thread of conversation, and my noob questions/comments, offend you then you should probably organise for the thread to be removed. I'm not sure how to go about getting a thread removed so I'll leave that up to you. You seem like the type of person who is better at destroying than creating...

Please refrain from participating in my threads if you have nothing constructive or positive to contribute.
#26
02/28/2009 (1:48 am)
I have just read through this thread, and got the code working correctly. Thanks, its pointing me in the right direction.

But my problem is that I am wanting 1 player to control two objects, instead of 2 players each controlling one object. Does anyone have any suggestions?

The game that I am trying to make is a 4 player game, each player controlling two objects, that can be moved around indipendantly.
Page«First 1 2 Next»