Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

compfanatic

Frog Tounge....(A real stumper for you!)

This topic is 6534 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, I have a sprite for a for a frog tounge, and I set the position of it so it appears to be coming out of the frog if the player presses the space bar. The problem is, the tongue won''t move with when the frog does, so it looks like the frog lost his tounge. I set the position of the frog like this: tounge.x = frog.x + 3; tounge.y = frog.y + 23; I also did this to make it move with the frog; if (frog.x++) tounge.x++; if (frog.x--) tounge.x--; if (frog.y++) tounge.y++; if (frog.y--) tounge.y--; Do you know the answer to this problem? Please help! Thanks! -Alex

Share this post


Link to post
Share on other sites
Advertisement
YOU ARE A GENIUS! I asked everybody in the chatroom and they couldn''t help! Thank you soooo much! I guess it really didn''t stump you afterall.

-Alex

Share this post


Link to post
Share on other sites
I may always be in the chat room but 90% of the time Im AFK coding and just read the logs later on

Share this post


Link to post
Share on other sites
If your frog can turn around and face the other way you''ll need to modify the code, so that it either subtracts or adds depending on the direction of the frog.

Share this post


Link to post
Share on other sites
quote:
Original post by compfanatic

I also did this to make it move with the frog;

if (frog.x++)
tounge.x++;

if (frog.x--)
tounge.x--;

if (frog.y++)
tounge.y++;

if (frog.y--)
tounge.y--;




By the way, you can''t use checks like that in the way you think. What you''ve written above isn''t "Check if the frog moved,and if so, move the tongue too". It''s actually "Move the frog, if the new value isn''t 0, move the tongue too". But since the above code moves everything right 1 pixel, left 1 pixel, down one pixel then up one pixel, you''ll never see any effect. If you want to check if the frog moved, you''ll have to use some sort of variable to track this yourself.

Share this post


Link to post
Share on other sites
An even better piece of code wouldn''t update the tongue position every time the frog moved, but only when it needed to be drawn. For example, when the player hits the spacebar, do the following:

tongue.x = frog.x + 3;
tongue.y = frog.y + 23;

instead of doing it every frame, this will only update when it needs to.

Share this post


Link to post
Share on other sites
Ewww you have a frogs tounge in a bottle of Sprite? Im drinking Sprite right now and now i dont feel so good after reading that.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!