I must have been sleeping in word problem class. Problem: I am trying to move a sprite to the mouse click coordinates with SDL.
Every iteration I use this function (if game mode is hero moving)
Code:
draw_sprites(gr, player, pdirection, ???, ??? ); //<----
void draw_sprites(GameRes *gr, Actor *a, int direction, int movex, int movey) {
//GameRes*gr is a pointer to struct holding lots of game resources
//int direction is only being used for which frame(s) our sprite should be displaying
//Actor *a points to the player sprite, only x/y relevant
gr->rcSprite->x += movex; //<-----
gr->rcSprite->y += movey;
//A lot of sprite frame code below
Now every time I click the mouse I get a x and y from the mouse click, lets just say mousecx, and mousecy I also have and x and y from the player sprites rectangle(rcSprite->x and rcSprite->y) Now, how do I move my rect to the mouse click coordinates? I need it to move incrementally every iteration until it reaches its destination. Maybe its Geometry? CPCTE???
I put my code up on my site
http://www.cooperlabs.net/packages/sdldf.tar.gz