Initial commit
commit
07e5b55f37
|
@ -0,0 +1,7 @@
|
|||
## Generic ignorable patterns and files
|
||||
*~
|
||||
.*.swp
|
||||
*bak*
|
||||
tags
|
||||
*.vim
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
Hovercraft for Minetest [hovercraft]
|
||||
====================================
|
||||
|
||||
Source Code: Copyright (C) 2013 Stuart Jones - LGPL
|
||||
|
||||
Tetxures: Copyright (C) 2013 Stuart Jones - CC-BY-SA
|
||||
|
||||
Models: Copyright (C) 2013 Stuart Jones - CC-BY-SA
|
||||
|
||||
Sounds: freesound.org
|
||||
|
||||
Rocket Boost Engine Loop by qubodup - CC0
|
||||
CARTOON-BING-LOW by kantouth - CC-BY-3.0
|
||||
All other sounds: Copyright Stuart Jones - CC-BY-SA
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
Hovercraft for Minetest [hovercraft]
|
||||
====================================
|
||||
|
||||
A fun alternative mode of transport for Minetest.
|
||||
|
||||
Controls
|
||||
========
|
||||
|
||||
Forward (W) Thrust
|
||||
Jump (Space) Jump
|
||||
Mouse Move Rotate
|
||||
|
||||
Know Issues
|
||||
===========
|
||||
|
||||
'Bouncing' into thin air: This can simply be the result of server lag (even in singleplayer).
|
||||
The client and server are out of sync. Solution, just be patient and allow the environment
|
||||
to full load before preceding.
|
||||
|
||||
Problems with bouncing in air and generally getting stuck, being pulled underwater and
|
||||
all manner of other weirdness can also be caused by a rather nasty entity duplication bug in minetest itself.
|
||||
The only solution here is to track down and remove any duplicate entities or by running /clearobjects
|
||||
|
||||
Entity Duplication: See above. This usually occurs when you move a given distance from where the entity
|
||||
was originally placed. The only solution right now is to restrict the hovercraft to a certain area.
|
||||
For example, create a sunken race track the hovercraft cannot physically escape from.
|
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1,166 @@
|
|||
hover = {}
|
||||
|
||||
function hover:register_hovercraft(name, def)
|
||||
minetest.register_entity(name, {
|
||||
physical = true,
|
||||
collisionbox = {-0.8,0,-0.8, 0.8,1.2,0.8},
|
||||
visual = "mesh",
|
||||
mesh = "hovercraft.x",
|
||||
textures = def.textures,
|
||||
max_speed = def.max_speed,
|
||||
acceleration = def.acceleration,
|
||||
deceleration = def.deceleration,
|
||||
jump_velocity = def.jump_velocity,
|
||||
fall_velocity = def.fall_velocity,
|
||||
player = nil,
|
||||
sound = nil,
|
||||
thrust = 0,
|
||||
velocity = {x=0, y=0, z=0},
|
||||
last_pos = {x=0, y=0, z=0},
|
||||
timer = 0,
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
self.object:set_animation({x=0, y=24}, 30)
|
||||
end,
|
||||
on_rightclick = function(self, clicker)
|
||||
if not clicker or not clicker:is_player() then
|
||||
return
|
||||
end
|
||||
local pos = self.object:getpos()
|
||||
if self.player and clicker == self.player then
|
||||
if self.sound then
|
||||
minetest.sound_stop(self.sound)
|
||||
minetest.sound_play("hovercraft_thrust_fade", {object = self.object})
|
||||
self.sound = nil
|
||||
end
|
||||
self.thrust = 0
|
||||
self.player = nil
|
||||
self.object:set_animation({x=0, y=24}, 30)
|
||||
clicker:set_animation({x=0, y=0})
|
||||
clicker:set_detach()
|
||||
elseif not self.player then
|
||||
self.player = clicker
|
||||
clicker:set_attach(self.object, "", {x=-2,y=16.5,z=0}, {x=0,y=90,z=0})
|
||||
clicker:set_animation({x=81, y=81})
|
||||
local yaw = clicker:get_look_yaw()
|
||||
self.object:setyaw(yaw)
|
||||
self.yaw = yaw
|
||||
pos.y = pos.y + 0.5
|
||||
minetest.sound_play("hovercraft_jump", {object = self.object})
|
||||
self.object:set_animation({x=0, y=0})
|
||||
end
|
||||
self.last_pos = pos
|
||||
self.object:setpos(pos)
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
self.timer = self.timer + dtime
|
||||
if self.player then
|
||||
local yaw = self.player:get_look_yaw()
|
||||
if not yaw then
|
||||
return
|
||||
end
|
||||
self.object:setyaw(yaw)
|
||||
local ctrl = self.player:get_player_control()
|
||||
if ctrl.up then
|
||||
if self.thrust < self.max_speed then
|
||||
self.thrust = self.thrust + self.acceleration
|
||||
end
|
||||
local velocity = hover:get_velocity(self.thrust, self.velocity.y, 0, yaw)
|
||||
if velocity.x < self.velocity.x then
|
||||
self.velocity.x = self.velocity.x - self.acceleration
|
||||
elseif velocity.x > self.velocity.x then
|
||||
self.velocity.x = self.velocity.x + self.acceleration
|
||||
end
|
||||
if velocity.z < self.velocity.z then
|
||||
self.velocity.z = self.velocity.z - self.acceleration
|
||||
elseif velocity.z > self.velocity.z then
|
||||
self.velocity.z = self.velocity.z + self.acceleration
|
||||
end
|
||||
if not self.sound then
|
||||
self.object:set_animation({x=25, y=75}, 30)
|
||||
self.sound = minetest.sound_play("hovercraft_thrust_loop", {
|
||||
object = self.object,
|
||||
loop = true,
|
||||
})
|
||||
end
|
||||
elseif self.thrust > 0 then
|
||||
self.thrust = self.thrust - 0.1
|
||||
if self.sound then
|
||||
minetest.sound_stop(self.sound)
|
||||
minetest.sound_play("hovercraft_thrust_fade", {object = self.object})
|
||||
self.sound = nil
|
||||
end
|
||||
else
|
||||
self.object:set_animation({x=0, y=0})
|
||||
self.thrust = 0
|
||||
end
|
||||
if ctrl.jump and self.velocity.y == 0 then
|
||||
self.velocity.y = self.jump_velocity
|
||||
self.timer = 0
|
||||
minetest.sound_play("hovercraft_jump", {object = self.object})
|
||||
end
|
||||
if ctrl.sneak then
|
||||
self.player:set_animation({x=81, y=81})
|
||||
end
|
||||
end
|
||||
local pos = self.object:getpos()
|
||||
if self.timer > 0.5 then
|
||||
local node = minetest.env:get_node({x=pos.x, y=pos.y-0.5, z=pos.z})
|
||||
if node.name == "air" or node.name == "ignore" then
|
||||
self.velocity.y = 0 - self.fall_velocity
|
||||
else
|
||||
self.velocity.y = 0
|
||||
pos.y = math.floor(pos.y) + 0.5
|
||||
self.object:setpos(pos)
|
||||
end
|
||||
self.timer = 0
|
||||
end
|
||||
if self.last_pos.x == pos.x and math.abs(self.velocity.x) > 0.5 then
|
||||
self.velocity.x = self.velocity.x * -0.8
|
||||
self.thrust = 0
|
||||
minetest.sound_play("hovercraft_bounce", {object = self.object})
|
||||
end
|
||||
if self.last_pos.z == pos.z and math.abs(self.velocity.z) > 0.5 then
|
||||
self.velocity.z = self.velocity.z * -0.8
|
||||
self.thrust = 0
|
||||
minetest.sound_play("hovercraft_bounce", {object = self.object})
|
||||
end
|
||||
self.last_pos = pos
|
||||
if self.velocity.x > self.deceleration then
|
||||
self.velocity.x = self.velocity.x - self.deceleration
|
||||
elseif self.velocity.x < 0 - self.deceleration then
|
||||
self.velocity.x = self.velocity.x + self.deceleration
|
||||
else
|
||||
self.velocity.x = 0
|
||||
end
|
||||
if self.velocity.z > self.deceleration then
|
||||
self.velocity.z = self.velocity.z - self.deceleration
|
||||
elseif self.velocity.z < 0 - self.deceleration then
|
||||
self.velocity.z = self.velocity.z + self.deceleration
|
||||
else
|
||||
self.velocity.z = 0
|
||||
end
|
||||
self.object:setvelocity(self.velocity)
|
||||
end,
|
||||
})
|
||||
minetest.register_craftitem(name, {
|
||||
description = def.description,
|
||||
inventory_image = def.inventory_image,
|
||||
liquids_pointable = true,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
pointed_thing.under.y = pointed_thing.under.y + 0.5
|
||||
minetest.env:add_entity(pointed_thing.under, name)
|
||||
itemstack:take_item()
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
function hover:get_velocity(vx, vy, vz, yaw)
|
||||
local x = math.cos(yaw)*vx+math.cos(math.pi/2+yaw)*vz
|
||||
local z = math.sin(yaw)*vx+math.sin(math.pi/2+yaw)*vz
|
||||
return {x=x, y=vy, z=z}
|
||||
end
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
dofile(minetest.get_modpath("hovercraft").."/hover.lua")
|
||||
|
||||
hover:register_hovercraft("hovercraft:hover_red" ,{
|
||||
description = "Red Hovercraft",
|
||||
textures = {"hovercraft_red.png"},
|
||||
inventory_image = "hovercraft_red_inv.png",
|
||||
max_speed = 10,
|
||||
acceleration = 0.25,
|
||||
deceleration = 0.025,
|
||||
jump_velocity = 4.0,
|
||||
fall_velocity = 1.0,
|
||||
})
|
||||
|
||||
hover:register_hovercraft("hovercraft:hover_blue" ,{
|
||||
description = "Blue Hovercraft",
|
||||
textures = {"hovercraft_blue.png"},
|
||||
inventory_image = "hovercraft_blue_inv.png",
|
||||
max_speed = 12,
|
||||
acceleration = 0.25,
|
||||
deceleration = 0.05,
|
||||
jump_velocity = 4,
|
||||
fall_velocity = 1,
|
||||
})
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 905 B |
Binary file not shown.
After Width: | Height: | Size: 244 B |
Binary file not shown.
After Width: | Height: | Size: 889 B |
Binary file not shown.
After Width: | Height: | Size: 227 B |
Loading…
Reference in New Issue