|
Registered User
|
 |
Join Date: Mar 2001
Location: Chicago, IL
Posts: 791
|
|
When I was trying out the new commands, this is what I made to check out attachplayertoobj... I'll add some comments for you.
NPC Code:
if (created) {
setimg lift_platform.png;
this.speed = .1;
drawunderplayer;//looked funny when the player was getting on without this
setshape2 8,7,{
20,20,20,20,20,20,20,20,
20, 0, 0, 0, 0, 0, 0,20,
20, 0, 0, 0, 0, 0, 0,20,
20, 0, 0, 0, 0, 0, 0,20,
20, 0, 0, 0, 0, 0, 0,20,
20,20, 0, 0, 0, 0,20,20,
20,20, 0, 0, 0, 0,20,20,
};//sets the images blocking properties
timeout = .05;
}
if (timeout) {
if (this.mode=0) {//left movement
if (x<12) {
this.mode = 1;
} else {
x -= this.speed;
}
} else {
if (x>42) {//right movement
this.mode = 0;
} else {
x += this.speed;
}
}
if (playerattached) {
this.check = false;//checks if the player can get off without getting stuck on a wall
for (i = 0;i<4;i++) {
if (onwall(x+2+i,y+7)) {
this.check = true;
break;
}
}
if (playery>=y+4 && playerx+.5 in |x+1,x+4| && this.check==false)//this will take the player off the object if theres no wall in the way
detachplayer;
} else {
if (playerx+.5 in |x,x+5| && playery in |y-2,y+4|)//this attaches the player to the object
attachplayertoobj 0,id;
}
timeout = .05;
}
|
__________________
Eric Kraft
|
|