Wow! I'm going to have to digest all this on separate chunks.
osuf oboys wrote:The functionality of camera is so common that I'd really like to see your reworked version standing on its own without the need of the complete framework. Though I missed some common functionality - centering the screen and scaling to display a certain number of units - and have attached an extension in case you are interested.
It is funny that you mention it, since the Camera system is one of the things I'm less satisfied about. I'll sure give it a look. Thanks for sharing it.
osuf oboys wrote:Mostly because, as with this project, the lack of transparency and documentation makes for a steep learning curve (it's pretty much the only reason I can think of why the majority of projects is not using PÄSSION
). What are your thoughts on this?
Thank you for your kind words. I understand exactly your concerns, and I'm fighting this on several fronts. Your question is a bit philosophical, so my answer will be too (sorry)
- First, there's this "if you build it, they will come" idea. I have hope that if I create a system that is awesome enough, people will use it. I realize that this is not a proper plan. I guess I'm still young and hopeful in some way.
- Then there is my direct attack in the form of a tutorial site. Have you seen it? It's still under development, but it is starting to look cool. I've stopped working on it for a while since I'm doing (again) some re-engineering on the core classes.
- I've got this "do the common bits easy" part. I try hard to make the usual steps as straightforward as possible. This is usually my #1 reason to make a change on a interface
- Then there's the "make things diggable". One should be able to "dig" through the system. Start doing the simple/common things, and then go down at some point. The Actor's getCamera method is an example of that. You go there and you see that there's also a "getCameras"... and that's how you discover that the system supports multicamera stuff (i.e. for split screens or minimaps).
- And then I try to follow the usual DRY, KISS, YAGNI principles that I've learnt from rails. The idea behind this is to make code that is not only "useful" but also "beautiful". I realize that in some cases I've had more luck than in others on this. My Camera code, for example, needs some serious beautification.
osuf oboys wrote:1. to remove a state not necessarily at the top of a stack
popState can do that. Invoked with no params, it will pop the top state, but if invoked with a state name, it will remove that state from the stack:
Code: Select all
myInstance:popState('MyStateName')
osuf oboys wrote:2. to move a state in the stack to the top
I think it is not common enough to be included on Mainstream Middleclass, but you can implement it yourself like this:
Code: Select all
function MindState:moveStateToTop(statename)
self:popState(statename) -- this does nothing if the state isn't on the stack, so it is safe
self:pushState(statename)
end
Notice that callbacks will be fired - but I'll assume that is desired.
osuf oboys wrote:3. for a function to access the version it is overwriting, and its associated state.
There is already one variable that gives you access to the "stateless" version of all methods: self.class . You can use it similarly to how you would use "super":
Code: Select all
function MyState:foo() -- foo is redefined on MyState
return self.class.foo(self) -- non-stateful version of foo (assuming that it exists)
end
osuf oboys wrote:How would you with states have a puppy limp when it is low on health but return to normal once it has filled up - while the state stack is used for a number of other purposes as well?
If we have a limp that has no full health, I would simply not use a state. Instead, I would do the plain old if(health < 100) then color=red end . It just takes less space than creating a whole state just for that.
Also, states are kind-of-binary things: you are on them or you are not. Health is more like a range-like thing. The "low health" condition is better expressed by a number than by a state.
osuf oboys wrote:How would you have the regular looks (which may be a product of states) be drawn together with a skull to indicate that an actor is poisoned?
If I had things like "Poisoned", "Dazzled" etc, I think I would not use States for this neither; they overlap so much that I would not probably be able to add one without having to modify the rest. But this is just a first thought.
osuf oboys wrote:If the walking behaviour may be the product of a number of status states but we only wish to draw one of them - how would you let the state with the "highest priority" take control instead of the one added last?
The only way I can think of for making "behaviours that are a product of different stacked states" is by having it "condensed" on a single method, with "holes" on it. The holes would be implemented differently depending on the state.
Code: Select all
function Player:draw()
if(self:hasSkull()) then
...
else
...
end
The Poisoned and Dead states will return true on hasSkull, while the rest would return false, and so on.
I hope I answered everything. Will review the Camera.lua file as soon as I can. Good night!