*Thumbs through the source.*kikito wrote:The latest sourcecode can be downloaded from the new google code page.
Holy... I think I'm gonna need some more coffee...
*Thumbs through the source.*kikito wrote:The latest sourcecode can be downloaded from the new google code page.
Code: Select all
small = passion:getFont(10) -- loads a default font with size=10
ttf = passion:getFont('fonts/comicsans.ttf', 12) -- loads a ttf font with a size from a file. Please don't use Comic Sans
numbers = passion:getFont('images/numbers.png', '1234567890') -- loads a font from a image
monkey = passion:getImage('images/monkey.png') -- loads an image
honk = passion:getSound('sounds/honk.wav') -- loads a sound
tune = passion:getMusic('musics/juantanamera.wav') -- loads a music
Code: Select all
Monkey = passion.Actor:subclass('Monkey', {hasImage=true})
Monkey:load({
fonts = { small = 10, -- loads a default font
ttf = {'fonts/comicsans.ttf', 12},
numbers = {'images/numbers.png', '1234567890'}
},
images = { monkey = 'images/monkey.png' },
sounds = { honk = 'sounds/honk.wav' },
musics = { tune = 'musics/juantanamera.wav' }
})
-- I now can use the resources by doing Monkey.collection.resource. For example:
love.graphics.setFont(Monkey.fonts.ttf)
love.graphics.draw(Monkey.images.monkey, x,y)
Code: Select all
function love.run()
return passion:run()
end
That seems like a rather large difference to me.kikito wrote:Unfortunately today's demo doesn't look very different from the previous one, since most changes have happened "under the hood".
The most visible difference is that the demo no longer segfaults.
Thanks! I'm trying hard to make it easy?osuf oboys wrote:Really useful, especially MindState
Not sure what you mean by "stacks of states". You mean states with states inside? I call those "stateful states" . It is in theory possible. The trick is that addState takes a second parameter that is the superclass of the state you are creating. I haven't got myself to fully test that part, though. Also, the syntax might not be clean for those cases.osuf oboys wrote:Stacks of states and the ability to "super-call" a lower state would be nice btw.
Code: Select all
require('MindState.lua')
Theory = class('Theory', StatefulObject)
function Theory:foo() print('foo') end
local StatefulState = Theory:addState('StatefulState', StatefulObject) -- <-- the magic happens on this line
function StatefulState:foo() print('bar') end
local InternalState = StatefulState:addState('InternalState')
function InternalState:foo() print('baz') end
theory = Theory:new()
theory:foo() -- foo
theory:gotoState('StatefulState')
theory:foo() -- bar
theory.currentState:gotoState('InternalState')
theory:foo() -- baz
I understand your concerns. However, I couldn't see any way of providing a simple interface for multi-words, while the mono-word interface is quite streamlined. If you or anyone else can show me a way to handle them that I like, I'll include them, sure. In the meantime, if someone needs multi-word stuff, they can extend passion (maybe add a passion:getWorld2() or something) and create a hasBody2 on actor.osuf oboys wrote:Not sure I like that there is a single world by default - some games will certainly want to use more.
Indeed. I'm just too busy to update that code at the moment. The PÄSSION version on the svn is already fixed, though.osuf oboys wrote:The example code needs to be updated to 6.0.1
I'll check that out. However, the "frozen" part is probably going to go. I'll add a Frozen state to actor! (and redefine update() to do nothing there! how cool is that?)osuf oboys wrote:'updateUnlessFrozen' or something in the Actor class should take and send the dt parameter - or else no actor will get their dt's.
Yes, I know what you mean. You might not like my responses very much but - you rely on actors. You can do two things:osuf oboys wrote:Something that that is not clear to me is how one gets callbacks in a Game class, without having to rely on actors or GUI elements
Code: Select all
keyHandler = passion.Actor:new()
keyHandler.onkeypress = function() ... end
I've thought about something like this, but for different reasons: efficiency. When the key 'space'(for example) is pressed, onkeypress is invoked on every actor, even if they "do not care" about space, and only "care" about "enter". But that's something I'll address if I run into performance issues, not before.osuf oboys wrote:Perhaps just a general register() function which allows callbacks to be sent to an object; be it a Game, non-Actor class, or otherwise?
I'm sorry to hear that. I'll try to make it more attractive No, seriously. If you don't like a feature, you can just deactivate it. For example, you can define love.onkeypress() so it does other things (register listeners, etc). The rest of PÄSSION will still be available. No hard feelings.osuf oboys wrote:This is a simple solution but I do not like this framework of direct input-model coupling; not even for Actors, as they are now.
Maybe we are conceiving two different types of Game object. On my head, the Game object just says "actors, create!", "actors, destroy!" depending on the status he is - only enterState and exitState callbacks are used, most of the time. He's like a lazy dictator; he doesn't even track the input directly, he has a subdit that does it.osuf oboys wrote:For instance, it is complicated to let the state of the Game influence Actors (is this the "states in states" deal?).
Code: Select all
local BeVeryMean = Director:addState('BeVeryMean')
function BeVeryMean:enterState()
musicPlayer:transitionToCreepyMusic()
Bee:applyToAllActors('growHorns', 13) -- invoke methods on all actors, with parameters
Zombie:applyToAllActors('gotoState', 'nightmarish') -- change the states of actors
Enemy:applyToAllActors('shout') -- all enemies (zombies and bees) will emit a fearsome cry now!
end
Well, on my example it will not matter because all the that aren't supposed to receive callbacks will be destroyed. Game is supposed to be a bastard ( ok, they could also be just frozen and invisible, and stored in a pool, to save creation time. Actor pools is another thing I'm considering doing)osuf oboys wrote:If we bring up the main menu, we do not want callbacks to be sent to the Actors unless Games wants it to be that way.
Thank you. I'll try to give both a look during this weekend. Unfortunately this week and the next one will be particularly difficult for me (Real Life work...). But if I see something that can improve PÄSSION, I'll add it.osuf oboys wrote:Perhaps something more like ËNVY's observer pattern (http://en.wikipedia.org/wiki/Observer_pattern) where Actors are registered as observers to Game and game an observer of love's callbacks?
By all means, keep your criticism coming! I think criticism helps. I enjoyed your comments very much. My apologies to everyone for the überlong post.osuf oboys wrote:Sorry about all the criticism, the framework is really good. Keep it up!
It is.kikito wrote: Thanks! I'm trying hard to make it easy?
statefulObject.pushState("game")kikito wrote: Not sure what you mean by "stacks of states".
What would be a practical application of that over, say, using a single layer of states but multiple such?kikito wrote:You mean states with states inside? I call those "stateful states" . It is in theory possible. The trick is that addState takes a second parameter that is the superclass of the state you are creating.
If you want to keep it out of the way and not provide it as an argument, you can let it be a parameter in PÄSSION (or a Game), currentWorld/newActorsWorld. Not a important feature for now though.However, I couldn't see any way of providing a simple interface for multi-words, while the mono-word interface is quite streamlined.
Nice. Perhaps a bit unrelated but what I find the most intuitive is not for states to have their own set of functions, but rather to overload functions (blanking them to deactivate, e.g.). That way, when the actors are "frozen", they could still be drawn without having to respecify the draw function. Similarly for applying a new state on another (the stacks).I'll check that out. However, the "frozen" part is probably going to go. I'll add a Frozen state to actor! (and redefine update() to do nothing there! how cool is that?)
Could be possible but then you should perhaps make it a class for callbacks (Game, GUI, etc) and another under that for more logic (objects in a game). Not sure 'Actor' is the right name. The first part should probably also be a module (included) rather than a class? This still essentially just becomes the observer pattern and the primary issues are resolved with it.Yes, I know what you mean. You might not like my responses very much but - you rely on actors. You can do two things:
- Make Game a subclass of Actor. Then you can do Game:onkeypress() and handle keys there. Problem with this approach is that you have to be careful not to do funky things with the game object- i.e. passion.Actor:applyToAllActors('destroy') would end the game, when you just wanted to destroy all actors instead.
- Use an invisible actor for keyboard handling. You don't even need to define a class for it - just add an onkeypress function to the instance:
This way your Game is "more inmune" to Actor:applyToAllActors stuff.Code: Select all
keyHandler = passion.Actor:new() keyHandler.onkeypress = function() ... end
That's actually the problem with the Observer pattern, plenty of overhead to send those messages. Your applyToAllActors as it is right now is a special case of this pattern.I've thought about something like this, but for different reasons: efficiency. When the key 'space'(for example) is pressed, onkeypress is invoked on every actor, even if they "do not care" about space, and only "care" about "enter". But that's something I'll address if I run into performance issues, not before.
I can explain how I see it. I agree but only as far as game logic goes. When it comes to input and output, we want to make the interface to come with as little coupling as possible, preferably relying on the Model-View-Controller design. Doing things like checking if a key is pressed in an Actor callback and reacting accordingly is simple in the beginning but that can become pretty obscene, will screw things up with things like AI and networking, and generally preventing a lot of freebies that comes with good design.Maybe we are conceiving two different types of Game object. On my head, the Game object just says "actors, create!", "actors, destroy!" depending on the status he is - only enterState and exitState callbacks are used, most of the time. He's like a lazy dictator; he doesn't even track the input directly, he has a subdit that does it.
keyListener: boss, somebody has pressed esc. We should return to the menu
Game: You are right keyListener. Allright, everyone just DIES now! - except you, keyListener (boum) Now, actors used on the menu, create yourselves. Now, start working! Ok, I'm going back to sleep.
So, the Game just creates and destroys actors, and they do their stuff.
Should there have to be this much work to just bring up a menu though when you already have all of the data prepared?Well, on my example it will not matter because all the that aren't supposed to receive callbacks will be destroyed. Game is supposed to be a bastard ( ok, they could also be just frozen and invisible, and stored in a pool, to save creation time. Actor pools is another thing I'm considering doing)
Oh! That! I remember I saw something like that when I was "looking for inspiration" on UnrealScript. I made a mental note to include it.. and then I forgot. Thanks for remembering it to me!statefulObject.pushState("game")
statefulObject.pushState("menu")
statefulObject.popState()
I'm not entirely sure, I must admit. The whole idea of states is keeping copied code to the minimum possible. But I wanted to be have those advantages inside states too:What would be a practical application of that over, say, using a single layer of states but multiple such?
Code: Select all
-- notation: Class { State { functions or substates } }
Enemy {
Attacking {
f1()..
f2()..
WithWeapon {
f2() -- do more damage
}
}
Running {
}
}
Ninja < Enemy {
Attacking {
WithWeapon {
f2() -- instant kill
}
}
}
Hmm so you mean that methods are searched "through the state stack" before searched on the subclass? That's ... intriguing. Powerful. Dangerous. I like it. If I can't come out with some scenario where this is a bad idea, I'll include that feature.Nice. Perhaps a bit unrelated but what I find the most intuitive is not for states to have their own set of functions, but rather to overload functions (blanking them to deactivate, e.g.). That way, when the actors are "frozen", they could still be drawn without having to respecify the draw function. Similarly for applying a new state on another (the stacks).
I have read the wikipedia link you gave. I still have to study how ËNVY does its thing. I liked what I saw on wikipedia.Could be possible but then you should perhaps make it a class for callbacks (Game, GUI, etc) ... (snip) ... MVC design ... I cannot think of an example where this subordination part would be superior to your states+stack.(snip)
Code: Select all
Should there have to be this much work to just bring up a menu though when you already have all of the data prepared?
Well, as I see, stacks do that.kikito wrote:statefulObject.pushState("game")Code: Select all
-- notation: Class { State { functions or substates } } Enemy { Attacking { f1().. f2().. WithWeapon { f2() -- do more damage } } Running { } }
True, the observer pattern could be taken care of by a different framework. Although, I think for most projects, it would mostly follow a simple pattern that would not at all use the full power - just registering new objects as listeners to some parent object, e.g. a game. Could even be done implicitly. I certainly think for the simplicity principle, you must at least make it possible to register classes in PÄSSION (/include a class) to receive LÖVE callbacks.*BUT* I want something simple and easy to grasp. The thing I like about my current approach is that it is very easy to understand to someone familiar with LÖVE, or learning it. If I'm going to lose that, it must be to something as easy to use as that.
Having to send to all actors that they should be frozen, invisible, and stored in a pool, just to bring up an options menu, certainly seems like an overly complicated solution.Sorry, which work are you referring to? I didn't get that last part.
[/quote]osuf oboys wrote: If we bring up the main menu, we do not want callbacks to be sent to the Actors unless Games wants it to be that way.kikito wrote: Well, on my example it will not matter because all the that aren't supposed to receive callbacks will be destroyed. Game is supposed to be a bastard ( ok, they could also be just frozen and invisible, and stored in a pool, to save creation time. Actor pools is another thing I'm considering doing)
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests