Should I use multiple classes for game?

前端 未结 5 1424
悲&欢浪女
悲&欢浪女 2020-12-14 23:24

I\'m considering making a text-based RPG-type program in PHP as both a holiday project and a chance to learn more about PHP and OOP. (Maybe not the best choice in language,

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-14 23:48

    You could create an abstract class, say Monster, and then extend that class for each of the different types of monsters. So

    
    

    edit Orc would extend Monster and then inherit the attribute $health and the function attack().

提交回复
热议问题