mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-26 18:21:04 +00:00
Sound refactor and improvements (#12764)
This commit is contained in:
parent
8e1af25738
commit
edcbfa31c9
52 changed files with 2802 additions and 1211 deletions
31
games/devtest/mods/soundstuff/racecar.lua
Normal file
31
games/devtest/mods/soundstuff/racecar.lua
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
local drive_speed = 20
|
||||
local drive_distance = 30
|
||||
|
||||
minetest.register_entity("soundstuff:racecar", {
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
visual = "upright_sprite",
|
||||
visual_size = {x = 1, y = 1, z = 1},
|
||||
textures = {"soundstuff_racecar.png", "soundstuff_racecar.png^[transformFX"},
|
||||
static_save = false,
|
||||
},
|
||||
|
||||
on_activate = function(self, _staticdata, _dtime_s)
|
||||
self.min_x = self.object:get_pos().x - drive_distance * 0.5
|
||||
self.max_x = self.min_x + drive_distance
|
||||
self.vel = vector.new(drive_speed, 0, 0)
|
||||
end,
|
||||
|
||||
on_step = function(self, _dtime, _moveresult)
|
||||
local pos = self.object:get_pos()
|
||||
if pos.x < self.min_x then
|
||||
self.vel = vector.new(drive_speed, 0, 0)
|
||||
elseif pos.x > self.max_x then
|
||||
self.vel = vector.new(-drive_speed, 0, 0)
|
||||
end
|
||||
self.object:set_velocity(self.vel)
|
||||
end,
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue