“Straight Outta Compton,” an exultant rap-to-riches story about the group N.W.A., opens with a blast of action-film braggadocio. It’s night sometime in 1986, and the group’s future headliner and fly in the ointment, Eazy-E (Jason Mitchell), is taking care of shady business. With the camera dogging his steps so closely that you half expect him to shout “Heel,” he hotfoots it into a cramped, bleak house that has been prepped for maximum horror-film suggestiveness, with lighting as dark as a dungeon, a Welcome Wagon of tough-guy scowls and a she-devil who’s soon holding a shotgun next to a bare leg, her gat and her gam each loaded and lethal.

The director, F. Gary Gray, has a modern commercial filmmaker’s sense of space and rhythm that’s announced in this scene’s mobile camerawork, loose compositions and functional editing. Yet Eazy’s peewee pugnaciousness (he’s a shrimp who towers over villainy with his defiance) suggests that Mr. Gray has a fondness for old James Cagney movies, too. Like an original Hollywood gangster, Eazy leads with his charisma (he’s a beautiful bluffer), motor mouth and quick feet, which he puts to nimble use when chaos erupts in the house, shattering it into a cacophony of sights and sounds: shrieking sirens, screaming bullets, snarling dog. The scene defines Eazy as a great escape artist and gestures toward the breakouts soon to come, including the one that takes N.W.A. out of Compton.