C
C
Chvalov2016-04-05 00:34:56
2D
Chvalov, 2016-04-05 00:34:56

How to find out the necessary pieces of sprites for a given text?

There are sprites and a text document for them, in which the areas of the sprite are indicated:

grid_size 40 40
  opaque

//==============================================================================
  use_surface sprites/tile/stone1.png	//Путь к картинке

  sprite wall_stoneA_00 { grid 0 0 gsize 2 2 }
  sprite wall_stoneA_01 { grid 2 0 gsize 2 2 }
  sprite wall_stoneA_02 { grid 0 3 gsize 1 2 }
  sprite wall_stoneA_05 { grid 0 2 gsize 2 1 }
  sprite wall_stoneA_03 { grid 1 3 solid 1 }
  sprite wall_stoneA_04 { grid 1 4 }
  sprite wall_stoneA_10 { grid 2 2 }
  
  sprite wall_stoneA_11 { grid 3 2 }
  sprite wall_stoneA_12 { grid 2 3 }
  sprite wall_stoneA_13 { grid 3 3 }
  sprite wall_stoneA_14 { grid 2 4 transparent }
  sprite wall_stoneA_15 { grid 3 4 transparent }

//==============================================================================
  use_surface sprites/tile/stone2.png

  sprite zabradli { rect 120 120 40 20 pivot 0 -20 transparent }
  sprite wall_stoneA_06 { grid 1 2 }
  sprite wall_stoneA_07 { grid 1 1 }
  sprite wall_stoneA_08 { grid 2 2 }
  sprite wall_stoneA_09 { grid 2 1 }

  sprite columnA_top    { grid 3 0 transparent }
  sprite columnA_middle { grid 3 1 transparent }
  sprite columnA_bottom { grid 3 2 transparent }

  sprite wall_arc_01 { grid 0 0 transparent }
  sprite wall_arc_02 { grid 1 0 transparent }
  sprite wall_arc_03 { grid 2 0 transparent }
  sprite wall_arc_chain_01 { grid 0 1 gsize 1 1 transparent }

  sprite wall_half_01 { rect 0 0 40 20 pivot 0 0 }
  sprite wall_half_02 { rect 20 80 20 40 pivot -20 0 }
  sprite wall_half_03 { rect 20 80 20 40 pivot 0 0 }
  sprite wall_half_04 { rect 40 100 20 20 pivot -20 0 }
  sprite wall_half_05 { rect 40 100 20 20 pivot 0 0 }

  sprite photo1 { rect 0 80 6 6 transparent in_editor 0 }	// Для анимация
  sprite photo0 { rect 0 86 6 6 transparent in_editor 0 }	// Для анимация
  anim   photo  { time_step 100 skey photo0 skey photo1 send }	//Анимация из двух верхних картинок

  sprite wall_noidea_10 { grid 0 4 transparent }
  sprite wall_noidea_11 { grid 1 4 transparent }
  sprite wall_noidea_12 { grid 2 4 transparent }
  sprite wall_noidea_13 { grid 3 4 transparent }

//==============================================================================

How convenient is it to find out the area of ​​the sprite I need, it is desirable to somehow automate this process, since there are more than 40 such files and they are all painfully long (
? rect 20 80 20 40cutting out 20x40px, but with pivot I didn’t quite understand what it is responsible for?
And maybe someone has seen a similar structure for describing sprites before, in what program were they assigned areas?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Lerg, 2016-04-05
@Lerg

Most of all it looks like something custom for PyGame.
You can write a simple script in Lua or the same Python to convert these files to, say, JSON.

A
angru, 2016-04-05
@angru

pivot is most likely responsible for the pivot point. those. if the sprite size is 40x40, and pivot = (20, 20), then the sprite will rotate around its center, and if (0, 0) then around the upper/lower left (depending on which corner of the screen the countdown starts) corner.
although judging by the coordinates (-20, 0) - it can also wash some kind of constant offset. for example, you place the sprite at (30, 30), but with this pivot it will be at (10, 30).
It's hard to say exactly, you yourself need to play around with the offsets, try changing something in the file and see what changes in the game.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question