Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon

14. August 2015

 

In this part of the ongoing Paradox3D Game Engine tutorial series we are going to accomplish two tasks.  First we are going to show how to set the resolution of our game in Paradox Studio.  We will then look at an example of extending Game and implementing the same thing using code.  This will be a fairly short tutorial, but needed, as the process isn’t entirely intuitive.

 

As always, there is an HD video version of this tutorial available here.

 

Setting the Screen Resolution using Paradox Studio

 

The process of setting the resolution is incredibly easy, but certainly not intuitive.  To set the resolution, in Solution Explorer within Paradox Studio, right click the game package ( FullScreen in my case ), then select Package properties.

image

 

Then in the Property grid, set the width and height desired:

image 

And done.

 

Extending Game

 

Create a new class in your .Game project, I’m calling mine MyGame.cs.  Now enter the following code:

using SiliconStudio.Paradox.Engine;

namespace FullScreen
{
    public class MyGame : Game
    {
        protected override void Initialize()
        {
            // Set the window size to 720x480
            GraphicsDeviceManager.PreferredBackBufferWidth = 720;
            GraphicsDeviceManager.PreferredBackBufferHeight = 480;

            base.Initialize();
        }
    }
}

This code simply sets the resolution by using GraphicsDeviceManager to set the PreferredBackBufferWidth and Height to our desired dimensions.  Initialize is called after your applications constructor, but before a window is displayed, making it an ideal location to set the resolution.  Why preferred?  Well because frankly outside of desktop platforms (mobile), you often don’t have control over the window size.  Like the previous tutorial, it’s very important to remember to make your class public.

 

Please note, Initialize() is just one point in the application lifecycle, there are several other protected methods you can override to gain much more precise control over the lifecycle of your game:

image

 

Now that we have created our own custom game class, we now need to update the entry point for each target platform to create an instance of our new class instead of using Game.

image

 

Edit the ___App.cs file accordingly:

 

using SiliconStudio.Paradox.Engine;

namespace FullScreen
{
    class FullScreenApp
    {
        static void Main(string[] args)
        {
            using (var game = new FullScreen.MyGame())
            {
                game.Run();
            }
        }
    }
}

 

 

The Video

Programming , ,

14. August 2015

 

In this part of the Paradox3D game engine tutorial series we are now going to look at how you actually program your games.  In the end you will discover that it’s actually a pretty straightforward process, but could certainly use some streamlining.  ( The option to generate a .cs file when you add a script component would be a nice little time saver… ).  Minor quibble however… let’s jump in.  The code in this particular example was written to target version 1.2.  If the code doesn’t work any more, be sure to check the comments for suggestions.  If there is no fix there, please email me.

 

As always, there is an HD video of this process available here or embedded below.

 

Creating a new Script

Scripting in Paradox is a two step process.  First you create the script, generally in Visual Studio.  Then you attach the script to an entity, either programmatically, or using the editor.  We are going to look at the process of creating the script first.

 

In Visual Studio, inside your .Game folder, create a new cs file.

image

 

I personally called mine ExampleScript, outside of standard variable naming requirements, the name really doesn't matter.  We now have two options as to how we want to implement our script.  It can either be a SyncScript or AsyncScript, we will show an example of both. 

A SyncScript as the name suggests, runs Syncronously.  That is, the game loop iterates over and over and we frame our script’s update function is called and we handle the logic of our script.  An AsyncScript on the other hand, takes advantage of C# 5’s async functionality, and allows your script to run in parallel.  This could lead to performance gains on multi processor machines.  Which works best is ultimately up to you and your game’s design.

SyncScript example:

using System;
using SiliconStudio.Paradox.Engine;

namespace ScriptingDemo
{
    public class ExampleScriptSync : SyncScript
    {
        public override void Update()
        {

            if (Game.IsRunning)
            {
                if (Input.IsKeyDown(SiliconStudio.Paradox.Input.Keys.Left))
                {
                    this.Entity.Transform.Position.X -= 0.1f;
                }
                if (Input.IsKeyDown(SiliconStudio.Paradox.Input.Keys.Right))
                {
                    this.Entity.Transform.Position.X += 0.1f;
                }
            }
        }
    }
}

 

AsyncScript example:

using System;
using System.Threading.Tasks;
using SiliconStudio.Paradox.Engine;

