ID:2413570 Nov 27 2018, 11:23 pm (Edited on Dec 3 2018, 8:10 am) Code: This is the code for the library containing the translate proc being used for movement in the movement loop. ```// This library is a set of procs for finding, setting,// and shifting the absolute pixel positions of atoms.// (1, 1) is the bottom-left pixel of the map.#ifndef TILE_WIDTH#define TILE_WIDTH 32#endif#ifndef TILE_HEIGHT#define TILE_HEIGHT 32#endifatom proc /* Get the pixel width of this atom's bounding box. */ Width() . = TILE_WIDTH /* Get the pixel height of this atom's bounding box. */ Height() . = TILE_HEIGHT /* Get the absolute pixel-x-coordinate of the bounding box's left edge. */ Px(P) . = 1 + (x - 1 + P) * TILE_WIDTH /* Get the absolute pixel-y-coordinate of the bounding box's bottom edge. */ Py(P) . = 1 + (y - 1 + P) * TILE_HEIGHT /* Get the absolute pixel-x-coordinate of the bounding box's center. */ Cx() . = Px(1 / 2) /* Get the absolute pixel-y-coordinate of the bounding box's center. */ Cy() . = Py(1 / 2)atom/movable Width() . = bound_width Height() . = bound_height Px(P) . = 1 + bound_x + step_x + (x - 1) * TILE_WIDTH + P * bound_width Py(P) . = 1 + bound_y + step_y + (y - 1) * TILE_HEIGHT + P * bound_height var /* Accumulates the fractional part of movements in the x-axis. */ fractional_x /* Accumulates the fractional part of movements in the y-axis. */ fractional_y proc /* Directly sets the loc and step offsets to the given arguments. Best to use a proc for this in case you want to add side effects, which you can't have if you're just setting variables directly in code. */ SetLoc(Loc, StepX = 0, StepY = 0) loc = Loc step_x = StepX step_y = StepY /* Directly sets the loc and step offsets in order for the bottom-left of the bounding box to be at a given absolute pixel coordinate, or to the bottom-left of a given atom. Format: SetPosition(atom/Atom) Parameters: * Atom: The object to align bounding box bottom-left corners with. Format: SetPosition(Px, Py, Z) Parameters: * Px: The desired resulting left x-coordinate. * Py: bottom y-coordinate. * Z: z-level. */ SetPosition(Px, Py, Z) if(isloc(Px)) var atom/a = Px Px = a.Px() Py = a.Py() Z = a.z SetLoc( Loc = locate( 1 + (Px-1)/TILE_WIDTH, 1 + (Py-1)/TILE_HEIGHT, isnull(Z) ? z : Z), StepX = (Px-1) % TILE_WIDTH - bound_x, StepY = (Py-1) % TILE_HEIGHT - bound_y) /* Directly sets the loc and step offsets in order for the center of the bounding box to be at a given absolute pixel coordinate, or at the center of a given atom. Behaves kinda screwy (i.e. sends you to the void) at map edges. Format: SetCenter(atom/Atom) Parameters: * Atom: The atom to align bounding box centers with. Format: SetCenter(Cx, Cy, Z) Parameters: * Cx: The desired resulting center x-coordinate. * Cy: y-coordinate. * Z: z-level. */ SetCenter(Cx, Cy, Z) if(isloc(Cx)) var atom/a = Cx Cx = a.Cx() Cy = a.Cy() Z = a.z SetPosition(Cx - Width()/2, Cy - Height()/2, Z) /* Slides this movable atom by a given offset in pixels. Fractional movements are preserved in the fractional_x/y variables. Preserved, as in successive calls to Translate(0.1, 0) will eventually add up to a single-pixel movement to the right. Parameters: * X: Distance to move along the x-axis in pixels. * Y: Distance to move along the y-axis in pixels. Returns: * null if both arguments are false. * TRUE if only the fractional values changed. * The result of Move() for a successful whole-pixel movement. */ Translate(X, Y) if(!(X || Y)) return var rx, ry if(X) fractional_x += X rx = round(fractional_x, 1) fractional_x -= rx if(Y) fractional_y += Y ry = round(fractional_y, 1) fractional_y -= ry var s = step_size step_size = max(abs(rx), abs(ry)) + 1 . = (rx || ry) ? Move(loc, dir, step_x + rx, step_y + ry) : TRUE step_size = s /* Slides this movable atom by a given polar vector. Uses Translate(), so fractional movements are preserved. Parameters: * Distance: Distance to move in pixels. * Angle: Direction to move in degrees clockwise from NORTH. Returns: * Whatever Translate() returns. */ Project(Distance, Angle) . = Translate(Distance * sin(Angle), Distance * cos(Angle)) ``` ```#define EAST_KEY "East"#define WEST_KEY "West"#define NORTH_KEY "North"#define SOUTH_KEY "South"#define RUN "Shift"#define JUMP "Space" mob //bound_width = 26 //bound_height = 20 bound_depth = 10 step_size = 5 New() ..() var move_speed = 3 //4 tmp forward_x = 0 forward_y = 0 speed_mod = 0 jumping = FALSE running = FALSE velocity_z = 0 jump_power = 30 fall_speed = 10 verb KeyDown(k as text) set hidden = 1 usr.key_down(k) KeyUp(k as text) set hidden = 1 usr.key_up(k) movement_loop() movement = 1 gravity() if(MOVE && client) if(keys[JUMP]) jumping(19) forward_x = keys[EAST_KEY] - keys[WEST_KEY] forward_y = keys[NORTH_KEY] - keys[SOUTH_KEY] if(movement_check()) #ifndef CAGE_platform_one roofandfloor() #endif //call the gravity() to calculate descent gravity() //call the velocity() to calculate the current velocity velocity() if(movement_z) if(movement_z>0) if(step_z + bound_depth-1 + movement_z > nearestroof()) step_z = nearestroof - bound_depth - 1 else step_z += movement_z if(movement_z<0) if(step_z + movement_z < nearestfloor()) step_z = nearestfloor else step_z += movement_z if(step_z == nearestfloor) onfloor() pixel_y = initial(pixel_y)+step_z animater() if(!onfloor) if(shadow) underlays-= shadow shadow.loc = locate(x,y,z) flick("animate",shadow) shadow.step_x = step_x shadow.step_y = step_y+nearestfloor shadow.layer = layer shadow.invisibility = 0 //var/obj/Effects/Jump/A = new(src.loc) //A.layer = src.layer+1 else if(shadow) shadow.invisibility = 102//102 Translate(forward_x * (move_speed + speed_mod), forward_y * (move_speed + speed_mod)) dir = (forward_x ? forward_x > 0 ? EAST : WEST : 0) | (forward_y ? forward_y > 0 ? NORTH : SOUTH : 0) animater() movement = 0 spawn(world.tick_lag) movement_loop() movement_check() . = TRUE speed_mod = 0 if(keys[RUN]&&keys[EAST_KEY]||keys[RUN]&&keys[WEST_KEY]||keys[RUN]&&keys[SOUTH_KEY]||keys[RUN]&&keys[NORTH_KEY]||In_Battle) running = TRUE else running = FALSE;Reset_Icon_State() if(running) speed_mod += 2 Reset_Icon_State()/dm>Problem description: After updating to the latest BETA version of DM, I noticed i couldn't move in our game. This is the movement loop being used as of now. It also incoporates Kaiochao's Absolute Position library; the translate proc. (http://www.byond.com/developer/Kaiochao/absolutepositions) which i believe just utilizes the step and Move procs.Any idea what's going on or any insights? ``` <-> Dec 3 2018, 12:07 am Anyone?? <-> Dec 3 2018, 6:30 am Do some debugging and narrow the problem down. Go through BYOND's update logs and look for changes made specifically to movement related procs from the version you had previously up to the Beta. The information you have provided to us on the outside looking in isn't much to go on. I think if you do your due diligence with the information you do have, you'll discover the issue. <-> Dec 3 2018, 8:07 am I have checked the notes and everything already, there seems to be no changes to the movement system placed. But I don't understand why my movement just stopped after updating. Wouldn't be the first time either. But....Let me add the translate proc so you can see how everything is working in the actual movement proc. I hope the updated codes I posted may be able to give some more and better insight into the issue, but I will also try debugging too. 