S&box Wiki

Revision Difference

Games/GettingStarted#551153

<title>Getting started - making a game in s&box</title> # A New Game Project The first step is to create a [Game Project](GameProject). Do this by going to `Project > Create New..` in the editor. You'll be presented with `Create New Project` window. Choose project type `Game`, and choose the template `Shooter Game`. Pick a name for your project and choose where you'd like to store it. # Shooter Game The shooter game project gives you the basic code that you need to make a first, or third person shooter game. To play the game you can click on the play icon in the project list. This will open the game's menu. <upload src="1/8db77290d35f58c.png" size="10783" name="image.png" /> You can also use the "Launcher" system, which is available at the top of the game view. This will take you straight into the game, skipping the main menu altogether. <upload src="1/8db772927554c6e.png" size="16148" name="image.png" /> # Editing The Code To open the solution in Visual Studio, go to `File > Open Solution`. The solution will contain a project containing your game's code, but will also include projects containing common code for the game and editor. You might wish to right click your game's project in the `Solution Explorer` and choose `Scope To This` to isolate just your project. To open the solution in Visual Studio, go to `File > Open Solution` in the S&box Editor. The solution will contain a project containing your game's code, but will also include projects containing common code for the game and editor. You might wish to right click your game's project in the `Solution Explorer` and choose `Scope To This` to isolate just your project. <note>Any changes you make to the code will be applied on save. The game will compile and hotload the new assemblies. You don't need to compile in Visual Studio. This works flawlessly 99% of the time, but if you've changed something that we can't hotload you might have to restart the game (using the restart icon at the top). This works flawlessly 99% of the time, but if you've changed something that we can't hotload you might have to restart the game (using the restart icon at the top of the game window). </note> For the most part the templates are designed to act like tutorials. They are heavily documented to help explain what's going on. # Glossary We might use some terms that you don't understand, so here are a few explanations. * `Client` - A [Client](Client) is generally a human that is connected to the game * `Entity` - An [Entity](Entity) is usually an object that exists in the world. They are usually synchronized between the server and client. * `Pawn` - A [Pawn](Pawn) is an entity that a player owns and controls - this could be a car or a humanoid * `Panel` - A [Panel](Panel) is a UI element * `RootPanel` - A [RootPanel](RootPanel) is a panel that holds a bunch of other panels. The HUD is usually on its own RootPanel. * `GameManager` - each game has one game manager. The [GameManager](GameManager) is actually an `Entity` * `Tick` - one server cycle. A tick is independent of the frame rate. The rate is adjustable. * `Tick` - one server cycle. A tick is independent of the frame rate. The tick rate is adjustable. # Shooter Game Overview When the game starts, the `MyGame` [GameManager](GameManager) entity is created. When a client joins, `ClientJoined` is called. From there a Pawn is created for that client. When a client joins, `ClientJoined` on `GameManager` is called. From there a Pawn is created for that client. Each tick, `Simulate` is called on the Pawn (automatically). This method takes client input and acts on that. The Pawn's current weapon is also simulated here too. On the client only, each frame FrameSimulate is called. This method is used to position the camera. On the client only, each frame `GameManager.FrameSimulate` is called. This method is used to position the camera. # Testing If you want to test your multiplayer game, you don't have to publish it. If you start a server, people will download everything they need from you. If you edit code, the code changes will be sent to them as you make changes. If you edit UI and stylesheets, they will be synchronized to your remote clients too. # Publishing To publish your game go to your game's [Project Settings](ProjectSettings) and choose `Upload To Asset Party` from the menu on the left. From there you will be guided through the process of publishing your first release. Once you make your game live, other people will be able to discover and play it.