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
1 registered members (AndrewAMD), 1,089 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
random code #214738
07/06/08 23:26
07/06/08 23:26
Joined: Aug 2006
Posts: 152
vector(200,45,338)
Marwan Offline OP
Member
Marwan  Offline OP
Member

Joined: Aug 2006
Posts: 152
vector(200,45,338)
wussup george , I copied a randomization code from your aum from the questions section , i dont remember which one , and i modified it and made it like this

Code:
 function bat_direction()
{
       var index;
       index = random(10);
       var tempo = 0;
       while (index > 0)
       {	
               tempo = random (1);
               if (tempo <= 0.2)
               {
               my.pan+=0*time_step;
               }
               if ((tempo > 0.2) && (random(1)<= 0.4))
               {
                       my.pan+=10*time_step;
               }
               if ((tempo > 0.4) && (random(1) <= 0.6))
               {
                       my.pan-=10*time_step;
               }
               if ((tempo > 0.6) && (random(1)<= 0.8))
               {
                       my.tilt+=10*time_step;
               }
               if (tempo > 0.8)
               {
                       my.tilt-=10*time_step;
               }
               index-=1;
       }
}


it was for saving quotes in a random way , i only changed the instructions

the question is , whats the use of the index var , I replaced it with while loop , but it screwed it up

the other question is that i cant see any randomization , because i watched the pan variable of the entity and it only keeps increasing , it dont decrease at all , and vice versa with the tilt variable , it only keeps decreasing

and sorry for bothering you george



age:16 game design and programming experience:2 years
Re: random code [Re: Marwan] #214776
07/07/08 09:51
07/07/08 09:51
Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
George Offline

Expert
George  Offline

Expert

Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
Don't worry, you don't bother me at all. What exactly are you trying to achieve?

Re: random code [Re: George] #214848
07/07/08 18:22
07/07/08 18:22
Joined: Apr 2005
Posts: 3,076
Germany, NRW
rvL_eXile Offline

3D Artist
rvL_eXile  Offline

3D Artist

Joined: Apr 2005
Posts: 3,076
Germany, NRW
I think hes confused about these Values (Pan/Tilt)... Add in the first line

Code:
my.pan%=360;
my.tilt%=360;


cYa Sebastian


Tutorials:
[Blender]Terrain creation ENG/GER
[Blender]Low Poly Tree Modeling
[GIMP]Create a Texture for Terrains
CLICK HERE


Re: random code [Re: rvL_eXile] #214935
07/08/08 09:53
07/08/08 09:53
Joined: Aug 2006
Posts: 152
vector(200,45,338)
Marwan Offline OP
Member
Marwan  Offline OP
Member

Joined: Aug 2006
Posts: 152
vector(200,45,338)
thanks george

I am trying to make some realistic movement for some flying bats , so I make them change their pan and tilt randomly and continously , as if they just flying around , and i made their moves look realistic , but i realized something wrong in their movement , so I watched the pan variable to see how does it change and i found it increasing only , it didnt decreasing even for a millisecond (assuming that the randomization changes every frame or sth like that ) so that means that there is no randomization at all
I closed the engine and ran it again a couple of times , but it gives the same result , i forgot to tell you that the same thing happens to the tilt value

I want to know why is that happening ?

and thanks again

ps :thanks sebastian but that wasnt exactly my point


age:16 game design and programming experience:2 years
Re: random code [Re: Marwan] #215368
07/10/08 19:30
07/10/08 19:30
Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
George Offline

Expert
George  Offline

Expert

Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
I wrote some random bird flying code in one of the more recent magazines. Did you try it? Look for it in the "unanswered questions" (faq) section of the magazine.

Re: random code [Re: George] #215435
07/11/08 07:46
07/11/08 07:46
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
'I' would like a peek at that snippet, but there isn't time to look it up in an AUM index, at the moment.
Code:
// C-Script, 6.60
// use or ignore
// sample only
// untested
define _tm1, skill52;	// time counter for entity
define _dir1, skill53;  	// dir = 1,  or -1; pan
define _dir2, skill54;	// dir = 1, or -1 ; tilt

var mo = 0;		// time, time_step, synonym
var n1 = 0;		// temp var
var n2 = 0;		// temp var
var nStepPan = 5;	// step for pan
var nStepTilt = 5;	// step for tilt

function batty_f1() {
	timef();
	my.passable = ON;
	my._tm1 = max(my._tm1 - mo, 0);  // check that for inaccuracy
	if (my._tm1 <= 0.002) {
		my._tm1 = max(random(10), 1) * 16;
		if2(random(1) > 0.5, n1, 1, -1);
		if2(random(1) > 0.5, n2, 1, -1);
		my._dir1 = n1;
		my._dir2 = n2;
	}
	if (random(1) > 0.45) {
		my.pan += my._dir1 * nStepPan * mo;
		my.tilt += my._dir2 * nStepTilt * mo;
		my.tilt = clamp(my.tilt, -45, 45);
	}
	temp.x = 5 * mo;
	temp.y = 0;
	temp.z = 0;
	c_move(me, temp, nullvector, IGNORE_PASSABLE);
}
action batty_a1 {
	while(me != NULL) {
		batty_f1();
		wait(1);
	}
}


Tips hat at George.
'I' hope that 'you' are faring well.



Re: random code [Re: testDummy] #215457
07/11/08 10:38
07/11/08 10:38
Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
George Offline

Expert
George  Offline

Expert

Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
Check out Aum45 to see an example.

Re: random code [Re: George] #215601
07/12/08 11:07
07/12/08 11:07
Joined: Aug 2006
Posts: 152
vector(200,45,338)
Marwan Offline OP
Member
Marwan  Offline OP
Member

Joined: Aug 2006
Posts: 152
vector(200,45,338)
well , that should do it , but still one more something I need to know , How does the index var help , I saw it too in the script of the booker from the aum 72 code , nd its still confusing me , of course its not a predefined var , is it?

Last edited by Marwan; 07/12/08 11:46.

age:16 game design and programming experience:2 years
Re: random code [Re: Marwan] #215648
07/12/08 16:25
07/12/08 16:25
Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
George Offline

Expert
George  Offline

Expert

Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
I have a hard time trying to debug other people's code; I have to get into their mindset in order to do that. "index" is just a regular name for a variable; I use it in loops or in repetitive actions and its value is usually incremented or decremented in a loop.

Re: random code [Re: George] #215699
07/12/08 21:04
07/12/08 21:04
Joined: Aug 2006
Posts: 152
vector(200,45,338)
Marwan Offline OP
Member
Marwan  Offline OP
Member

Joined: Aug 2006
Posts: 152
vector(200,45,338)
thx again george


age:16 game design and programming experience:2 years

Moderated by  George 

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