For your information: I have made the parrot image PO2, and also renamed Timer.lua to SimpleTimer.lua so certain crap... microsoft-produced operative systems don't complain.
Thanks for helping me make PÄSSION suck less.
PÄSSION: object-oriented LÖVE
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: PÄSSION: object-oriented LÖVE
When I write def I mean function.
-
- Party member
- Posts: 215
- Joined: Sun Jan 18, 2009 8:03 pm
Re: PÄSSION: object-oriented LÖVE
Hi, these were the changes I did to Pässion when playing around a bit with GUIs. Most of them pretty unimportant.
passion.lua
I did not like how Button operated since e.g. buttons covered by other GUI objects could still be triggered. To fix this, I created a MouseHandler class that considers objects in reverse draw order and invokes appropriate callbacks, Beholder triggers and state changes (if wanted). It is also faster since it only has to go through the stack once per update (plus room for possible optimizations) instead of doing the check for every button and frame. To facilitate this, actors or panels have a method for whether they accept mouse input or not, as well as a method that checks if a point on the screen is over the object.
Not core material perhaps, but I created a general GUI parent class that includes common functionality such as helpers for expansion/contraction (e.g. mouse over for details), (window-like) dragging, fade-in/out affecting children, fade-out&destroy, and having all of the button&various on-callbacks "available" by default.
Camera I mentioned before (bug fixes though, e.g. forgot to update the inversion matrix I think it was with my origin change)
Also a small change. I didn't consider the text in labels (and subs. buttons) particularly centered vertically so I botched the default y a bit.
Still not a lot of changes so it's a very stable library.
passion.lua
- drawWithCameras must unset camera after drawing because it does not pop parents otherwise which e.g. makes three levels of GUI components render improperly.
- added a Beholder update trigger to the update method. (I saw a reference to "passion.update" so perhaps it existed already?)
- added Beholder trigger variants of keypressed, mousepressed etc where the button/key is not appended to the trigger event string. This is what you want for some general handlers.
- Moved out some the functionality of destroy() to a separate destroyChildren() method. It seemed like something natural that should be in Actor.
- Changed setParent so that it also adds the object as a child of the parent unless already parent or an optional addFlag argument is false (also means changing the getterSetter of parent to just getter).
- Added some simple methods on ancestor trees - ascends (is arg an ancestor of self?), descends, applyToDescenders/Descendents, applyToAncestors. Preferably these should come in two kinds or take an argument for whether or not the object itself should be included (strict vs weak ascendor/descendor). These helper functions were quite common for some GUI components.
- Changed _getOrCreateCallback so that it does not throw an Exception even if the classCallbacks table does not have methods field, which e.g. happens if the lines before are executed. Sorry about this one, I do not remember exactly when this can happen.
- setParent calling super.setParent instead of setting it directly with self.parent=.
I did not like how Button operated since e.g. buttons covered by other GUI objects could still be triggered. To fix this, I created a MouseHandler class that considers objects in reverse draw order and invokes appropriate callbacks, Beholder triggers and state changes (if wanted). It is also faster since it only has to go through the stack once per update (plus room for possible optimizations) instead of doing the check for every button and frame. To facilitate this, actors or panels have a method for whether they accept mouse input or not, as well as a method that checks if a point on the screen is over the object.
Not core material perhaps, but I created a general GUI parent class that includes common functionality such as helpers for expansion/contraction (e.g. mouse over for details), (window-like) dragging, fade-in/out affecting children, fade-out&destroy, and having all of the button&various on-callbacks "available" by default.
Camera I mentioned before (bug fixes though, e.g. forgot to update the inversion matrix I think it was with my origin change)
Also a small change. I didn't consider the text in labels (and subs. buttons) particularly centered vertically so I botched the default y a bit.
Still not a lot of changes so it's a very stable library.
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: PÄSSION: object-oriented LÖVE
Whoa.
Can you upload it somewhere? Pleasy please?
The ideal place would be github - fork PÄSSION there, clone your repo locally, overwrite with your changes, and pull your changes up.
If that is too complicated, just upload a zip here.
I'm sure the Callbacks module has bugs on it. Could not put my finger on what was going wrong. That's why I went the TDD way.
This is going to be interesting. I only have one week to browse it up, and then I'll be AFK for a month (summer holidays far, far away). I'd love to give your code a look if I have the chance.
Can you upload it somewhere? Pleasy please?
The ideal place would be github - fork PÄSSION there, clone your repo locally, overwrite with your changes, and pull your changes up.
If that is too complicated, just upload a zip here.
I'm sure the Callbacks module has bugs on it. Could not put my finger on what was going wrong. That's why I went the TDD way.
This is going to be interesting. I only have one week to browse it up, and then I'll be AFK for a month (summer holidays far, far away). I'd love to give your code a look if I have the chance.
When I write def I mean function.
Re: PÄSSION: object-oriented LÖVE
So much writing.
Hey, Kikito, the GUI library seems a bit hobbled. What do you think if I advanced it a bit, including scripted styling, text boxes, windows, stuff? I could always make it a separate library, but having it as a PASSION module would be pretty awesome in my opinion.
Thanks for this awesome library.
Hey, Kikito, the GUI library seems a bit hobbled. What do you think if I advanced it a bit, including scripted styling, text boxes, windows, stuff? I could always make it a separate library, but having it as a PASSION module would be pretty awesome in my opinion.
Thanks for this awesome library.
Good bye.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: PÄSSION: object-oriented LÖVE
Hi Luiji,
I'm glad you liked it.
Development has not stopped - I've simply concentrated on middleclass and mindstate lately. I want to make sure the building I was creating had strong enough foundations.
If you are interested on adding stuff to PÄSSION, I suggest creating a fork on github. You can then add features there, and send them to me in the form of pull requests (please, one pull request by feature; don't send a gigantic pull request with 100 new things).
I must warn you that I'm very picky though - I only take top-notch quality from contributions; I've enough with fighting my own quirky ugly code. The worst thing that could happen is that I don't accept any of your pulls, and in that case you would still have a visible clone out there on github. Which is kind of nice anyway.
Also, let me remind you that I will be on holidays starting next monday, for 1 month aprox. If I seem unresponsive, it's probably that the great firewall of China is blocking the communications.
I'm glad you liked it.
Development has not stopped - I've simply concentrated on middleclass and mindstate lately. I want to make sure the building I was creating had strong enough foundations.
If you are interested on adding stuff to PÄSSION, I suggest creating a fork on github. You can then add features there, and send them to me in the form of pull requests (please, one pull request by feature; don't send a gigantic pull request with 100 new things).
I must warn you that I'm very picky though - I only take top-notch quality from contributions; I've enough with fighting my own quirky ugly code. The worst thing that could happen is that I don't accept any of your pulls, and in that case you would still have a visible clone out there on github. Which is kind of nice anyway.
Also, let me remind you that I will be on holidays starting next monday, for 1 month aprox. If I seem unresponsive, it's probably that the great firewall of China is blocking the communications.
When I write def I mean function.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: PÄSSION: object-oriented LÖVE
I find programming class-and-method related stuff is very gratifying, but also extremely complicated at times! So many things to take into account!
I would have liked to finish the Callbacks arc on MiddleClass and PÄSSION before going on holidays, but it is not going to be possible. I apologize. My flight takes off in 9 hours and I haven't slept yet.
I've committed my latest changes to MiddleClass - I'm near to what I wanted, but still not there. All the code there works, and it could be used on PÄSSION, except the Callbacks module, which basically just fails miserably.
Very briefly, the Callbacks module is supposed to allow you to "hook" actions onto methods. This way, you can do very fancy things with modules and class modification. However, if is complex stuff.
The Callbacks module is the only thing preventing me to continue on PÄSSION. Once it is correctly implemented and it passes the tests, my plans are to replace the "oop" directory in the PÄSSION dir with a git submodule.
I'm going on holidays now, and won't be around until mid-september. I could say "I'll try to connect from some ciber-cafe when I'm in China" but I don't think I'll do, so I will not say it. You might try sending me a PM while I'm away. I might be more lucky answering via email, with my phone.
Anyway, see you guys!
I would have liked to finish the Callbacks arc on MiddleClass and PÄSSION before going on holidays, but it is not going to be possible. I apologize. My flight takes off in 9 hours and I haven't slept yet.
I've committed my latest changes to MiddleClass - I'm near to what I wanted, but still not there. All the code there works, and it could be used on PÄSSION, except the Callbacks module, which basically just fails miserably.
Very briefly, the Callbacks module is supposed to allow you to "hook" actions onto methods. This way, you can do very fancy things with modules and class modification. However, if is complex stuff.
The Callbacks module is the only thing preventing me to continue on PÄSSION. Once it is correctly implemented and it passes the tests, my plans are to replace the "oop" directory in the PÄSSION dir with a git submodule.
I'm going on holidays now, and won't be around until mid-september. I could say "I'll try to connect from some ciber-cafe when I'm in China" but I don't think I'll do, so I will not say it. You might try sending me a PM while I'm away. I might be more lucky answering via email, with my phone.
Anyway, see you guys!
When I write def I mean function.
- Felipe Budinich
- Citizen
- Posts: 67
- Joined: Thu Jul 29, 2010 1:36 pm
Re: PÄSSION: object-oriented LÖVE
Good luck in your trip! Have a blast!
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: PÄSSION: object-oriented LÖVE
Ni-haou!
I just wanted to say I'm back from holidays.
Jetlagged as hell. My home needs a clean up.
Catching up with all the news (love 0.7!).
But, yeah, I'm back.
I just wanted to say I'm back from holidays.
Jetlagged as hell. My home needs a clean up.
Catching up with all the news (love 0.7!).
But, yeah, I'm back.
When I write def I mean function.
Re: PÄSSION: object-oriented LÖVE
Hi all.
I've hit some problems with making PÄSSION work and want to share some thought about it.
I've used Windows, love 0.6.2, latest versions of PÄSSION, middleclass-extras and middleclass.
1. First of all paths ./passion/timer/timer.lua and ./passion/timer/Timer.lua are different on linux but the same on windows, so I had to merge that files in one.
2. There is great manual on how to set up PÄSSION but there is no reference to middleclass in it. And there is no require for it in any samples for some reason. It's really confusing.
3. Also seems like PÄSSION not working with middleclass 1.2. Actually I can't figure out whats wrong with it. But I'm sure that it's not calling initialize methood for subclass.
Some variations around "the parrot" example:
4. Why there is no string in main.lua in any existing sample? Is there other way to require middleclass?
P.S. I'm new to this so please don't blame me too much if I've wrote something stupid.
I've hit some problems with making PÄSSION work and want to share some thought about it.
I've used Windows, love 0.6.2, latest versions of PÄSSION, middleclass-extras and middleclass.
1. First of all paths ./passion/timer/timer.lua and ./passion/timer/Timer.lua are different on linux but the same on windows, so I had to merge that files in one.
2. There is great manual on how to set up PÄSSION but there is no reference to middleclass in it. And there is no require for it in any samples for some reason. It's really confusing.
3. Also seems like PÄSSION not working with middleclass 1.2. Actually I can't figure out whats wrong with it. But I'm sure that it's not calling initialize methood for subclass.
Some variations around "the parrot" example:
Code: Select all
require('middleclass.init')
require('passion.init')
-- assumes there's an image/parrot.png file
local image = passion.graphics.getImage('images/parrot.png')
Parrot = class('Parrot', passion.Actor)
function Parrot:initialize(image)
error('never hit here because no call to Parrot:initialize!')
super.initialize(self)
self:setPosition(100,100)
self.image = image
end
function Parrot:update(dt)
local x,y = self:getPosition()
self:setPosition(x+dt,y) -- got shot in foot here
end
function Parrot:draw()
love.graphics.draw(self.image, self:getPosition())
end
parrot = Parrot:new(image)
Code: Select all
require('middleclass.init')
P.S. I'm new to this so please don't blame me too much if I've wrote something stupid.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: PÄSSION: object-oriented LÖVE
You are not stupid.
I'm the stupid.
I've been doing lots of changes to middleclass lately; for example, middleclass has been split into middleclass and middleclass-extras. PÄSSION isn't up-to-date with those changes yet.
I assumed it would take me a couple weeks to fix everything, but it's taking much longer.
I'm hoping that I'll have some free time during Christmas for fixing Pässion. In the meantime, the current branch is a bit of a mess, I don't recommend using it. Sorry.
I'm the stupid.
I've been doing lots of changes to middleclass lately; for example, middleclass has been split into middleclass and middleclass-extras. PÄSSION isn't up-to-date with those changes yet.
I assumed it would take me a couple weeks to fix everything, but it's taking much longer.
I'm hoping that I'll have some free time during Christmas for fixing Pässion. In the meantime, the current branch is a bit of a mess, I don't recommend using it. Sorry.
When I write def I mean function.
Who is online
Users browsing this forum: No registered users and 8 guests