mardi 5 janvier 2016

moving a object gradually in a random direction in a c# windows form application

I am making a basic security purpose application but I am doing it in steps to make things simpler for myself.

I'm having difficulty attempting to get an object, in a VS C# windows form application, to move in random directions (left, down, up, right) for a random length of pixels (generated by a random number generator) but gradually, (ideally, pixel by pixel) so it appears as if the object is moving almost independently, much like an enemy NPC in a top-down 2D game. I'm not attempting to make a game, but the principle is the same.

I've began with generating the decision whether the object will first move 'left or right' and 'up or down' (obviously can only move in one direction along each of the axis') or neither of them or move in 2 directions along both axis. Getting the object to move to a new random location was easy, but I'm trying to get the object to move progressively to the new position instead of instantly appearing at the new location.

any helpful code structures would be greatly appreciated for the future but a specific solution would be preferred as I am in need of specifics for academic purposes.




Aucun commentaire:

Enregistrer un commentaire