Textures creation

From Xmoto
Jump to: navigation, search

If you want to create levels with an outfit, that can't be given by the current available textures, you'll have to add your own.

To do this, we have to be aware, that both, xmoto as well as the Inksmoto editor know the textures. Therefore we assume that we have already the texture created (Be aware that its size must be the power of two, 64x64, 128x128, ..., that they have to be square, and that they are saved as jpg's and png's, for not consuming too much space). Now we have to make it available for our use.

  1. As a first step, put your file into the ~/.xmoto/Textures folder. Be aware that there exist several sub-folders, and we have to choose the correct one, dependent of the type of our texture or sprite (HERE is a detailed overview of handling themes). If we use a texture that will be assigned to blocks, we take the ~/.xmoto/Textures/Textures sub-folder, and copy it into there.
    (In fact, for a quick and dirty test we could simply give the name of an existing texture like 'Dirt', and assign this existing one in the editor to our block to see how it looks, but this will lead to even more work afterwards. So we'll not go astray.)
    Now our texture is basically accessible for xmoto.

  2. But now, we'll have to tell xmoto that it may use the texture we put into its directory.
    To achieve this, we'll have to modify the theme file of xmoto. This one is located in ~/.xmoto/Themes. Normally there is the t1.xml theme file, which can simply be copied to test.xml for instance, and then be modified to our needs.
    We do this, and open it in a text editor (e.g. gedit ~/.xmoto/Themes/test.xml) and have a look at the second line, which is:
    <xmoto_theme name="Classic">
    Of course for not having two different theme files which refer to the same theme name, we'll have to change it, e.g.
    <xmoto_theme name="testing">.

    Now, we will add our texture.
    We can see that there are several types, that refer to the sub-folders from above. Now we will look for the ones with 'Texture' in it:
    <sprite type="Texture" name="Grass1" file="Grass1_210.png" />
    We simply copy the line and add our own values. For instance:
    <sprite type="Texture" name="Ashes" file="Ashes.png" />
    if the name of the texture file was Ashes.png, clearly.
    Finally we save the file, and start xmoto. Now we press F5 in the main menu screen (xmoto-0.3.0), and have it available under the options. Select it and save.

  3. To be able to assign our texture to blocks in Inksmoto-0.4.0 editor, we must also tell it that the file exists. Here it is not that difficult, we only need to modify the xml file that lists the names of all available game entities.
    To get the most actual one, first start Inkscape. We assume that Inksmoto is correctly installed and working. Go to the Effects - X-Moto menu item, and choose Update X-Moto menus.
    There will be a window popping up that gives you several options.
    First, we want to use the most actual list file as base. Therefore download it (most likely) per 'Direct Connexion' from the xmoto website. Now we can find this file in ~/.inkscape/extensions. It is called listAvailableElements.xml for Inksmoto-0.4.0.

    We open it: gedit ~/.inkscape/extensions/listAvailableElements.xml.

    Now we can see all xmotos media elements listed. So we add our texture now: Be sure we use exactly the same name like we did in the theme file for the 'name' field, in this case, we find the texture area and add:
    <texture id="Ashes" />
    Thats it - save and return to Inkscape. We still have to update Inksmotos menus.
    We open the menu update dialoge again, but this time we choose Local File and give the complete path to our modified list file. Press OK and thats it. Restart Inkscape and we can find the texture listed there when assigning to blocks.

  4. Export your Inkscape svg to a xmoto.lvl file and put it into ~/.xmoto/Levels/MyLevels, start xmoto and you should be able to see your texture ingame.

    Maybe you want to do some improvements on the texture, just do it and save it over the old file in ~/.xmoto/Textures/Textures, and you will have them immediately after a restart of xmoto.

  5. When you are finally ready with your level and satisfied with the look (and game play and so on) of everything, upload your level to the website, and also upload your textures to the website!

    Note that you don't have to change anything more, just be sure to give the same names in the name field on the sprite upload like you gave in your theme files, then everything should be fine.

    Levels with new textures or sprites usually need some more time to be validated, as there is some effort to update the official theme files and little time to to this, so be patient. After a few days everyone can enjoy your creativity!

Good luck!