Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AbrahamR, AndrewAMD, ozgur), 763 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Need help with 2d game panels. #294466
10/19/09 10:46
10/19/09 10:46
Joined: Oct 2009
Posts: 21
Redneck country USA
Crazykins Offline OP
Newbie
Crazykins  Offline OP
Newbie

Joined: Oct 2009
Posts: 21
Redneck country USA
I am writing a 2d game. I have a panel that is my player. I also have a panel that acts as the players weapon. My player moves so how would I get the weapon to move with the player. I was thinking perhaps I could add a window element to the player panel and just add the bmap to the window. I can't seem to get it to work.

So far I have the pick up of the weapon in the level working. But am at a stand still as far as how to add one panel to another moving panel. I want the weapon and the player to move as one.

The reason why I want 2 panels instead of just creating one panel with the weapon is I want the weapon to be animated separatly from the player.

Thanks for your help! laugh

Re: Need help with 2d game panels. [Re: Crazykins] #294492
10/19/09 14:09
10/19/09 14:09
Joined: Apr 2009
Posts: 248
Philippines
seecah Offline
Member
seecah  Offline
Member

Joined: Apr 2009
Posts: 248
Philippines
Can you post your codes how you let your player moves? Is it through mouse_force or keyboard? I might be able to add from it for you to add another panel on your player's panel..



Can't is not an option™
Re: Need help with 2d game panels. [Re: seecah] #294575
10/19/09 23:21
10/19/09 23:21
Joined: Oct 2009
Posts: 21
Redneck country USA
Crazykins Offline OP
Newbie
Crazykins  Offline OP
Newbie

Joined: Oct 2009
Posts: 21
Redneck country USA
here is my player panel code. The bmap changes based on direction of the keyboard.

Code:
function player_startup()
{
	VECTOR player_speed;
	var horizontal_speed = 0;
	var vertical_speed = 0;
	player_pan = pan_create("bmap = player.png", 150);
	player_pan.pos_x = 75;
	player_pan.pos_y = 158;
	player_pan.flags |= VISIBLE;
	player_pan.center_x = player_pan.size_x * 1; // set the rotation point for the panel
	player_pan.center_y = player_pan.size_y; // at its center on the x and at its bottom at its y axis
	while (1)
	{
		vec_set(player_speed.x, accelerate (horizontal_speed, 3 * (key_cur - key_cul), 0.3)); // 2 gives the acceleration, 0.3 the friction
		player_pan.pos_x += player_speed.x;
		vec_set(player_speed.y, accelerate (vertical_speed, 3 * (key_cud - key_cuu), 0.3)); // 2 gives the acceleration, 0.3 the friction
		player_pan.pos_y += player_speed.y;
		
		if (key_cul + key_cur + key_cuu + key_cud)
		{
			player_pan.angle += 0.8 * sin(60 * total_ticks);
		
			if (key_cul)
			{
				player_pan.bmap = player_left;
			}
			
			if (key_cur)
			{
				player_pan.bmap = player_right;
			}
			
			if (key_cuu)
			{
				player_pan.bmap = player_up;
			}
			
			if (key_cud)
			{
				player_pan.bmap = player_down;
			}
		}
			
			else
			{
				player_pan.bmap = player_center;
				player_pan.angle = 0;
			}
		
		wait (1);
	}
}



And here is my weapon panel code so far. It just disapears once the player gets close to the object then in another panel it shows that the weapon is equipped. But is not yet attached to the player.

Code:
function weapon_startup()
{
	VECTOR weapon_pos;
	 	weapon_pan = pan_create("bmap = skilletright1.png", 150);
		weapon_pan.pos_x = 125;
		weapon_pan.pos_y = 320;
		weapon_pan.flags |= VISIBLE;
	   while ((abs(player_pan.pos_x - weapon_pan.pos_x) > 40) || (abs(player_pan.pos_y - weapon_pan.pos_y) > 40))
	   {
	           wait (1);
	   }
	   
	   weapon_equip_pan.bmap = skillet_Right1;
	   ptr_remove(weapon_pan); // remove the weapon once picked up.
	   wait (1);
}



Thanks for the help grin

Last edited by Crazykins; 10/19/09 23:22.
Re: Need help with 2d game panels. [Re: Crazykins] #294579
10/20/09 00:01
10/20/09 00:01
Joined: Oct 2009
Posts: 21
Redneck country USA
Crazykins Offline OP
Newbie
Crazykins  Offline OP
Newbie

Joined: Oct 2009
Posts: 21
Redneck country USA
I got it! Just needed some sleep lol.

Code:
pan_setwindow(player_pan,0,40,10,178,160,skillet_Right1,0,NULL);



Works exactly the way I want it. Now I just need to fix the settings of the window so I looks right.

Thanks though for your help! grin

Re: Need help with 2d game panels. [Re: Crazykins] #294588
10/20/09 03:19
10/20/09 03:19
Joined: Apr 2009
Posts: 248
Philippines
seecah Offline
Member
seecah  Offline
Member

Joined: Apr 2009
Posts: 248
Philippines
wink That's really the result of no sleep.. grin



Can't is not an option™

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