Author Topic: Code to make ego swim  (Read 2224 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris Cromer

Code to make ego swim
« 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) {
« Last Edit: December 31, 1969, 07:00:00 PM by 1018072800 »


Chris Cromer

It's all fun and games until someone get's hurt then it's just fun. ;)

Offline Patrick

Re:Code to make ego swim
« Reply #1 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) {


Offline Chris Cromer

Re:Code to make ego swim
« Reply #2 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.
Chris Cromer

It's all fun and games until someone get's hurt then it's just fun. ;)

Offline Patrick

Re:Code to make ego swim
« Reply #3 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


Offline Chris Cromer

Re:Code to make ego swim
« Reply #4 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.
« Last Edit: May 09, 2002, 07:46:20 PM by AGISCI »
Chris Cromer

It's all fun and games until someone get's hurt then it's just fun. ;)

Offline Patrick

Re:Code to make ego swim
« Reply #5 on: May 09, 2002, 07:35:19 PM »
Oh  :-[  ok sorry!


Offline Patrick

Re:Code to make ego swim
« Reply #6 on: May 12, 2002, 04:40:53 PM »
What would I do to "tweak" it? I changed those things that you said to change.


Offline Chris Cromer

Re:Code to make ego swim
« Reply #7 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.
Chris Cromer

It's all fun and games until someone get's hurt then it's just fun. ;)


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.042 seconds with 21 queries.