Skip to main content

News

Topic: The Wiki (Read 17898 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • Rahkiin
  • [*][*][*]
Re: The Wiki
Reply #30
Why isn't this topic in 'Site Comments' anyways?

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: The Wiki
Reply #31
Rahkiin, you're right. It does seem to fit better there.

/moved.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • N E O
  • [*][*][*][*][*]
  • Administrator
  • Senior Administrator
Re: The Wiki
Reply #32
Map changing tutorial now exists! It may need a second set of eyes to confirm that it's typo-free, though, especially near the code blocks.

The actual code itself, though, should be fine since I wrote it first in a Sphere project and made sure it worked before copying and pasting. I'm actually going to use that code style for a new version of NTrans, so theoretically it should be WAY easier to update and extend than the original AND should be a bit more future-proof.

The "waypoint map" tutorial will be theory-based, though, so for now I'm still working on the outline.

@Rahkiin - The Developing tutorial, once complete, is meant to be the definitive reference to future compatible engine development; because of that importance I imposed a soft editing restriction on it. Nothing against you personally or your skill, but since you are relatively new to me in the Sphere community at the moment I'd like to see you draft your work on the wiki sandbox first and either myself or another wiki sysop will merge the content (reformatted as needed) into the main article. After a couple of drafts I'm pretty sure I'd give you permission to edit the article directly.

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: The Wiki
Reply #33
N E O: I'm having a hard time following your code in general. It just doesn't read so clean to me. It might be your explanations.

Also, I'd like to show you a cool trick to make this line more stable and read better: http://www.grauw.nl/blog/entry/510
Code: (javascript) [Select]

fade.prototype.init = function(data) {
this.color = 'color' in data?data['color']:CreateColor(255,255,255,255);
};

// becomes:
fade.prototype.init = function(data) {
// if data and data.color exist, use data.color; else use new color
this.color = (data && data.color) || CreateColor(255, 255, 255);
};


Your easing description is kind of bland, and it doesn't help to show that your linear ease really does nothing. Part of Penner's easing functions is so that they do the work for you.

Code: (javascript) [Select]

// bad:
function linear(a) { return a * 1.0; }
var blah = linear(a-lot-of-math-here-which-does-nothing);

// good:
function linear(a, b, t) { return a + b * t; }
var blah = linear(start, end - start, time/total);


Edit: thanks to Jest below I've added parenthesis to clarify the new trick above.
  • Last Edit: March 08, 2014, 06:07:54 am by Radnen
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

Re: The Wiki
Reply #34

Code: (javascript) [Select]

fade.prototype.init = function(data) {
this.color = 'color' in data?data['color']:CreateColor(255,255,255,255);
};

// becomes:
fade.prototype.init = function(data) {
// if data and data.color exist, use data.color; else use new color
this.color = data && data.color || CreateColor(255, 255, 255);
};



If this is going to be a tutorial, more parenthesis would be nice. I still don't always remember the associativity of all operands off the top of my head.

  • Rahkiin
  • [*][*][*]
Re: The Wiki
Reply #35

@Rahkiin - The Developing tutorial, once complete, is meant to be the definitive reference to future compatible engine development; because of that importance I imposed a soft editing restriction on it. Nothing against you personally or your skill, but since you are relatively new to me in the Sphere community at the moment I'd like to see you draft your work on the wiki sandbox first and either myself or another wiki sysop will merge the content (reformatted as needed) into the main article. After a couple of drafts I'm pretty sure I'd give you permission to edit the article directly.


Allright. I actually only wanted to add tables for the file structure :)

  • N E O
  • [*][*][*][*][*]
  • Administrator
  • Senior Administrator
Re: The Wiki
Reply #36
@Radnen:

Re fade.init - I purposefully didn't add much checking (if any) to the tutorial's code for simplicity; my actual personal version has almost every check I can think of, including the basic version of the || trick. I could've also modified the alpha value of the modified fade() function during the declaration of the c variable instead of modifying its alpha after, but again people aren't going to know to do that immediately, and the tutorial's fade code doesn't type-check fade.color so theoretically any object that has red, green, blue, and alpha properties would work. Your || recommendation is probably better JS practice anyways, so I'll use it, but I also chose to show the 4 parameter CreateColor because I want readers to notice that the alpha value of the tint is being set.

Re easing - I want to put a better description, but I was pressed for time; a later edit will expand it. Regarding the long version of easing function prototypes, for simplicity I simply pass the t value (0.0 to 1.0, inclusive) since the effect function only passes a t value to whatever easing function it's given. If it won't add needless complexity to the tutorial a later edit will add a section explaining using proper easing functions.

Re explanations - This is exactly why I want at least two pairs of eyes on every tutorial, so that we can make sure they're as readable as possible. If there are any suggestions, like reorder the pieces or be more/less detailed in X section or reword a thing I'm all ears!


@Rahkiin - That is a good idea, as the file format docs that come with Sphere may be a bit outdated (especially the map and spriteset ones). If they're not documented on the forums for some reason, ask Radnen and Flying Jester for their findings on parsing Sphere formats (especially version inconsistencies) since they've worked with them more recently than I have. Lord English may also have a couple of notes after making some edits to Radnen's Sphere Studio. alpha123's worked with the most recent version of vanilla Sphere, but that may have been quite some time ago. The Web Sphere Utilities repo has my code for parsing the formats but it's all in web-compatible JavaScript. Pick your poison ;)

  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
Re: The Wiki
Reply #37
NEO: regarding your map changing tutorial, it might be an idea to address setting the position of your character, as that is something that someone might want to do and it's not 100% straightforward.

  • N E O
  • [*][*][*][*][*]
  • Administrator
  • Senior Administrator
Re: The Wiki
Reply #38
I left out setting character position in the first draft since there's kind of an implicit assumption that the maps one will use are far enough along that they have the starting point already defined. It is needed, however, if/when a map has multiple entrances/exits so I'll cover that in an "extra advanced techniques" section.

I'm going to work on the explanations right now and hopefully come up with something easier to understand.

  • N E O
  • [*][*][*][*][*]
  • Administrator
  • Senior Administrator
Re: The Wiki
Reply #39
Update to Map Change tutorial! Let me know if it's more readable now and what should be changed if needed.