Gamestudio Links
Zorro Links
Newest Posts
IG plugin initial release
by sodiumchloride. 09/22/20 20:53
Using STL in Zorro strategies
by AndrewAMD. 09/22/20 17:01
Rubbish data from Yahoo
by DanielX. 09/22/20 14:37
assert
by Grat. 09/22/20 12:14
MT4 - use more Zorro script
by Grat. 09/22/20 06:49
Single advise model for portfolio
by jmlocatelli. 09/21/20 19:41
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
4 registered members (Dooley, kvm, AndrewAMD, jmlocatelli), 445 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
NewBorn, 3dvg, secretagentman, distribution, EditeY
18515 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Moving Panels together #480817
07/16/20 15:53
07/16/20 15:53
Joined: Sep 2009
Posts: 957
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 957
Budapest
I would like to move more than one (2 or 3 or 14 or 35 or 42 or more...) panels together, at once. If it is possible...
I have an idea, I think that would work, but... What would be the most appropriate method to do it?
Thanks in advance.

Re: Moving Panels together [Re: Aku_Aku] #481027
08/02/20 09:46
08/02/20 09:46
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Save a difference vector = panel pos - mouse_pos on left mouse clicks, set panel to (new) mouse_pos + difference vector.
This could either be saved in panel skills or in a helper struct which you access via some panel ID.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Moving Panels together [Re: Aku_Aku] #481033
08/02/20 19:41
08/02/20 19:41
Joined: Sep 2009
Posts: 957
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 957
Budapest
Yeah I am using the same algorithm for moving one panel. I am just curious how should do it with perhaps four panels.
Moving the rest three panels is the exciting part. One method is modifying their position in the first panel mover function.
Is there another method under the sun?

I did not know the panels have skills. Can I refer to them like this? mypanel.skill[42]
How many skills do they have? What kind of data can be stored in one skill?
Maybe, somehow I overlooked this information in the manual.

Re: Moving Panels together [Re: Aku_Aku] #481034
08/02/20 23:08
08/02/20 23:08
Joined: Jul 2007
Posts: 577
Turkey, izmir
Emre Offline
User
Emre  Offline
User

Joined: Jul 2007
Posts: 577
Turkey, izmir
Originally Posted by Aku_Aku
I did not know the panels have skills. Can I refer to them like this? mypanel.skill[42]
How many skills do they have? What kind of data can be stored in one skill?
Maybe, somehow I overlooked this information in the manual.


You should take a look at "atypes.h" All structures are in that file.

[Linked Image]

Re: Moving Panels together [Re: Aku_Aku] #481035
08/02/20 23:09
08/02/20 23:09
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Go to your Gamestudio installation folder, then open the "include" subfolder. Among others you'll find atypes.h in there. You might have seen and looked into it before but still, check it out. There's the PANEL definition inside:
Code
typedef struct PANEL {
	C_LINK link;
	long	type;		// internal use only
	var	layer;		// layer number (read only)
	var	pos_x,pos_y;	// screen position in pixels
	long	flags;		// 
	var	alpha;		// transparency factor
	BMAP	*bmap;		// background bitmap
	var	scale_x,scale_y;
	var	blue,green,red;	// color for background and Truetype fonts
	var	size_x,size_y;	// panel dimension
	var	angle;			// rotation angle (6.5 or above)
	var	center_x,center_y;	// rotation center
	BMAP	*mouse_map;
	BMAP	*target_map;
	EVENT	event;		// panel function, executed on mouse click
	var   skill_x,skill_y; // general purpose variables
	byte  pad[PAD_PANEL];
} PANEL;


You can use skill_x/y freely. center_x/y might be usable (in a hacky way sort of) as well, never tried it.
If you've got the code to move one panel you have it to move them all. You need to know beforehand which panels to move of course.
What about something like this (needs more stuff to work but you get the idea):

Code
typedef struct
{
	PANEL* pnl;
	int isSelected;
	var diffX, diffY;
} PANEL_EXTENDED;
#define PANELS_EXTENDED_MAX 8
PANEL_EXTENDED panelsExtended[PANELS_EXTENDED_MAX];

void panelsExtendedInit()
{
	panelsExtended[0].pnl = myPanel1;
	panelsExtended[0].isSelected = 1;
	
	panelsExtended[1].pnl = myPanel2;
	
	panelsExtended[2].pnl = myPanel3;
	panelsExtended[2].isSelected = 1;
}

void panelsExtendedSetDiffs() // call this on left mouse presses (once, like on_mouse_left)
{
	int i;
	for(i = 0; i < PANELS_EXTENDED_MAX; i++)
	{
		PANEL_EXTENDED *pnlExtended = &panelsExtended[i];
		PANEL* pnl = pnlExtended.pnl;
		if(pnl != NULL && pnlExtended.isSelected)
		{
			pnlExtended.diffX = pnl.pos_x - mouse_pos.x;
			pnlExtended.diffY = pnl.pos_y - mouse_pos.y;
		}
	}	
}

void panelsExtendedMove()
{
	int i;
	for(i = 0; i < PANELS_EXTENDED_MAX; i++)
	{
		PANEL_EXTENDED *pnlExtended = &panelsExtended[i];
		PANEL* pnl = pnlExtended.pnl;
		if(pnl != NULL && pnlExtended.isSelected)
		{
			pnl.pos_x = mouse_pos.x + pnlExtended.diffX;
			pnl.pos_y = mouse_pos.y + pnlExtended.diffY;
		}
	}
}


Last edited by Superku; 08/02/20 23:09.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Moving Panels together [Re: Aku_Aku] #481044
08/03/20 12:22
08/03/20 12:22
Joined: Sep 2009
Posts: 957
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 957
Budapest
Thanks for Emre and Superku for pointing out the atypes.h. Yesterday I had the idea, should peek into that file, that should be worthy. You two made it sure.
Special thanks for Superku for the idea supported by example code. I was suspected something like this. But the code is nice to see.
Thanks again for you. This community is great.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1