Author Topic: Couple of questions about sprite scripting  (Read 7380 times)

Dai Tou Zai

  • Posts: 99
  • Definitely Not Blitzcrank
    • View Profile
Couple of questions about sprite scripting
« on: October 11, 2014, 09:48:16 PM »
So im trying to add a couple of custom sprites to my map and im editing the script and i cant figure out some of these things

<texture>doodads/Tree12.gif</texture> (Can gif's be used?)
<origin>48 72</origin> (What is origin used for?)
      
No i'm not blitzcrank, stop asking me.

ChrisN

  • Posts: 44
  • Crackshell Game artist
    • View Profile
    • Portfolio
Re: Couple of questions about sprite scripting
« Reply #1 on: October 11, 2014, 11:15:47 PM »
The editor is not made for gifs to be used. The editor will just crash if you point on a gif file through the xml's. (I tested it out)

----------------------

Press F1 in the editor to see collisions and origins.

The origin is the pivot point of any sprite. It determines where the collision starts and what is above or below if the objects are in the same layer.



As you see in the picture, objects that are above a origin will rendered as behind it.

I have marked with blue where the origin point is on a few creatures. As you can see we recommend placing the origin in the middle of characters while environments is varies a lot more mostly to make sure the players or objects does not appear infront weird on any object.

Hope that answers your questions! :)

Dai Tou Zai

  • Posts: 99
  • Definitely Not Blitzcrank
    • View Profile
Re: Couple of questions about sprite scripting
« Reply #2 on: October 12, 2014, 12:25:58 AM »
Thank you, now i just need to figure out how to do collision :) do you know if there's a tutorial for this stuff, i cant seem to find one and id like to figure out how to do dimensions as well kinda confused about the 0 0 0 0
« Last Edit: October 12, 2014, 12:41:07 AM by Dai Tou Zai »
No i'm not blitzcrank, stop asking me.

Kashlavor

  • Posts: 79
  • Spike Dodger.
    • View Profile
Re: Couple of questions about sprite scripting
« Reply #3 on: October 12, 2014, 01:52:55 AM »
Lets take a look at the h_16_fence.xml

Code: [Select]
<collision shoot-through="true">
<polygon>
<point>0 8</point>
<point>0 -4</point>
<point>32 -4</point>
<point>32 8</point>
</polygon>
</collision>

If you go into the editor and turn on "Show Physics" those little green boxes are the solid parts of an object, just like in the picture up above.  The easiest way to make them is to copy-paste an existing similar item and then just mess with the numbers a bit.  Lets look at what they mean.

shoot-through="true" should have fairly apparent implications, letting you make some objects permeable to projectiles or not, remember we pulled this one off the fence xml.  The next bit takes a bit more explaining.

A polygon is just a shape made up of straight lines and corners, and the points between the two <polygon> tags is the list of points which makes up that bounding shape (in this case a rectangle, since we have 4 points arranged such). 



Feel free to change around the numbers to get a better idea of what these points do, but I'll try to explain.  The first point, <point>0 8</point>, is the bottom left corner.  The first number there is how far that corner is to the right of the origin (remember the origin is that little red bit), so in this case it directly lines up with it.  The next number, 8, is how far below (down!) it is from the origin.  So the first point is just 8 units directly under the origin.

The next point, <point>0 -4</point>, is the top-left one, since its just 4 units above the origin (since the 4 is negative).  The next two points form the top-right and bottom-right respectively, and then it always connects the shape back to the first point.  Thats how the shape is defined and thats what makes it in to a solid object in Hammerwatch.  So in order to make your own doodad you have to set up those numbers so that the shapes lines up with your graphic.

Don't forget to Reload Assets (Ctrl-R) after you make changes to an xml, and always remember that you have to save those changes for them to matter.  Good luck.

---

Oh and here's an example of a circle collider.

Code: [Select]
<collision static="true">
<circle offset="0 0" radius="8" />
</collision>

Good luck figuring it out.  Remember your two best tools are:
  • Guessing and seeing what happens
  • Copying and pasting

I believe some sources refer to this as "an exercise left to the reader" lol
« Last Edit: October 12, 2014, 01:55:52 AM by Kashlavor »
Starting work on the Lair of the Archnecromantrix, a Hammerwatch campaign!

Dai Tou Zai

  • Posts: 99
  • Definitely Not Blitzcrank
    • View Profile
Re: Couple of questions about sprite scripting
« Reply #4 on: October 12, 2014, 02:10:18 AM »
Oh i get it now, thanks alot guys :)
No i'm not blitzcrank, stop asking me.

