mirror of
https://github.com/bvanroll/Love2d.git
synced 2025-08-30 04:22:45 +00:00
organizing folders
This commit is contained in:
55
HomeMadeLibs/Characters.lua
Normal file
55
HomeMadeLibs/Characters.lua
Normal file
@@ -0,0 +1,55 @@
|
||||
player = {
|
||||
properties = {
|
||||
name = "PlayerName",
|
||||
sprite = "NaN"
|
||||
},
|
||||
size = {
|
||||
width = 5,
|
||||
height = 10
|
||||
},
|
||||
physics = {
|
||||
gravity = false,
|
||||
rate = 0.1,
|
||||
grate = 0.98,
|
||||
pos = {
|
||||
x = 50,
|
||||
y = 50,
|
||||
z = 1
|
||||
},
|
||||
vel = {
|
||||
x = 1,
|
||||
y = 1,
|
||||
z = 1
|
||||
},
|
||||
Addvel = function(self, vx, vy, vz)
|
||||
self.vel.x = self.vel.x + vx
|
||||
self.vel.y = self.vel.y + vy
|
||||
self.vel.z = self.vel.z + vz
|
||||
end,
|
||||
Stopvel = function(self)
|
||||
self.vel.x = 1
|
||||
self.vel.y = 1
|
||||
self.vel.z = 1
|
||||
end,
|
||||
Update = function(self)
|
||||
self.pos.x = self.pos.x * self.vel.x
|
||||
self.pos.y = self.pos.y * self.vel.y
|
||||
self.pos.z = self.pos.z * self.vel.z
|
||||
if(self.gravity) then self.vel.y = self.vel.y + grate end
|
||||
if(self.vel.x < 1) then self.vel.x = self.vel.x + self.rate end
|
||||
if(self.vel.y < 1) then self.vel.y = self.vel.y + self.rate end
|
||||
if(self.vel.z < 1) then self.vel.z = self.vel.z + self.rate end
|
||||
if(self.vel.x > 1) then self.vel.x = self.vel.x - self.rate end
|
||||
if(self.vel.y > 1) then self.vel.y = self.vel.y - self.rate end
|
||||
if(self.vel.z > 1) then self.vel.z = self.vel.z - self.rate end
|
||||
end,
|
||||
SetPosition = function(self, x, y, z)
|
||||
self.pos.x = x
|
||||
self.pos.y = y
|
||||
self.pos.z = z
|
||||
self.vel.x = 1
|
||||
self.vel.y = 1
|
||||
self.vel.z = 1
|
||||
end
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user