Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Super Mario 2D. Questions.

Discussion in '2D' started by 8Observer8, Aug 12, 2015.

  1. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    Hello!

    Sorry for English in advance. I am creating Mario Clone for learning. It won't be for commercial usage. It's only for learning how to create platformer games.

    You will understand my problem if you will see the picture below (you will see vertical lines):

     
  2. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    It looks like you are missing padding around your tile textures.
     
  3. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    I use this tileset (16x16 for a tile):
    NES - Super Mario Bros - Tile Set.png
     
  4. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    I don't understand. Where must I find a problem?

    TileSetProblem.png
     
  5. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    You need to have some room ("padding") between the single tiles in your texture atlas. Textures tend to "bleed" over a little into adjacent textures.
     
  6. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    How to make a handling of texture atlas to add the padding? What programs can I use? I have Tiled Map Editor, but I think it cannot.
     
  7. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    I have "Pixel Per Unit" = 1. Maybe is it a problem?
     
  8. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    I solved the problem. I will create little tilesets from the general tileset. For example by Paint and GIMP or by Tile Map Editor:

    Hill.png

    TileSetSolution.png
     
  9. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    I found a solution here
     
  10. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    How to solve this problem:
    TiledProblemBattleCity.png
     
  11. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    I solved the problem above. I apply this plugin and I wrote my own plugin for GIMP in Python.

    Code (CSharp):
    1. #!/usr/bin/env python
    2. # -*- coding: utf-8 -*-
    3.  
    4. # add-pixels-to-tiles v1.0: Python-fu plugin for GIMP 2.8
    5. # Copyright Ivan Enzhaev (8Observer8) [http://ivan.enzhaev.name], 2015
    6. # Licence GPL-2
    7. # Installation: put the file into /GIMP 2/lib/gimp/2.0/plug-ins
    8.  
    9. from gimpfu import *
    10. import os
    11.  
    12. def python_fu_add_pixels_to_tiles(tile_size = 16):
    13.        # Get image
    14.        image = gimp.image_list()[0]
    15.        # Get drawable
    16.        drawable = pdb.gimp_image_get_active_drawable(image)
    17.        # Get width and height
    18.        width = pdb.gimp_image_width(image)
    19.        height = pdb.gimp_image_height(image)
    20.  
    21.        # Right
    22.        x = 17
    23.        y = 2
    24.        spacing = 5
    25.        y_counter = 0
    26.            
    27.        while y < height:
    28.         while x < width:
    29.          # Get color
    30.          color = pdb.gimp_color_picker(image, drawable, x, y, FALSE, FALSE, 0)
    31.          # Set end point
    32.          ctrlPoints = [x+1,y,x+2,y]
    33.          if color.a == 1:
    34.           # Set color
    35.           pdb.gimp_context_set_foreground(color)
    36.           # Draw points
    37.           pdb.gimp_pencil(drawable, 4, ctrlPoints)
    38.          x = x + spacing + tile_size
    39.         x = 17
    40.         if y_counter < tile_size:
    41.          y = y + 1
    42.         else:
    43.          y = y + spacing
    44.          y_counter = 0
    45.            
    46.        # Top
    47.        x = 2
    48.        y = 2
    49.        spacing = 5
    50.        x_counter = 0
    51.            
    52.        while x < width:
    53.         while y < height:
    54.          # Get color
    55.          color = pdb.gimp_color_picker(image, drawable, x, y, FALSE, FALSE, 0)
    56.          # Set end point
    57.          ctrlPoints = [x,y-1,x,y-2]
    58.          if color.a == 1:
    59.           # Set color
    60.           pdb.gimp_context_set_foreground(color)
    61.           # Draw points
    62.           pdb.gimp_pencil(drawable, 4, ctrlPoints)
    63.          y = y + spacing + tile_size
    64.         y = 2
    65.         if x_counter < tile_size:
    66.          x = x + 1
    67.         else:
    68.          x = x + spacing
    69.          x_counter = 0
    70.  
    71.        # Left
    72.        x = 2
    73.        y = 2
    74.        spacing = 5
    75.        y_counter = 0
    76.            
    77.        while y < height:
    78.         while x < width:
    79.          # Get color
    80.          color = pdb.gimp_color_picker(image, drawable, x, y, FALSE, FALSE, 0)
    81.          # Set end point
    82.          ctrlPoints = [x-1,y,x-2,y]
    83.          if color.a == 1:
    84.           # Set color
    85.           pdb.gimp_context_set_foreground(color)
    86.           # Draw points
    87.           pdb.gimp_pencil(drawable, 4, ctrlPoints)
    88.          x = x + spacing + tile_size
    89.         x = 2
    90.         if y_counter < tile_size:
    91.          y = y + 1
    92.         else:
    93.          y = y + spacing
    94.          y_counter = 0
    95.  
    96.        # Down
    97.        x = 2
    98.        y = 17
    99.        spacing = 5
    100.        x_counter = 0
    101.            
    102.        while x < width:
    103.         while y < height:
    104.          # Get color
    105.          color = pdb.gimp_color_picker(image, drawable, x, y, FALSE, FALSE, 0)
    106.          # Set end point
    107.          ctrlPoints = [x,y+1,x,y+2]
    108.          if color.a == 1:
    109.           # Set color
    110.           pdb.gimp_context_set_foreground(color)
    111.           # Draw points
    112.           pdb.gimp_pencil(drawable, 4, ctrlPoints)
    113.          y = y + spacing + tile_size
    114.         y = 17
    115.         if x_counter < tile_size:
    116.          x = x + 1
    117.         else:
    118.          x = x + spacing
    119.          x_counter = 0
    120.  
    121. register(
    122.        "python_fu_add_pixels_to_tiles",
    123.        "Add a few pixels to tiles",
    124.        "Add a few pixels to tiles",
    125.        "Ivan Enzhaev (nickname: 8Observer8; email: 8observer8@gmail.com)",
    126.        "Ivan Enzhaev (nickname: 8Observer8; email: 8observer8@gmail.com)",
    127.        "8/18/2015",
    128.        "AddPxToTiles",
    129.        "*",
    130.        [
    131.         (PF_INT, "tile_size", "Tile Size", 16)
    132.        ],
    133.        [],
    134.        python_fu_add_pixels_to_tiles,
    135.        menu="<Image>/Filters/Map",
    136. )
    137.  
    138. main()

    This is the result:
     

    Attached Files:

  12. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    I want to show you the solution again. Maybe you know a better solution.

    The problem (see on nose of bird):


    I solved this problem by this script and by my script.

    The solution is a new spritesheet:

     

    Attached Files:

    Last edited: Sep 14, 2015
  13. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Just so you know there is a fix for the problem you are having that is readily available inside Unity without additional software.
    blizzy gave you the answer (padding) to the issue. The fix to this problem is shown in the 2D section of the learning material.