Phantom

  • Posts: 63
  • Dungeoneer
    • View Profile
Re: Couple of questions about sprite scripting
« Reply #5 on: October 12, 2014, 02:50:42 AM »
Hammersprite can also help generate some of it for you and you can modify any other things you need from that point.

Dai Tou Zai

  • Posts: 99
  • Definitely Not Blitzcrank
    • View Profile
Re: Couple of questions about sprite scripting
« Reply #6 on: October 12, 2014, 03:12:26 AM »
Hammersprite can also help generate some of it for you and you can modify any other things you need from that point.
I actually tried that phantom, cant say it worked for me keep getting this error.


Code: [Select]
<doodad ao="false"> defaultlayer="20"
<sprite scale="16">
<texture>trees/T1.png</texture>
<origin>32 63</origin>
<frame>0 0 63 66</frame>
</sprite>
<collision static="true" shoot-through="false">
<polygon>
<point>-5 2</point>
<point>2 0</point>
<point>5 1</point>
<point>6 0</point>
<point>4 -3</point>
<point>7 -6</point>
<point>3 -11</point>
<point>-5 -12</point>
<point>-4 -7</point>
<point>-7 -6</point>
<point>-5 -3</point>
<point>-7 1</point>
</polygon>
</collision>
</doodad>

not really sure what i'm doing wrong.

EDIT - I fixed it but now i have a new problem texture size should be the power of twos? what the hell does that even mean
« Last Edit: October 12, 2014, 03:16:56 AM by Dai Tou Zai »
No i'm not blitzcrank, stop asking me.

Phantom

  • Posts: 63
  • Dungeoneer
    • View Profile
Re: Couple of questions about sprite scripting
« Reply #7 on: October 12, 2014, 03:23:43 AM »
power 2s are

2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, etc

Your png file width and height pixel size should be of those dimensions.

Kashlavor

  • Posts: 79
  • Spike Dodger.
    • View Profile
Re: Couple of questions about sprite scripting
« Reply #8 on: October 12, 2014, 03:31:04 AM »
All hail the mighty power of 2, the avatar of binary made manifest.
Starting work on the Lair of the Archnecromantrix, a Hammerwatch campaign!

Dai Tou Zai

  • Posts: 99
  • Definitely Not Blitzcrank
    • View Profile
Re: Couple of questions about sprite scripting
« Reply #9 on: October 12, 2014, 03:33:24 AM »
power 2s are

2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, etc

Your png file width and height pixel size should be of those dimensions.
Oh okay so i just have to resize them

Not a big deal tbh i mean the editor still runs good and now i have these beautiful trees!



Golden sun graphics work perfectly with hammerwatch because they use the exact same sizes for the doodad tiles (Except for trees obv) and they're of the same quality, probably wont use the ghost trees.

eh ill do shading later
« Last Edit: October 12, 2014, 03:35:41 AM by Dai Tou Zai »
No i'm not blitzcrank, stop asking me.

Phantom

  • Posts: 63
  • Dungeoneer
    • View Profile
Re: Couple of questions about sprite scripting
« Reply #10 on: October 12, 2014, 03:53:06 AM »
Oh man, lovely trees, keep them coming.

Dai Tou Zai

  • Posts: 99
  • Definitely Not Blitzcrank
    • View Profile
Re: Couple of questions about sprite scripting
« Reply #11 on: October 12, 2014, 04:24:07 AM »
Oh man, lovely trees, keep them coming.
not going to do all the golden sun graphics but ill def send you them when i finish editing everything
No i'm not blitzcrank, stop asking me.

Dai Tou Zai

  • Posts: 99
  • Definitely Not Blitzcrank
    • View Profile
Re: Couple of questions about sprite scripting
« Reply #12 on: October 13, 2014, 05:29:41 AM »
I needa stop working on my world 3 and just complete my world 2 ;-;

No i'm not blitzcrank, stop asking me.

Hipshot

  • Developer
  • Posts: 453
  • Level Designer
    • View Profile
Re: Couple of questions about sprite scripting
« Reply #13 on: October 13, 2014, 03:11:38 PM »
Is this world 3?

Dai Tou Zai

  • Posts: 99
  • Definitely Not Blitzcrank
    • View Profile
Re: Couple of questions about sprite scripting
« Reply #14 on: October 13, 2014, 04:01:32 PM »
Is this world 3?
yeah, planning on having a city with like a couple of sidequests or you can just say f it and go to the castle to continue the main storyline.
No i'm not blitzcrank, stop asking me.