Gamestudio Links
Zorro Links
Newest Posts
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
4 registered members (AndrewAMD, Baklazhan, Ayumi, Hanky27), 1,387 guests, and 2 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
points to open a door #403670
06/24/12 00:05
06/24/12 00:05
Joined: Nov 2006
Posts: 497
Ohio
xbox Offline OP
Senior Member
xbox  Offline OP
Senior Member

Joined: Nov 2006
Posts: 497
Ohio
I have a snippet of code I wrote to require the player to have 2000 points in order to open a door. It works fine if the player walks upto it with 2000+ points and and works by not opening if the player has less than 2000 points. My problem is that after the player walks up to the door and fails to open it (not enough points), once I get more points, I cannot go back and open it.

here is my code.
Code:
action doorU()
{
	while(player==NULL) {wait(1);}
	while(vec_dist(player.x , my.x) >80){wait(1);}
	if(vec_dist(player.x , my.x) <= 80)
	{
		if(totalPoints >= 2000)
		{
			beep();
			totalPoints -= 2000;
			ent_remove(me);
		}
		else
			return;
	}
	else
		return;
}



Re: points to open a door [Re: xbox] #403671
06/24/12 05:21
06/24/12 05:21
Joined: Mar 2009
Posts: 88
Walori Offline
Junior Member
Walori  Offline
Junior Member

Joined: Mar 2009
Posts: 88
After the failed attempt the action terminates. You should use a loop that doesn't break after the player is in the distance but when the every condition to the door opening is met. Like this:

Code:
while(!player)wait(1);
while(1)
{
if(vec_dist(player.x,my.x) <=80 && totalPoints >= 200)break;
}



Re: points to open a door [Re: Walori] #403693
06/24/12 18:06
06/24/12 18:06
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
while(1) give you a error after the ent_remove(me)
Use while(me) instead.

Last edited by Widi; 06/24/12 18:06.
Re: points to open a door [Re: Widi] #403699
06/24/12 20:38
06/24/12 20:38
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Originally Posted By: Widi
while(1) give you a error after the ent_remove(me)
Use while(me) instead.

No, the function is stopped automatically if the my entity gets removed. Thus while(1) is perfectly fine.
Walori's code is okay but obviously misses a "wait(1);" in the second while loop.


"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: points to open a door [Re: Superku] #403706
06/25/12 03:00
06/25/12 03:00
Joined: Nov 2006
Posts: 497
Ohio
xbox Offline OP
Senior Member
xbox  Offline OP
Senior Member

Joined: Nov 2006
Posts: 497
Ohio
Okay so I got it working by making my second while loop and just making it while(1) and then enclosing the rest of the action in that one loop. I didn't do that originally because I was thinking the while(1) would cause the game to slow a bit because all of the doors would be in an infinite while loop waiting for the player to get close with enough points. haha Thanks though to all three of you, I appreciate it.

Re: points to open a door [Re: xbox] #404132
07/03/12 02:44
07/03/12 02:44
Joined: Dec 2009
Posts: 128
China
frankjiang Offline
Member
frankjiang  Offline
Member

Joined: Dec 2009
Posts: 128
China
your question: pointer a to open door by mouse or any you want.

open door looks like a animation.your use door animation by game event.
and then your put any block nearless your door. So if you want to control just push event to your game Object ,and play animation by itself.


development 3d game is interesting!
Re: points to open a door [Re: frankjiang] #404145
07/03/12 14:53
07/03/12 14:53
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Quote:

your question: pointer a to open door by mouse or any you want.

open door looks like a animation.your use door animation by game event.
and then your put any block nearless your door. So if you want to control just push event to your game Object ,and play animation by itself.
???

For all who want to know, this should work
Code:
#define open skill100

action points_door()
{
  while(!player) wait(1);
  while(my)
  {
    if(player)if(vec_dist(player.x, my.x) < 80 && totalPoints>2000 && my.open == 0)
    { 
      my.open = 1;
      _open_door(); //whatever
    }
    if(player)if(vec_dist(player.x, my.x) > 80 && my.open == 1)
    { 
      my.open = 0;
      _close_door(); //whatever
    }

    wait(1);
  }
}



Last edited by rayp; 07/03/12 15:10.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;

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