namespace ScriptingDemo
{
    public class ExampleScriptAsync : AsyncScript
    {
        public override async Task Execute()
        {
            while (Game.IsRunning)
            {
                await Script.NextFrame();

                if (Input.IsKeyDown(SiliconStudio.Paradox.Input.Keys.Left))
                {
                    this.Entity.Transform.Position.X -= 0.1f;
                }
                if (Input.IsKeyDown(SiliconStudio.Paradox.Input.Keys.Right))
                {
                    this.Entity.Transform.Position.X += 0.1f;
                }
            }
        }
    }
}

 

This particular tutorial isn’t actually about how you program Paradox, so don’t pay too much attention to how the code works, that will all be explained later.  Just be aware that both Async and Sync scripts do the same thing, transform the Entity they are attached to along the X axis when the Left or Right arrow keys are pressed.  The important take away points are that your script derive from one of the two mentioned classes, that your script has access to the entity it is attached to and actually has access to the entire game engine, allowing you to do just about anything.  Update() is not the only callback function implemented, there is also one for Start and Cancel available, if you need to do startup or cleanup functionality.

 

One final extremely important note…  MAKE SURE YOUR CLASS IS PUBLIC!   Otherwise it will not be available in the editor!  Sorry, I’ll stop yelling now.

 

Implement one of the two scripts ( or both, it doesn’t matter ), then compile your project to make sure you haven't made any errors.  We are now ready to attach the script to an entity in Paradox Editor.

 

Attaching a Script using Paradox Studio

 

Now that we have a script, we can attach it to one or more entities in our scene.  In an ideal world, Paradox Studio should notice the changes you made, and pop up a dialog telling you so.  Unfortunately, at least right now, it rarely succeeds with the first script you create.  In this case, simple do a quick restart of Studio using the menu, File->Reload project.

image

 

Now in the 3D view, select the entity you want to attach a script to.  If you are unfamiliar with operating Paradox Studio, please refer to this tutorial.  I am going to attach this script to the sphere model created in a default scene:

image

 

Now go to the Property Grid and press the Add Component button and select Scripts from the drop down.

image

 

Now scroll down to the Scripts component that should have been added, Click the green plus sign next to Script, then in the drop down for Item 0, select your script.

image

 

Run your game using the toolbar:

image

 

You can now control the sphere using the arrow keys:

AttachingArrowKeyScript

 

A couple cool things here.  First this shows that the same script can be used to control multiple entities.  We could attach the exact same script to our camera, the light, another model, etc… and it would just work.  Second, you can attach multiple scripts to the same entity.

 

What we didn’t cover

We covered the basics of attach a script to an Entity in Paradox, and I think it should give you a good idea of how you add logic to entities in your game.  There are two things we didn’t cover (yet), that I think it should be important to be aware of before we move on.

 

First, in addition to the SyncScript and AsyncScript classes, there is a third scripting type, StartupScript.  This is a type of script that is called when your object is created.  The major difference is it is not called each frame or async, like the other two scripts.

 

Second is the game class.  If you look in your generated project, in each platform you will see an entry point, like this one for the Windows platform:

image

 

Here are the contents of that script:

using SiliconStudio.Paradox.Engine;

namespace ScriptingDemo
{
    class ScriptingDemoApp
    {
        static void Main(string[] args)
        {
            using (var game = new Game())
            {
                game.Run();
            }
        }
    }
}

 

As you can see, the heart of this script is to create an instance of Game, then call Run().  If you require more control over the lifecycle of your game, you can easily derive your own game from the Game class and create an instance of it instead.  We will see a simple example of this process in the next tutorial.

 

Don’t worry if you are a bit lost on the specifics of the code, I had no intention of explaining how the code actually works, those posts will be coming in the near future.  You should however have a good idea now of how you create a script and attach it to your game entities.

 

The Video

Programming , ,

13. August 2015

 

Paradox ships with a full 3D editor named Paradox Studio.  In this tutorial we are going to take a look at what it can do and how it works. 

 

Once again, there is an HD video version of this tutorial available.

 

Paradox Studio Introduction

 

This is Paradox Studio:

image

 

This is where you can import assets, create entities, add components and instantiate them into scenes.  In a nutshell, it’s where you can visually compose the elements of your game.  Using Studio is strictly optional ( as is using Visual Studio ) but it can make your life a great deal simpler.

 

The majority of panels are configurable, can be minimized or re-docked in whatever pattern you prefer:

image

 

I am going to cover each panel one at a time.

 

Scene Graph

image

