Gamestudio Links
Zorro Links
Newest Posts
zorro license, IB connection
by AndrewAMD. 12/06/23 17:16
Newbie Questions
by fairtrader. 12/06/23 11:29
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
5 registered members (AndrewAMD, miwok, TipmyPip, 3run, 1 invisible), 631 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
I want solution to the easy problem #269436
06/03/09 05:45
06/03/09 05:45
Joined: Jun 2009
Posts: 12
bahrain
A
abdulla Offline OP
Newbie
abdulla  Offline OP
Newbie
A

Joined: Jun 2009
Posts: 12
bahrain
Hi !!

I have a small problem .. I want to help me.
How do I make the object go and back repeatedly ??

For example ..

The object goes to the point A and then return to point B and then go again to point A .. Thus ??

this is my code :

Quote:
action monster1
{
my.enable_scan = on;
my.event = monster_1;
while (1)
{
my.x += 1.5;
ent_cycle("walk", my.skill46);
my.skill46 += 4 * time;
if(my.x > 12)
{
while(1)
{
my.x -= 1.5;
my.pan = 180;
ent_cycle("walk", my.skill46);
my.skill46 += 4 * time;
wait(1);
}
}
wait(1);
}
}


This code makes the object Just go and back then continue walking frown

Re: I want solution to the easy problem [Re: abdulla] #269439
06/03/09 05:59
06/03/09 05:59
Joined: Apr 2009
Posts: 298
Southern Oceans
KiwiBoy Offline
Member
KiwiBoy  Offline
Member

Joined: Apr 2009
Posts: 298
Southern Oceans
HI, try it like this

action monster1
{
var goback = 1;
my.enable_scan = on;
my.event = monster_1;

while (goback > 0)
{
my.x += 1.5;
ent_cycle("walk", my.skill46);
my.skill46 += 4 * time;
my.skill1 += 1 *time_step;

if(my.skill1 > 12)//adjust as required
{
my.x -= 1.5;
my.pan = 180;
ent_cycle("walk", my.skill46);
my.skill46 += 4 * time;
}
return;
}
}

or base your script on similar.

Here skill1 has been used as a timer and when it runs out, your char walks backwards and return loops it.

Not tried, just hurridly edited from yours to show a way smile


Use the 'manual' Luke, the manual is your friend. 'Self reminder' smile

My WebPage
Re: I want solution to the easy problem [Re: KiwiBoy] #269440
06/03/09 06:06
06/03/09 06:06
Joined: Jun 2009
Posts: 12
bahrain
A
abdulla Offline OP
Newbie
abdulla  Offline OP
Newbie
A

Joined: Jun 2009
Posts: 12
bahrain
but the monster is not move and animate ..

Re: I want solution to the easy problem [Re: abdulla] #269497
06/03/09 11:13
06/03/09 11:13
Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Cowabanga Offline
Expert
Cowabanga  Offline
Expert

Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Try this:
Code:
action monster1
{
var goback = 1;
my.enable_scan = on;
my.event = monster_1;

while (goback > 0)
{
my.x += 1.5;
ent_animate(my,"walk",my.skill46,ANM_CYCLE);
my.skill46 += 4 * time;
my.skill1 += 1 *time_step;

if(my.skill1 > 12)//adjust as required
{
my.x -= 1.5;
my.pan = 180;
ent_animate(my,"walk",my.skill46,ANM_CYCLE);
my.skill46 += 4 * time; 
}
return;
}
}


Re: I want solution to the easy problem [Re: Cowabanga] #269507
06/03/09 11:37
06/03/09 11:37
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
and here is this

Code:

var counter = 0;

action monster1
{
     my.enable_scan = on;
     my.event = monster_1;
     while (1){ wait(1);

          //always loop animation in a while
          ent_cycle("walk", my.skill46);
          my.skill46 += 4 * time;

          if(my.x < 12){//use a multiple of 1.5 (3, 4.5, 6, 7.5...12)
               my.x += 1.5;
               counter += 1.5;//same as your movement amount
               my.pan = 0;// you need to reset the pan here
          }

          if(my.x >= 12){
               my.x -= 1.5;
               counter += 1.5;//keep adding, removes further coding
               my.pan = 180;
          }
          if(counter> 24){counter = 0;}//reset the counter, cause the enemy should be back where he was.
     }
}



remember,

as soon as you get into a while loop, you can not perform 'ifs' outside of its loop, unless you provide your script a way to exit to the if statement...

Enjoy laugh


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: I want solution to the easy problem [Re: DLively] #269563
06/03/09 14:15
06/03/09 14:15
Joined: Jun 2009
Posts: 12
bahrain
A
abdulla Offline OP
Newbie
abdulla  Offline OP
Newbie
A

Joined: Jun 2009
Posts: 12
bahrain
Devon

thank you .. but if monster is go to Point B he isn't back to A ..
how ?? frown

Re: I want solution to the easy problem [Re: abdulla] #269619
06/03/09 19:11
06/03/09 19:11
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
hopfel Offline
User
hopfel  Offline
User

Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
Hm when I want to make that I use this (it's nearly the self then the other) :

my.skill1+=0.5*time_step;

if(my.skill2==0)
{
my.pan=0;
my.x+=1.5;
if(my.skill1>=12)
{
my.skill1=0;
my.skill2=1;
}}

if(my.skill2==1)
{
my.pan=180;
my.x-=1.5;
if(my.skill1>=12)
{
my.skill1=0;
my.skill2=0;
}}



Last edited by hopfel; 06/03/09 19:13.

Hilf mir, dir zu helfen!
Re: I want solution to the easy problem [Re: hopfel] #269916
06/05/09 08:36
06/05/09 08:36
Joined: Jun 2009
Posts: 12
bahrain
A
abdulla Offline OP
Newbie
abdulla  Offline OP
Newbie
A

Joined: Jun 2009
Posts: 12
bahrain
hopfell .. the monster isn't move why ??

Re: I want solution to the easy problem [Re: abdulla] #269917
06/05/09 08:36
06/05/09 08:36
Joined: Jun 2009
Posts: 12
bahrain
A
abdulla Offline OP
Newbie
abdulla  Offline OP
Newbie
A

Joined: Jun 2009
Posts: 12
bahrain
ok all thank you very much !!


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