Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (VoroneTZ, monk12, Quad), 829 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 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: 991
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 991
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: 991
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 991
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: 619
Turkey, Izmir
Emre Offline
User
Emre  Offline
User

Joined: Jul 2007
Posts: 619
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: 991
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 991
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