ID:270973
 
Basically what I want to do is create an underwater combat system for my game. I have already gotten players to the underwater map, added a breathing system, and got them to switch states, but what I couldn't do is make them slowly descend in the water if they don't swim with arrow keys. Is there a way to make them descend by pixels? Also, I'd like to thank the people in this forum. In the last month of coding I've learned a lot from all of your posts and replies.
Moving something pixel by pixel (othewise known as pixel movement) can get a bit tricky in BYOND. The variables associated with pixel movement are pixel_x and pixel_y. Giving these a positive value displaces the atom's icon by the value inputted in the positive direction from the axis chosen. Now I'm sure that sentence won't make any sense to anyone besides me so I'll give a much clearer picture:

mob/verb/Shift_Horizontally(n as num)
pixel_x = n


In that case, if n was 100, your icon would move 100 pixels to the right. If n was -50, it would move 50 pixels to the left. One thing to note though is that this is purely graphical. So your real atom would still be in the same position (and Bump(), Enter(), density etc) would all work from the real position rather than the icon.

Similarly

mob/verb/Shift_Vertically(n as num)
pixel_y = n


If n was 5, you'd move 5 pixels up. If n was -94, you'd move -94 pixels down.

Another thing to note is that pixel_x and pixel_y only take real integers (real whole numbers). So 5.5 wouldn't work.

At this point, you might be loving pixel_x and pixel_y, but here's the real downfall. They range from -127 to 127, which means that you can't easily displace your icon more than 127 pixels. Search the forum for ways around that.