This is where you compose the entities that make up your game.  All game elements are entities, which in turn are containers for components, that can themselves consume or use assets.  Don’t worry, we will cover this in more detail later.  Just think of it this way… the Scene Graph is the stuff that composes your world, and all the “stuff” in your game is ultimately an Entity.  In the above screen shot, you can see the default scene created when you create a new project, it consists of a Scene that has a Sphere(Mesh), Ground(Mesh), Camera(Camera), Directional Light(Light) and Skybox(Light) entities.

 

If you create multiple scenes (I’ll show you how shortly), they will appear across the top in tab form.

image

 

This is only panel that cannot be minimized or moved, although it can be resized.  I suppose I should point out that the Scenegraph and 3D view are actually the same window, but they serve very different functions, so I will treat them as a separate windows for this tutorial.

 

You can create new entities using the imageicon, which will drop down the following menu:

image

 

Remember, an Entity is simply a container for Components, all of which have a default component called Transform, that allows them to be positioned in the world.  This means you can create the equivalent of a Point light entity by creating an Empty entity and adding a Light component to it.  We will see the component options later on.  When you create a new entity, it will be created (and automatically selected) in the 3D view:

image

 

Clicking the small magnifying glass beside the entity will automatically focus the 3D view on that entity, zooming in on it.

 

One last important concept to understand is parenting.  If you create a new entity with an entity selected, the new entity will be parented to the selected entity, like so:

Scenegraph_CreateNew

 

The newly created light will now inherit transforms applied to it’s parent, but can also be transformed independently.  The inheritance only goes down the genealogy, not up.

Scenegraph_Parent

 

Solution Explorer

 

image

The ultimate file format for a Paradox project is actually an sln file, in other words, a Visual Studio Solution file.  On top of that, Paradox provides a format for bundling codes and assets together, the package ( pdxpkg file extension ).  The Solution Explorer is where you manage the contents and dependencies of your project.

 

You can create sub folders to better organize your assets:

image

 

Even create entire new packages:

image

 

You can also create new assets directly from the Solution explorer:

image

 

Asset View

 

image

 

The asset view shows you the assets in the currently selected folder from the Solution View.  You can select an Asset (to edit it’s properties in the Property Grid, which we will cover shortly) by left clicking it. 

You can create new assets, or import existing ones, using these two toolbar buttons:

image

You can also import an asset using drag and drop from Windows Explorer:

AssetImport

 

You can also drag and drop Assets to the 3D view to create new Entities.  Here for example is dragging and dropping a 3D model asset.

AssetDragToInstantiate3DView

 

Asset Preview / History / References

These three panels are all actually separate, but by default appear together and are pretty straight forward, so I will cover them as a single entity.  Much of the functionality in these panels requires you to select an asset in the asset view.

Action History

image

Simply a stack of actions you’ve performed.  You can undo/redo using the typical CTRL+Z | CTRL+Y hotkey.  In all honesty, not sure why you would use this panel.  It’s display only, you cant change anything.

 

Asset Preview

image

A handy quick preview of how an asset would look.  The above screenshot is with a material asset selected, you can then pick a geometric shape to apply your material to.  For 3D models, it instead loads a simple model viewer.  Can be controlled via the mouse, scroll wheel zoom, right button pans and left button orbits the camera.

 

References

image

There are two modes of operation for this panel, References and Referencers.  It’s a great way to see what assets/entities use an asset, and in turn, what assets an asset depends on.  The above example is the Referencers tab with the default Sphere material selected, you can see that the Sphere Procedural Model uses this asset.

 

Property Grid

image

 

This is probably the most important panel in Paradox Studio.  The contents are entirely dynamic, depending on what you have selected in the editor.  The above example shows the properties with a Material asset select.  As you can see, numerous material properties can be configured here.  The settings vary from asset type to asset type.  Below for example shows a Model asset selected:

image

 

This nicely illustrates the relationship between assets.  Remember earlier when I selected the Sphere Material and it showed the Procedural Model as a Referencer?  Well this is where that reference was set.  You can see that the material attached is a Sphere Material ( the example I showed earlier in the Property Grid ).  You can easily select these relationships by clicking the Hand icon:

image

 

This will in turn bring up the Asset Picker dialog, and show compatible assets:

image

 

As you can see, you can access the entire solution, in case your asset exists in a different folder or package entirely.

 

The Property Grid functionality changes completely however if you have an Entity from the Scenegraph selected instead of an Asset, like so:

image

 

