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.
A jury at Wolverhampton Crown Court heard how that the victim, who lived alone, was discovered two days after the attack which left him with multiple fractures including a broken nose and bruises.
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.
Prosecuting barrister Mr Kevin Hegarty KC told the jury that the alleged victim was murdered having only moments before returned from a shopping trip to Brierley Hill. He said some of the movements of the victim and the defendant on that date had been caught on camera.
Mr Hegarty said: "Barry Johnson lived alone. He was 67 years old. On August 23, 2021 shortly after 1pm he returned to the building. He had done some shopping. He had been to Asda. He was seen to come through the front door, across the lobby and make his way up to his flat.
"About 40 minutes later at about 1.45pm Mr Gallier appeared at the front door to Dean Court. He could not get in. He did not live there.
"He was seen hanging around the building.
"Eventually when somebody else was leaving they let him in and as he crossed the lobby there was an oval-shaped table where people who lived in Dean Court would put things they no longer wanted for others to take.
"Among the things was a pair of ladies' slippers. He then walked further into the lobby to the lift. There was another person in the lift who noticed him. It appeared to them that Gallier was perhaps uncertain where he was going.
"He later reappeared in the lift. He was no longer carrying the slippers. About that time Barry Johnson was in his flat, but by this time he was either dead or dying.
"He had been attacked in his own home. He was not discovered until two days later when his own brother John had been making a number of phone calls. They had made arrangements to go to shop. He was ringing and got no answer. So at about 6pm he went round to check on him."
Mr Hegarty said that John Johnson got no reply when he knocked on the door, but when he turned the handle the door opened. He said he saw his brother on the floor.
"He was lying face down and John at first thought Barry might have fallen. He saw a lot of blood and realised that his brother was dead," Mr Hegarty added.
He said police investigations led them to arrest the defendant, who claimed that he had visited the alleged victim's flat to smoke cannabis. Gallier, of Salop Street, in Dudley, denies murdering Mr Johnson.
The trial continues.