Jump to content

Recommended Posts

Posted

Create or join a lobby, then hold V key to talk.

MultiplayerGame.zip

Source looks like this:

#include "App.h"

using namespace Leadwerks;

int main(int argc, const char *argv[])
{
	Steamworks::Initialize();

	//World setup
	auto window = Window::Create("Multiplayer Game", 0, 0, 1024, 768);
	auto context = Context::Create(window);
	auto world = World::Create();
	auto gui = GUI::Create(context);	
	auto camera = Camera::Create();
	
	//Create server list
	auto serverlist = Widget::ListBox(20, 20, 400, 300, gui->GetBase());
	int count = Lobby::Count({ { "game","mplayertest" } });
	Lobby* lobby = nullptr;
	for (int n = 0; n < count; ++n)
	{
		lobby = Lobby::Get(n);
		serverlist->AddItem(String(lobby->steamid),n==0);
	}
	lobby = nullptr;

	//GUI buttons
	auto button_join = Widget::Button("Join",20, 20+300, 76, 28, gui->GetBase());
	auto button_create = Widget::Button("Create", 20 + 76 + 2, 20+300, 76, 28, gui->GetBase());
	bool recording = false;
	
	while (true)
	{
		if (window->KeyHit(Key::Escape)) break;
		if (window->Closed()) break;
		
		if (lobby)
		{
			if (recording)
			{
				if (!window->KeyDown(Key::V))
				{
					Sound::StopRecording(lobby);
					recording = false;
				}								
			}
			else
			{
				if (window->KeyDown(Key::V))
				{
					Sound::StartRecording();
					recording = true;
				}
			}
		}
		
		P2P::Receive(-101);
		
		Time::Update();
		world->Update();
		world->Render();
		
		while (EventQueue::Peek())
		{
			auto event = EventQueue::Wait();
			if (event.id == Event::WidgetAction)
			{
				if (event.source == button_join)
				{
					int index = serverlist->GetSelectedItem();
					lobby = Lobby::Get(index);
					lobby->Join();
					gui->Hide();
				}
				else if (event.source == button_create)
				{
					lobby = Lobby::Create();
					lobby->SetKey("game", "mplayertest");
					gui->Hide();
				}
			}
		}
		
		context->Sync();
	}
	return 0;
}

 

Let's build cool stuff and have fun. :)

Posted

i can hear someone testing but dont think they can hear me lol

Asus ROG STRIX B350-F GAMMING

AMD Ryzen 7 1700x

32 gb ddr4

15 TB raid 5 HD

Nvidia EVGA 1060GTX

Win10 64bit

Posted

it may be i have multy mic

so will check

 

Asus ROG STRIX B350-F GAMMING

AMD Ryzen 7 1700x

32 gb ddr4

15 TB raid 5 HD

Nvidia EVGA 1060GTX

Win10 64bit

Posted

yep that me lol

at home off sick for a while so can do lots of testing for you lol

Asus ROG STRIX B350-F GAMMING

AMD Ryzen 7 1700x

32 gb ddr4

15 TB raid 5 HD

Nvidia EVGA 1060GTX

Win10 64bit

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...