This is where you can both configure existing, or add new components to your entity.  As I said earlier, Entities are simply containers for components.  The above example is a camera, which you can see is composed of a Transform component and a Camera component.

You can also add new components to an entity using the Add Component button.

image

 

I will cover the entire process in more detail later, including how to do this all using code instead.

 

3D View

image

Finally we have the 3D view ( which technically is the same panel as the Scene graph as mentioned earlier ).  This is a 3D representation of your game world.  As we saw earlier, we can create new instances of an asset by dragging and dropping.  You can also easily select and transform assets in your scene.  If you are comfortable with a 3D application like Max or Maya this concept should be immediately comfortable to you.

 

You can move, rotate and scale using the toolbar across the top. 

image

Or using the following hot keys:

  • Q – Select
  • W – Translate/Move
  • E – Rotate
  • R – Scale

When you select an object, a 3d manipulator widget is displayed, like this one for rotating:

image

Each color corresponds with a particular axis, so the blue circle rotates around the Z axis, green around the Y and red around the X.  You can also use the grey ball in the middle to transform along all 3 axis at the same time.

You can also use these control bar buttons:

image

To configure which coordinates the manipulator should work on, world space, local space, or camera.

 

Misc

image

Across the top of the application is the above toolbar.  The icon on the far left opens the project in Visual Studio.  The grayed out button syncs changes between the two.  The next button enables you to compile your code, Visual Studio is not required.  The play icon enables you to run your game and it will run for the platform selected in the drop down to the right.  The final button enables live scripting, something we will talk about later.

 

image

Using the View menu you can toggle the visibility of every single panel we just discussed.

 

image

Pressing Ctrl + Shift + D or Help Menu->Show Debug Window, brings up the above invaluable tool.  It contains the various logs and handy debugging details as your game runs.  If something goes wrong, this is the first place you should go for details.

 

The Video

 

Programming , , ,

11. August 2015

 

Welcome to the very first tutorial in the Paradox Game Engine tutorial series, this section is going to cover installation and getting started.  The process is in reality incredibly straight forward, so this should be fairly short.  If you are unfamiliar with the Paradox Game Engine, consider starting here for an indepth review of Paradox’s functionality.

 

As with most tutorials on GameFromScratch, this one is also available as an HD video.

 

Getting Started

To get started, of course you are going to need download a few things.

 

Either version of Visual Studio will work.  If you don’t have a license, remember the community edition is free for small teams and people who make less than $1million per year in revenue.  You don’t specifically need to have Visual Studio installed, Paradox actually ships a copy of MSBuild and the .NET framework includes the C# compiler.  If you want to instead use your favorite text editor, that is an option.  These tutorials are all going to assume you are using Visual Studio however.

 

If you are going to be using Visual Studio, and don’t already have it installed, make sure it is installed before installing Paradox, as part of the Paradox installation will install a plugin to Visual Studio.  I am not going to go through the Visual Studio installation process; however if you choose strictly default settings, it will work out just fine.

 

Once you have Visual Studio installed, make sure you run it at least once to allow it to do some late step configurations.  This may not be strictly necessary, but better safe than sorry.

 

Next run the Paradox Installer you downloaded earlier.

image

 

The install process is extremely straight forward, basically just asking you which shortcuts you wish to create.  Once complete, the Paradox Launcher will be run.  This is the application you use to create new or open existing Paradox projects, as well as managing which version of Paradox you have installed:

image

 

It will now detect that you don’t have an SDK installed ( assuming you don’t have a prior install ), when prompted, choose yes:

image

 

It will then ask if you wish to install the Visual Studio integration, again click yes:

image

 

Your Paradox install should now be complete.

 

Creating Your First Project

 

Now that Paradox is installed and configured, let’s create our first project.  In the Launcher, click the big purple Start button,  your actual version number could obviously differ from mine.

image

 

This will launch the New/Open Project dialog.  You may notice there are several examples you can load.  In this case we are going to create a new project instead. 

image

 

The only thing to be aware of here is when naming your game, be sure to use a C# namespace friendly value.  For example, Game3D works, but 3DGame will work here, but then blow up when you get to the project in Visual Studio.  For a very detailed description of what’s allowed and what’s not in a C# variable see here.  Simple rule of thumb however, don’t start with a number or punctuation other than an underscore and keep away from oddball characters and you should be good.

 

Once you click the Select button, you will be taken to another dialog:

image

 

