Pixel Movement Bumping in Developer Help
|
|
Code:
mob { proc { pixel_movement() { if(src.moving) {return} src.moving = !src.moving; while(1) { for(var/v in src.directions) { var/turf/t = get_step(src, v); if(t && t.density && ((v == NORTH && src.pixel_y >= 28) || \ (v == EAST && src.pixel_x >= -4) || (v == SOUTH && src.pixel_y <= 4) || \ (v == WEST && src.pixel_x <= 4))) {src.moving = !src.moving; return;} } if(NORTH in src.directions) { if(src.y == world.maxy) {src.moving = !src.moving; return;} else if(src.pixel_y >= 28) {src.pixel_y = 4; src.y++;} else {src.pixel_y += 4;} } if(SOUTH in src.directions) { if(src.y == 1 && !src.pixel_y) {src.moving = !src.moving; return;} else if(!src.pixel_y) {src.y--; src.pixel_y = 28;} else {src.pixel_y -= 4;} } if(EAST in src.directions) { if(src.x == world.maxx) {src.moving = !src.moving; return;} else if(src.pixel_x == 32) {src.x++; src.pixel_x = 4;} else {src.pixel_x += 4;} } if(WEST in src.directions) { if(src.x == 1 && !src.pixel_x) {src.moving = !src.moving; return;} else if(!src.pixel_x) {src.x--; src.pixel_x = 28;} else {src.pixel_x -= 4;} } if(!src.directions.len) {src.moving = !src.moving; return;} sleep(0.1); } } } }
|
Problem description:
Well the movement seems to work great and all the problem I am having is getting it to bump dense turfs. Now it bumps them, but if you go East then move North and there is a dense object you can go through about the first half of it. Now if you just go East and try to go through a dense object you can get about 4 pixels in. So, if I can get some help on when I should be updating the location on the East movement it would be appreciated.
Here is a demo for it, to show what I'm talking about.
http://www.mediafire.com/?itijigv2eoy
|