GPWiki.org
GPWiki.org
It is currently Sun May 19, 2013 9:06 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sun Aug 26, 2012 1:54 pm 
Grand Optimizer
User avatar

Joined: Mon Jan 17, 2005 6:01 pm
Posts: 352
Location: Canada
I'm finding lately that when im doing things that involve loops, I'm having to place little control variables way up in the game's own class variable section just to get the functionality I want out of the loop. I know that's kind of vague, I'l try to explain.

As an example, I have a loop that checks for mouse input on all the active windows on the screen. You can drag them around and such. I originally had it set up in such a way that when you clicked(and held) on a window, Window.Active would be set to true, which allowed you to drag the window around. No problem, until I had an array of windows that I was performing my input algorithm on. With Window.Active, always the first element of the array kept 'hogging' the focus and I couldn't figure out why. So what I had to do is place a variable way outside the algorithm, all the way up in the game's class variables which kept track of which window is active. It now works fine, but doing it somehow feels unclean and sloppy?

I'm finding im doing that sortof thing quite a bit and I'd prefer to avoid it. Has anyone else experienced this? Any suggestions or is what I'm doing normal?

Thanks

Meneliki

_________________
"None are more hopelessly enslaved than those who falsely believe they are free."
"It is no measure of health to be well adjusted to a profoundly sick society."
"Hope is the first step on the road to dissapointment." -Jonah Orion
http://tankzgame.blogspot.com


Top
 Profile  
 
PostPosted: Sun Aug 26, 2012 8:59 pm 
Shake'n'Baker

Joined: Sun May 27, 2012 6:01 pm
Posts: 62
Hi meneliki

Im cant imagine the control flow in your example. But it sounds like window.active maybe the issue.

from your description, window.active means 'the window with the mouse down'.

If this is how you wish to handle this, what would make more sense is mouse.grabbing = object

when the mouse is pressed and held for longer than x seconds, grabbing is set to point to an object. and on mouse up unset. 'If mouse move and grabbing' move the window ietc..

This will make all your code independent again.

There are other solutions; But will depend on your other needs

Mikey


Top
 Profile  
 
PostPosted: Sun Aug 26, 2012 9:21 pm 
Grand Optimizer
User avatar

Joined: Mon Jan 17, 2005 6:01 pm
Posts: 352
Location: Canada
That's an interesting approach, I may give that a whirl.

Thanks Mikey!

_________________
"None are more hopelessly enslaved than those who falsely believe they are free."
"It is no measure of health to be well adjusted to a profoundly sick society."
"Hope is the first step on the road to dissapointment." -Jonah Orion
http://tankzgame.blogspot.com


Top
 Profile  
 
PostPosted: Mon Aug 27, 2012 11:05 am 
Funky Monkey

Joined: Thu Sep 09, 2004 1:17 pm
Posts: 1542
Location: burrowed
cxzuk wrote:
If this is how you wish to handle this, what would make more sense is mouse.grabbing = object


This actually sounds like a nifty little trick, thanks for pointing it out, might help out solve a bunch of ui
problems for me too :D

_________________
Long pork is people!

wzl's burrow


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group