It is, of course, trivial to put a fixed collection of adverts into your code. The trouble comes if you want to sell eyeballs and have the ads change. Then the code has to go talk over the network to get new adds.
Many people would have a name for this: adware. If people find you making network connections behind their back, as it were, they are likely to break out some more negative terms.
However, if you are completely open and honest about it when you offer the code for download, then your conscience might be clear.
Practically, you need to have code that makes a network connection to some site of yours, pulls the ad content, and displays it in some sort of annoying popup.