Doing collision detection for rotated rectangles is a lot more challenging than for axis-aligned rectangles, but it's not super hard:
The basic idea is that two rectangles intersect if and only if you cannot draw a straight line between them. This sounds quite obvious and is in fact true for any convex shape.
However, we can make things a bit simpler because we're dealing with rectangles: One of these potential dividing lines will be parallel to one of the sides of the rectangle. That leaves 4 possible axis (two for each rectangle). We only know that the line is parallel, not exactly where it is, but there's a trick:
For each line direction, let's create another line perpendicular to that. Then, we project both rectangles on that line. Now we can check if the rectangles overlap.
If they do, we don't know anything, but if they don't, we know that the rectangles definitively don't intersect.
Once we tried all four possible directions and haven't found a separating axis, we know that the rectangles intersect.
The only challenging part is projecting the rectangles onto the line. This is done using the dot product, but you'll probably find better explanations elsewhere. The basic idea is to turn every corner of the rectangles into a number that represents how far up the line it is. Then take the minimum and maximum number for each rectangle and check whether these areas overlap.
I'm sorry I didn't provide any code, but it should be possible to follow these steps to get a working implementations.
I based my answer on this (where you can also find pictures):
https://www.gamedev.net/articles/programming/general-and-gameplay-programming/2d-rotated-rectangle-collision-r2604