Here you can choose which platforms you want to support.  You may notice that Windows Store and Windows Phone are both showing “The Requirements to build for this platform are not met on this machine”, that is because I do not have the proper signing keys configured.  The value “Windows 10” might also be a bit confusing, as a normal “Windows” project will run just fine on a Windows 10 machine.  In this case “Windows 10” refers to the now renamed Universal apps, that enable your code to run on desktop and mobile Windows platforms.  It’s also important to note that Android and iOS development require a Xamarin license.

 

The final options are for configuring the starting graphics configuration as well as the starting orientation.  Once done, click OK.  This will then launch Paradox Studio:

image

 

Paradox creates a simple preconfigured scene for you.  Most importantly it sets up all the graphics configuration for you.  Feel free to delete everything from the scene, although I would recommend keeping at least the camera initially.

 

You can now test that your Visual Studio integration works properly.  In the toolbar you should see this:

image

 

If you have multiple versions of Visual Studio installed, you should be able to select which one you wish to use.  In my case I have only Visual Studio 2015 installed.  Either click the version you want to run, or the toolbar Visual Studio icon for the default.   Visual Studio should now open with your project displayed:

image

 

Looking in Solution Explorer you should see a project ending in .Game, as well as one project per platform you selected.  The .Game project is where the majority of your game logic will go, while platform specific initialization code will go in each platform project, if required that is.  You should also now see a new menu Paradox if you install completed correctly:

image

 

That’s it.  Paradox is now up and running and you’ve created your first project.  Stay tuned for the next part where we take a tour of Paradox Studio.

 

The Video

 

Programming , , ,

9. August 2015

 

 

EDIT:  The tutorial series announced below is now live and available here.

 

Hello All, just a quick update on an upcoming tutorial series here on GameFromScratch.com.   I have recently been looking at the Paradox game engine, cumulating in a Closer Look at Paradox3D.

 

I rather enjoyed my time with the engine, but I will say outright that the documentation is in pretty rough shape.  There are two ways to look at this.  For new users its a rough go and makes Paradox inaccessible.  For a tutorial writer however, it’s an opportunity, as the worse the documentation the more you need good tutorials! Winking smile

 

There is one major challenge here… the documentation is spotty for a reason.  The API is under active development and they are making breaking changes as they go.  This certainly presents a challenge.  Part of it is simply the nature of the beast, but I am going to address it in a couple ways.

 

First I am going to keep each tutorial quite small, so if it breaks it only breaks a small portion of the over all tutorial.  I am going to be doing both text and video tutorials.  It might be possible to update text tutorials as things break, but obviously this isn’t possible with the videos.  Second, I am going to mark the version I use for each tutorial.  I will keep with the most current release as I update the series, so you can quickly see what version the tutorial works with if things have in fact broken.  Quite often the comments section can capture and work around breaking API changes.  Finally I am going to keep the explanation in each tutorial to a minimum.  This will help keep tutorials small and will also help with the fact in many cases I am guessing at the best way to implement something.

 

I intend to cover as much as possible over the course of the series.  I am going to take a recipe type approach.  This is how you draw a sprite sheet, this is how you add animation to a model, this is how you play an audio file, etc.  Please let me know what you want to see covered.  Expect the first new tutorial early this week.

News , ,

Month List

Popular Comments

Valve Release Destination Workshop VR Tools
Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon


9. June 2016

 

Today on Steam Valve just released the Destination Workshop a free application for building VR environments.  Designed to work with any OpenVR headset, this toolset is built on top of the Source 2 engine and is available for free.  From the Steam store page:

Destinations Workshop Tools lets you create, share, and explore both real and imaginary places in virtual reality. This is a beta release of a set of content creation tools that users can use to construct worlds and share them on the Destinations Workshop – then explore them with the included Destinations Viewer.

Destinations Workshop Tools includes:

  • The Source 2 tool set used internally at Valve. Once installed, you can find theDestinations Workshop Tools in the Library under Tools.
  • Several example Destinations created with photogrammetry
  • An example map that users can copy and modify which highlights how to use Source 2 tools to add interactivity to a Destination
  • The Destinations Viewer, where users can browse and explore Destinations downloaded from the Steam Workshop. Once installed, you can find the Destinations Viewer in the Library under Software.

 

More information is available on the Destinations Wiki.  Are we entering the age of VRML 2.0?  (Actually technically VRML2 was actually released, but you know what I mean...)

GameDev News

blog comments powered by Disqus

Month List

Popular Comments