Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (AndrewAMD, TipmyPip, OptimusPrime), 15,359 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
how to start creating a: single- and multiplayer game #257842
03/25/09 21:08
03/25/09 21:08
Joined: Feb 2009
Posts: 6
Österreich, St. Pölten
doom4 Offline OP
Newbie
doom4  Offline OP
Newbie

Joined: Feb 2009
Posts: 6
Österreich, St. Pölten
Hi!

I'm new with 3dgs (I meanwhile can script lite-c and rough understand how lite-c works) but not new in programming.

Now I want to start a simple network game (test) and I already read a tutorial from locoweed (thank you here for it).

My question is now: how can I create a game with both modes where the player can choose at startup
- a singleplayer mode with ai-players
or
- a multiplayergame via lan


without programming the game two times?



Last edited by doom4; 03/25/09 21:22.
Re: how to start creating a: single- and multiplayer game [Re: doom4] #257856
03/25/09 23:31
03/25/09 23:31
Joined: Jan 2004
Posts: 2,062
Hamburg, Germany
slacer Offline
Expert
slacer  Offline
Expert

Joined: Jan 2004
Posts: 2,062
Hamburg, Germany
Hi,

lets say you want to create a game with two players - to make it easy.

You could create two entity pointers playerA and playerB
And to make it even more simple: two actions acPlayerA and acPlayerB

action acPlayerA() {
playerA = me;
...

same for the other action...

In your main program is a kind of main loop which checks the current game mode like
- intro running
- menu running
- game running
- game pause

in case of "game running" you check another game state: player mode

- 1 player
- 2 player (two players with joystick sitting in front of the same screen)
- network mode

Your game loop calls different functions depending on your player mode (if the game mode is "game running")
it calls ai_function( playerB) if it is a single player game and the opponent is controlled by the AI

it calls input_playerB() in order to check the buttons pressed by the second player

If it is a network game, you have to change skills on playerB depending on network input.

In all cases playerA is controlled by a function input_playerA() which sends network commands only in case of "network game" ( the entity actions control all animations locally.)

This is just a raw sketch about how you could do it and it is not easy if it is your first try.
But the idea is to decouple input from Player A + B, AI or network from the action which animates the entities.

let 4 functions change skills of playerA and playerB and let 2 actions control its entity depending on my.health, my.move_mode, my.anim_mode,...

Our game was more complex when it came to game modes, because you could choose between
- single player ( against AI and return to menu after level complete)
- arcade (play against all possible enemies and maintain a highscore list)
- dual player (local)
- network (2 player)

We had to write the game only once - which was your question smile

-- slacer

Re: how to start creating a: single- and multiplayer game [Re: slacer] #257951
03/26/09 20:51
03/26/09 20:51
Joined: Feb 2009
Posts: 6
Österreich, St. Pölten
doom4 Offline OP
Newbie
doom4  Offline OP
Newbie

Joined: Feb 2009
Posts: 6
Österreich, St. Pölten
Thank you very much.
I think I have undersood how you did this.
And I'm happy to start easy with only single player and Multiplayer by network.


Moderated by  HeelX, Spirit 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1