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

Started by
1 comment, last by Lightness1024 11 years ago

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.

Advertisement

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.

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

This topic is closed to new replies.

Advertisement