Community

AGI Programming => Mega Tokyo AGI Archive => Topic started by: Chris Cromer on September 02, 2001, 06:38:28 PM

Title: Code to make ego swim
Post by: Chris Cromer on September 02, 2001, 06:38:28 PM
This is the code for making your ego swim just change a few things to make it work with your game.

// Put the code below into the all rooms that have water.

// Beginnning of code

if (ego_on_water) {
Title: Re:Code to make ego swim
Post by: Patrick on April 21, 2002, 04:42:30 PM

This is the code for making your ego swim just change a few things to make it work with your game.

// Put the code below into the all rooms that have water.

// Beginnning of code

if (ego_on_water) {
Title: Re:Code to make ego swim
Post by: Chris Cromer on April 21, 2002, 04:55:53 PM
f100 was basically a flag I used to make sure the write animation of the ego is drawn... this code is quite old, I have rewritten it. You can set f100 to whatever flag you want it doesn't make any difference in the code.

The only things that need to be changed are these:

Quote
new_ego_x = new_ego_x - 7;
7 is what I got when I subtracted the width of the ego view and the swimming view. Just subtract the ego view from the swimming view and place that number in place of the 7.

And also change this:

Quote
new_ego_x = new_ego_x + 11;
I got the 11 by adding 4 to the 7 I got from earlier. Just add 4 to whatever number you got for the above and replace 11 with it.

Good luck with this. And if you can't get it to work I will post the new swimming code I have.
Title: Re:Code to make ego swim
Post by: Patrick on May 09, 2002, 06:43:35 PM
Well, I cant seem to get this code to work. Am I supposed to draw something on my picture resoucre? is it outdated(is that possible?  :)  )

SMG240
Title: Re:Code to make ego swim
Post by: Chris Cromer on May 09, 2002, 07:15:09 PM
As I said this is old code AND it is specifically for somebodies game. He asked for a swimming code and I made it for him. With some tweaking it should work for you though.
Title: Re:Code to make ego swim
Post by: Patrick on May 09, 2002, 07:35:19 PM
Oh  :-[  ok sorry!
Title: Re:Code to make ego swim
Post by: Patrick on May 12, 2002, 04:40:53 PM
What would I do to "tweak" it? I changed those things that you said to change.
Title: Re:Code to make ego swim
Post by: Chris Cromer on May 12, 2002, 05:15:13 PM
Here is what it looks like now which works much better than the code above:

Code: [Select]
if (ego_on_water) {
 set.view(ego,1);
 if (!f100) {
   if ((ego_dir == 6 ||          //if ego walking left
        ego_dir == 7 ||
        ego_dir == 8 )) {
     new_ego_x = new_ego_x - 6;  //if the width of the side view of the swimming ego is bigger
                                 //than the width of the side ego walking subtract swim view
                                 //from the walking view. I got 6.
     object.on.water(ego);
   }
   if (ego_dir == 5) {
     new_ego_y = new_ego_y + 10;
   }
   erase(ego);
   position.v(ego,new_ego_x,new_ego_y);
   draw(ego);
 }
 get.posn(ego,new_ego_x,new_ego_y);
 if (new_ego_y == 72 && ego_dir == 1) {
   new_ego_y = new_ego_y - 10;
   erase(ego);
   position.v(ego,new_ego_x,new_ego_y);
   draw(ego);
 }
 set(f100);
 set(always_animate_ego);
}
else {
 set.view(ego,0);
 if (f100) {
   if ((ego_dir == 2 ||
        ego_dir == 3 ||
        ego_dir == 4)) {
     new_ego_x = new_ego_x + 11; //set 11 to the size of the width of the swimming view's side
     object.on.land(ego);
   }
   erase(ego);
   position.v(ego,new_ego_x,new_ego_y);
   draw(ego);
   object.on.land(ego);
 }
 reset(f100);
 reset(always_animate_ego);
}


You still will need to change some values depending on the size of the ego's view and the ego's swimming view.