Code to make ego swim

AGI1122 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) {
smartguy240
AGISCI wrote:

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) {
AGI1122 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:

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:

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.
smartguy240 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
AGI1122 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.
smartguy240 Oh :-
smartguy240 What would I do to "tweak" it? I changed those things that you said to change.
AGI1122 Here is what it looks like now which works much better than the code above:

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.