Barry Johnson, 67, was discovered dead at the flat in Dean Court, The Promenade, in Brierley Hill, on August 25, 2021 by his brother after failing to answer his telephone.
Jay Lee Gallier, 33, of Dudley, is on trial accused of killing Mr Johnson after entering the block as another resident opened the front door to leave shortly after 1.30pm on August 23.
Giving evidence at Wolverhampton Crown Court on Tuesday, Gallier told the jury that during August 2021 he was using heroin and cannabis.
He said he had started talking to Mr Johnson in Brierley Hill High Street and asked him if he could find a drug dealer for him.
Gallier said Mr Johnson told him where he lived and on August 22, 2021 he went to his flat to meet him and the dealer to buy cannabis.
He told the jury he also went back to the flat the following day to see the drug dealer again to buy cannabis.
Describing his movements when he got to Dean Court on August 23, he said he had waited for someone to come out the front entrance and 'slipped past them'.
He said when he reached Mr Johnson's flat, the drug dealer was already there and he helped the pensioner to unpack his shopping.
Gallier told the jury: "While he was unpacking shopping he was drinking from a bottle of whiskey.
"He took a drag of the cigarette. He's gone light-headed and he vomited.
"He fell to the wall. He was bleeding from his mouth. Blood and sick came out of his mouth."
He said he had sniggered when Mr Johnson fell over but hadn't thought he was seriously hurt.
Gallier said he then got a cannabis cigarette from the drug dealer and left the pair at the flat a short while later.
When asked how Mr Johnson was when he left the flat, Gallier answered: "He was a bit drunk but he was alright.
"He looked okay to me."
The court was told that Gallier's fingerprints were found inside the flat and Mr Johnson's blood was found on a pair of jeans at his address.
He said after leaving Mr Johnson's flat he had gone back home and between then and when he was arrested in Brierley Hill High Street on August 28, 2021, he had sat at home 'loitering around' and was 'drinking and smoking'.
When asked did he do anything that caused Mr Johnson harm in his flat, Gallier said: "No, I shared a cigarette with him."
He said the drug dealer was still at the flat when he left on August 23.
The court previously heard that John Johnson got no reply when he knocked on his brother's door on August 25, but when he turned the handle the door opened.
He said he saw his brother lying face down on the floor and thought at first that he had fallen, but saw a lot of blood and realised he was dead.
Gallier, of Salop Street, in Dudley, denies murdering Mr Johnson.
The trial continues.