Compare commits
No commits in common. "e19943e9f228634f5c4514c487e9b596ef826dc0" and "d17e670f2787884693f5a2bef5ce8f6236915111" have entirely different histories.
e19943e9f2
...
d17e670f27
Binary file not shown.
Before Width: | Height: | Size: 736 B |
@ -1,41 +0,0 @@
|
|||||||
local Vector3 = require "types.vector3"
|
|
||||||
local util = require "util"
|
|
||||||
|
|
||||||
local TEXTURE = "images/tongue.png"
|
|
||||||
|
|
||||||
local Feed = {
|
|
||||||
position = {},
|
|
||||||
direction = {},
|
|
||||||
velocity = {},
|
|
||||||
landed = false,
|
|
||||||
|
|
||||||
speed = 0.15,
|
|
||||||
}
|
|
||||||
|
|
||||||
Feed.__index = Feed
|
|
||||||
|
|
||||||
function Feed.new(p_position, p_direction)
|
|
||||||
local f = util.shallow_copy(Feed)
|
|
||||||
f.position = p_position:copy()
|
|
||||||
f.direction = p_direction:copy()
|
|
||||||
f.velocity = f.direction * f.speed
|
|
||||||
f.velocity.y = 0.1
|
|
||||||
|
|
||||||
return setmetatable(f, Feed)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Feed:tick(ctx)
|
|
||||||
if not self.landed then
|
|
||||||
-- gravity
|
|
||||||
self.velocity.y = math.max(self.velocity.y - 0.02, -0.2)
|
|
||||||
self.position = self.position + self.velocity
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.position.y <= 0.2 and not self.landed then
|
|
||||||
self.position.y = 0.2
|
|
||||||
self.landed = true
|
|
||||||
end
|
|
||||||
draw_billboard{position = self.position, texture = TEXTURE, size = Vector3(0.2, 0.2)}
|
|
||||||
end
|
|
||||||
|
|
||||||
return Feed
|
|
@ -1,13 +1,6 @@
|
|||||||
local player = require "classes.player"
|
local player = require "classes.player"
|
||||||
local util = require "util"
|
local util = require "util"
|
||||||
local Vector3 = require "types.vector3"
|
local Vector3 = require "types.vector3"
|
||||||
local Feed = require "classes.feed"
|
|
||||||
|
|
||||||
local feed = {}
|
|
||||||
|
|
||||||
local function create_feed(position, direction)
|
|
||||||
table.insert(feed, Feed.new(position, direction))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- called every frame, with constant delta time
|
-- called every frame, with constant delta time
|
||||||
function game_tick()
|
function game_tick()
|
||||||
@ -15,9 +8,13 @@ function game_tick()
|
|||||||
if ctx.initialization_needed then
|
if ctx.initialization_needed then
|
||||||
-- ctx.udata persists on reload
|
-- ctx.udata persists on reload
|
||||||
ctx.udata = {
|
ctx.udata = {
|
||||||
capture = false,
|
capture = false
|
||||||
}
|
}
|
||||||
player.ThrowPressed:connect(create_feed)
|
player.ThrowPressed:connect(
|
||||||
|
function (position, direction)
|
||||||
|
print(position, " ", direction)
|
||||||
|
end
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
ctx.mouse_capture = ctx.udata.capture
|
ctx.mouse_capture = ctx.udata.capture
|
||||||
@ -27,14 +24,10 @@ function game_tick()
|
|||||||
ctx.udata.capture = not ctx.udata.capture
|
ctx.udata.capture = not ctx.udata.capture
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, v in pairs(feed) do
|
|
||||||
v:tick(ctx)
|
|
||||||
end
|
|
||||||
|
|
||||||
player:tick(ctx)
|
player:tick(ctx)
|
||||||
-- draw_camera{position = Vector3(0, 1, 0), direction = Vector3.FORWARD}
|
-- draw_camera{position = Vector3(0, 1, 0), direction = Vector3.FORWARD}
|
||||||
-- draw ground
|
-- draw ground
|
||||||
local q = util.create_plane_quad(Vector3(0, 0, 0), Vector3.UP, 20)
|
local q = util.create_plane_quad(Vector3(0, 0, 0), Vector3.UP, 10)
|
||||||
local params = {
|
local params = {
|
||||||
texture = "images/measure001a.png",
|
texture = "images/measure001a.png",
|
||||||
texture_region = { x = 0, y = 0, w = 512, h = 512 },
|
texture_region = { x = 0, y = 0, w = 512, h = 512 },
|
||||||
|
@ -1,26 +1,17 @@
|
|||||||
---@class Signal
|
|
||||||
local Signal = {
|
|
||||||
_connections = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
local util = require "util"
|
local util = require "util"
|
||||||
|
|
||||||
|
local Signal = {}
|
||||||
|
|
||||||
Signal.__index = Signal
|
Signal.__index = Signal
|
||||||
|
|
||||||
---Connects f to this signal. When the signal is emmitted, this function will be called.
|
|
||||||
---@param f function
|
|
||||||
function Signal:connect(f)
|
function Signal:connect(f)
|
||||||
util.list_insert_once(self._connections, f)
|
util.list_insert_once(self._connections, f)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Disconnects f from this signal.
|
|
||||||
---@param f function
|
|
||||||
function Signal:disconnect(f)
|
function Signal:disconnect(f)
|
||||||
util.list_remove_value(self._connections, f)
|
util.list_remove_value(self._connections, f)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Emits the signal, calling the connecting functions with the provided params.
|
|
||||||
---@param ... any
|
|
||||||
function Signal:emit(...)
|
function Signal:emit(...)
|
||||||
-- don't care about order
|
-- don't care about order
|
||||||
for _, v in pairs(self._connections) do
|
for _, v in pairs(self._connections) do
|
||||||
@ -28,8 +19,6 @@ function Signal:emit(...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Constructs a new signal.
|
|
||||||
---@return Signal
|
|
||||||
function Signal.new()
|
function Signal.new()
|
||||||
local s = {
|
local s = {
|
||||||
_connections = {},
|
_connections = {},
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
--- @field x number
|
--- @field x number
|
||||||
--- @field y number
|
--- @field y number
|
||||||
--- @field z number
|
--- @field z number
|
||||||
--- @alias vectorlike number[] | Vector3
|
--- @alias vectorlike table | Vector3
|
||||||
local Vector3 = {
|
local Vector3 = {
|
||||||
x = 0,
|
x = 0,
|
||||||
y = 0,
|
y = 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user