diff options
author | Fernando Carmona Varo <ferkiwi@gmail.com> | 2015-11-07 11:13:47 +0100 |
---|---|---|
committer | Fernando Carmona Varo <ferkiwi@gmail.com> | 2015-11-07 11:13:47 +0100 |
commit | e57a87c26466b430557f853975fbc2d0e9f17765 (patch) | |
tree | a84277c0ff085a95309c2dab70f8c35d11048127 /pong/ball.lua | |
parent | 2c3229eb8360276e2b502c2383825277d9764b8e (diff) |
Remove nibbles and pong from master branch
Diffstat (limited to 'pong/ball.lua')
-rwxr-xr-x | pong/ball.lua | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/pong/ball.lua b/pong/ball.lua deleted file mode 100755 index 91c48f3..0000000 --- a/pong/ball.lua +++ /dev/null @@ -1,108 +0,0 @@ - - - - -minetest.register_entity("pong:ball", { - hp_max = 1, - physical = false, - collide_with_objects = false, - visual = "cube", - visual_size = {x = 0.25, y = 0.25}, - textures = { - "default_cloud.png", "default_cloud.png", "default_cloud.png", - "default_cloud.png", "default_cloud.png", "default_cloud.png", - }, - velocity = {x=math.random(-1,1), y=0, z=math.random(-1,1)}, - direction = {x=1, y=0, z=1}, - collisionbox = {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25}, - is_visible = true, - automatic_rotate = false, - makes_footstep_sound = false, - speed = 4, - - update_velocity = function(self, direction) - if not self.speed then self.speed = 0 end - - if not direction then - local yaw = self.object:getyaw() - self.direction = {x= -math.sin(yaw), y=0, z=math.cos(yaw)} - else - self.direction = direction - end - self.object:setvelocity(vector.multiply(self.direction, self.speed)) - end, - - - on_player_collision = function(self, player) - local yaw = self.object:getyaw() - - local pos = self.object:getpos() - local playerpos = player:getpos() - - local playerdir = vector.direction(playerpos,pos) - playerdir.y = 0 - - local v = self.object:getvelocity() - if v.x < 1 and v.z < 1 then - self:update_velocity(playerdir) - return - end - - --[[ - if math.sign(playerdir.x) ~= math.sign(self.direction.x) then - self.direction.x = -self.direction.x - self:update_velocity(self.direction) - else - self.direction.z = -self.direction.z - self:update_velocity(self.direction) - end - --]] - - if math.sign(playerdir.x) ~= math.sign(self.direction.x) then - self.object:setyaw((yaw + 90)%360) - elseif pos.z < playerpos.z then - self.object:setyaw((yaw - 90)%360) - end - self:update_velocity() - end, - - on_step = function(self, dtime) - -- every 0.2 seconds - self.timer = (self.timer or 0) + dtime - if self.timer < 0.2 then return end - self.timer = 0 - - local pos = self.object:getpos() - local p = vector.add(pos, self.direction) - if p.x <= self.minp.x or p.x >= self.maxp.x then - self.direction.x = -self.direction.x - self:update_velocity(self.direction) - elseif p.z <= self.minp.z or p.z >= self.maxp.z then - self.direction.z = -self.direction.z - self:update_velocity(self.direction) - else - for _,obj in pairs(minetest.get_objects_inside_radius(pos,1)) do - if obj:is_player() == true then - self:on_player_collision(obj) - break - end - end - end - end, - - -- This function should return the saved state of the entity in a string - get_staticdata = function(self) - return minetest.serialize({minp = self.minp, maxp = self.maxp}) - end, - - -- This function should load the saved state of the entity from a string - on_activate = function(self, staticdata) - self.object:set_armor_groups({immortal=1}) - self.direction = vector.normalize(self.object:getvelocity()) - if staticdata and staticdata ~= "" then - staticdata = minetest.deserialize(staticdata) - self.minp = staticdata.minp - self.maxp = staticdata.maxp - end - end -}) |