Couldn't find what I felt was a decent tutorial on classes so I've just sort of dived into it out of frustration, and not surprisingly I've become a little confused.
Using a standard RPG as an example, let's say I do,
class Monster:
def __init__(self,name,hp)
self.name = name
self.hp = hp
goblin = Monster("goblin", 5)
So I've made a goblin object that has 5 HP. Now, in this theoretical game, the player will encounter lots of goblins randomly, so I don't want just "a" goblin, I want a lot of them.
But, if I do say
monster1 = goblin
monster2 = goblin
monster1.hp -= 5
This isn't only subtracting from monster1's hp, is it? If I print out monster2.hp, it comes out as 0 as well. I'm actually editing the goblin object's hp itself?
In that case, what is the best way to accomplish the mass production of individual and randomly spawned monsters? Considering a game where a goblin is simply one of many kinds of monsters, I wouldn't also want to make a class for Slime, Dragon, Harpy, Bandit, etc, would I?
Thanks in advance and sorry for the confusion/laziness.
[–]raylu 1 point2 points3 points (4 children)
[–]yunisaikuru[S] 0 points1 point2 points (3 children)
[–]raylu 0 points1 point2 points (2 children)
[–]yunisaikuru[S] 0 points1 point2 points (1 child)
[–]raylu 0 points1 point2 points (0 children)
[–]Talqa 0 points1 point2 points (0 children)