Can you boot from a system CD or DVD? If so that is an indication that the Logic board is OK and you likely have a software problem or hard drive issue.
Will it boot in Safe Mode?
Try safe mode if your Mac doesn't finish starting up - Apple Support
If the computer has been stored off wall power for months or longer, its internal backup battery (the "PRAM" battery) is surely dead and that can affect startup. Replacing the PRAM battery on early G5 iMacs is relatively easy:
https://www.ifixit.com/Guide/iMac+G5+17-Inch+Model+A1058+PRAM+Battery+Replacemen t/976
Replacing it on later G5 iMacs requires a major teardown:
https://www.ifixit.com/Guide/iMac+G5+17-Inch+Model+A1144+PRAM+Battery+Replacemen t/953
I think, as yours is a 2004 model, it is one of the easy ones.