collinhover / impactplusplus

Impact++ is a collection of additions to ImpactJS with full featured physics, dynamic lighting, UI, abilities, and more.
http://collinhover.github.com/impactplusplus
MIT License
276 stars 59 forks source link

Basic examples on how to use impact++ #123

Open Pattentrick opened 10 years ago

Pattentrick commented 10 years ago

Hi @ everyone who is interested in ++,

@collinhover and I just had a small discussion about how ++ lacks some kind of basic examples for certain features. I just finished my first game with ++ a while ago, and although I felt in love with ++, I also had some problems figuring out how to exactly use it.

Yes there are the detailed docs, but they are more a reference to how the methods behind these features are working. And yes, there is the awesome SUPERCOLLIDER demo, but even @collinhover stated, that he realized that the demo is to big and that it is a confusing example for devs that have not used ++ before.

So the idea now is, to add examples on how to use some single features of ++ on the main page of the project, as well as in the GitHub readme. So ++ gets more accessible for new devs.

Here are some topics that we think, are worth explaining first:

But this is open to suggestions! So if anyone out there thinks, that something deserves some specific explanation for beginners, please post your suggestion here.

Also I pretty much volunteered myself on doing these examples, since I came up with this topic. But I would be more than happy, if another ++ dev is willing to add some examples on his favourite ++ feature as well.

@collinhover I am not sure how to exactly write an example in terms of length and style. So I thought I just go for it, and post it here, so we could discuss about that in public. Like this we could maybe develop some kind of “guideline”, in case some other devs want to participate in this.

Because I had some major trouble with pathfinding as beginner, I think I should start with that first!

Falconerd commented 10 years ago

@Pattentrick My first thought was to swap the animation sheets as well, I created a function to mimic the way that impact++ stores the anims. It worked, but then as soon as I transitioned to a new level, it threw a cannot call property of undefined errror. Unfortunately, I don't have that code anymore which is not too helpful. Thanks for that link to #148, I'll take a look again in the morning with a fresh mind and see what I can find. I'll post a solution if I find one :)

collinhover commented 10 years ago

@Archadian you can use multiple animation sheets, but you should define all the animations on initialization using the animSettings. You'll need to edit the automatic adding of animations to account for the animSheet property of the animation options. Then, in game, just set the animation to the name of the action based on the character state. Ex: move animation vs moveSwordShield animation vs moveAxe animation.

Look at vicman4's reply here for more info on this: http://impactjs.com/forums/code/impact-library-75-additions/page/5

Falconerd commented 10 years ago

@collinhover Thanks for your reply. That certainly helped and I have some version working. There are multiple ways to do this, but I've chosen to just use a mode property. So, I've followed the example that vicman4 wrote and updated the addAnim function and animSettings property and then added this to each instance of getDirectionalAnimName in updateCurrentAnim.

Example: this.currentAnim = anims[this.getDirectionalAnimName("move" + this.mode)]; which returns the current animation name as moveBlueX.

Thanks for your help @collinhover and @Pattentrick.

Pattentrick commented 10 years ago

Thanks for clearing this up @collinhover and thanks for giving an example on how you implement that in your game @Archadian! That knowledge will be highly useful for me in the future, since it's just a matter of time, until i get to a point where i need multiple animation sheets too.