Jump to content

View more

Image of the Day

WIP title screen for #DeathOfAPartisan #screenshotsaturday #gamedev https://t.co/qJNhfZCvd4
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

[C++/SDL] Rotated image & collision detection

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 selve   Members   

145
Like
0Likes
Like

Posted 27 March 2013 - 10:26 AM

Hi guys,
I want to know how to rotate an image and make a collision with another object like this:
en1ce3lkgnez.png

First collision it's just an easiest collision without rotating any image. When the ball collides with the square, the XVEL of the ball changes to
-XVEL.
Now the question for you: how to make a rotated image and collision with the ball that changes the xVelocity and yVelocity depending on the rotated image position.
 



#2 Ludus   Members   

1020
Like
1Likes
Like

Posted 27 March 2013 - 03:47 PM

SDL does not support image rotation on its own, so you'll need to either write the code yourself or use a library such as SDL_gfx. As for collision detection, the best way is probably using Verlet intergration. There's an article on it here.



#3 Lightness1024   Members   

924
Like
0Likes
Like

Posted 28 March 2013 - 10:00 AM

code for rotozooms of sdl gfx:

http://carnage-engine.git.sourceforge.net/git/gitweb.cgi?p=carnage-engine/carnage-engine;a=blob;f=carnage-engine/sdlrotozoom.cpp;h=7fd7941360eb107925426b18b7c0938eacbf58a2;hb=refs/heads/v2

 

how to compute intersections of rotated rectanges with circles or other rotated rectangles:

http://carnage-engine.git.sourceforge.net/git/gitweb.cgi?p=carnage-engine/carnage-engine;a=blob;f=carnage-engine/tools/geometry.cpp;h=d3dc4d81c53a0edd619fba84913a6d9b65ea6871;hb=refs/heads/v2






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.