I'm working on the foundation of a CS50 lecture, but there are a couple of things regarding the HUMP class system that I just don't understand, and I haven't been able to find answers on the forum nor anywhere else.
I've created a three classes (Player.lua, Enemy.lua, Orb.lua) and I'm at a point where I would like the Enemy to cause Damage to the player if they are the same position on the x-axis.
I've made a function in Player.lua called
Code: Select all
Player = Class{}
function Player:init(map)
-- Here I load in all the attributes of the player.
self.map = map -- I'll come back to this line
end
function Player:update(dt)
-- Here I update the state, animations, and update positions as well as create a function that looks like:
function takeDamage()
self.health = self.health - 1
return self.health
end
end
Furthermore, I've been experimenting a little and I'm not quite sure what the self.map = map does. My guess is that it takes the parameter and creates a variable with it.
It would be much appreciated if you could explain it to me like I was 5 years old. Any other sources would also be greatly appreciated. I just don't think I'e quite grasped the concept yet and I kind of feel like I'm cheating myself a little using HUMP, yet I'm not totally sure what it actually provides me with.
I've attached Player.lua. It looks very similar to Enemy.lua. Thank you!