Jump to content
  • Advertisement

Archived

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

farhanx

[java] Java 1.1, Collision detection and fliping image

This topic is 5178 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

hi every one|! i am facing some problem , i am at the end of my webgame but i am facing some problems. 1) i have sprites with 1 direction(left) , i want to flip them (right)on keyboard event.I know its easy in java 1.2 and so on but i want to make this game in java 1.1 so it will work on all pc without any problem. If some one know how i can do this then please guide me 2)i am using pathagoras theorm for detection, like dist=(int)Math.sqrt((PlayerX-(DogX))*(PlayerX-(DogX))+(PlayerY-200)*(PlayerY-200)); here Dog is the enemy , problem is this when dog hit and move forward and when i forward my self again before reaching to dog''s middle portion it collides....... it seems like player is hitting with dog even there is a big space between them while when both faces infront of each other then it hits without a space problem (means correctly). How can i control this any got any idea??? these problems are becoming wall for me to make a good webgame.. Thanks in advance Farhan

Share this post


Link to post
Share on other sites
Advertisement
I think you can flip images by just using drawImage(theImage,x,y,-width,height,null)

Notice the "-"!
If this doesn't work, get the pixels with a pixelGrabber, flip them, put them back into animage using a MemoryImageSource.

Wherefore is the "200" in your formula?
(By the way,it is pythagoras)

-edit:forgot a parameter in drawImage

[edited by - koroljov on June 11, 2004 8:56:39 AM]

Share this post


Link to post
Share on other sites
Thanks for reply , i am using -(width) rightnow to flip the image but its not working perfectly it changes the X position and i think its all because of it what i am facing, actully when i move left or right by using minus width it doesnt place the image on same position while X-Y is both same in left and right place....maybe thats why its not collides with other object on same position.

I dont know how i can grap these pixels can u little be more specific to guide me or any code...

Thanks to correct me about pathagoras i mean pythagoras

Share this post


Link to post
Share on other sites
Yes it changes the X position. Try this: drawImage(theImg, x+width, y, -width, null). If that doesn''t work I''ll post pixelgrabber code.

Share this post


Link to post
Share on other sites
Thanks alot man , your one line has made my whole game cool , now collision detection are going fine as how it should be , and flipping images too.

thanks champs

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!