ID:145198
 
Code:
client
MouseDrag(S,O)
if(weap=="Machinegun")
var/obj/Bullet/B=new(usr.loc)
pixel_X=rand(0,32)
pixel_Y=rand(0,32)
B.pixel_x=pixel_X
B.pixel_y=pixel_Y
walk(B,get_dir(usr,O),0)


Problem description: the code above works but not how i want it the bullets will only go in the 8 directions i want them to head to where the usr dragged and then continue i dont do much with bullets so im really stumped.

no one answering? not even the people screaming im a noob?

In response to Flame500
Nobody is answering because you haven't even given people an hour to answer you yet. This is a forum, not a chatroom.

However, because you would rather have a quick answer than a thorough one: you're going to have to calculate the rise and the run (remember drawing lines in algebra?) of the line that is the path your bullet should take. If you've dealt with vectors in the past, it should be a piece of cake. Take the difference in the X and the difference in the Y, and then normalize the two values (so that x*x + y*y = 1, more algebra woo!) You can then use these new values (let's call the dx and dy) to move the bullet. Each "step", add the values of dx and dy to the X and Y variables. IMPORTANT: don't use normal x and y, because that'll discard the remainders, which you need! If you want a bullet to move faster than 1 tile per "step," then you'll need to multiply dx and dy by a speed value, but keep in mind this may cause the bullet to skip over tiles.
In response to Anon e. Mouse
thanks i dont understand some of that but i think i can work it out and also i didnt really look at the clock time seems to go pretty slow when ur staring at a computer confused and it was almost an hour.
Well... That code right there is pretty wierd. And telling from what you said you wanted, sounds like you want something like Shadowdarke's PixelProjectiles. Coding your own pixel projectiles would take some trigonometry skillz. =p

If you have a BYONDscape sub, you could go over and take a look at his library... because I don't feel much like going into trigonometry right now.