DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 16th April 2012
xmorg xmorg is offline
Real Name: Tim Cooper
Fdisk Soldier
 
Join Date: Sep 2010
Location: San Diego
Posts: 56
Question Its a math problem isnt it?

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
Reply With Quote
 

Tags
c programming, sdl

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Boot problem. Geometry problem? gulanito FreeBSD Installation and Upgrading 0 3rd July 2009 03:03 AM
Math resources ephemera Off-Topic 16 3rd April 2009 12:06 PM
My D-Link DFE530TX ethernet adapter isnt found. Help! Quaxo OpenBSD Installation and Upgrading 15 10th February 2009 12:23 AM


All times are GMT. The time now is 07:05 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick