S&box Wiki

Revision Difference

Games/GettingStarted#551026

<title>Getting started - making a game in s&box</title> # A New Game Project The first step is to create a Game Project. Do this by going to `File > New Project` in the editor. The first step is to create a [Game Project](GameProject). Do this by going to `File > New Project` 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. <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). </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 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.⤶ ⤶ # 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.⤶ ⤶ 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.⤶ ⤶