old-bullet-move.nv
· 671 B · Text
原始文件
Playground
|#port, on move bullets, needs, @move bullets|
|#port body, on move bullets, lua|
local dt = state.dt
local bullets = state.bullets
for _, bullet in ipairs(bullets) do
if not (bullet.frozen and counters["game is paused"] > 0) then
bullet.frozen = false
bullet.x = bullet.x + math.cos(bullet.angle) * 350 * dt
bullet.y = bullet.y + math.sin(bullet.angle) * 350 * dt
local in_bounds
= -10 <= bullet.x and bullet.x <= 810
and -10 <= bullet.y and bullet.y <= 610
if not in_bounds then
bullet.deleted = true
end
end
end
1 | |#port, on move bullets, needs, @move bullets| |
2 | |#port body, on move bullets, lua| |
3 | local dt = state.dt |
4 | local bullets = state.bullets |
5 | for _, bullet in ipairs(bullets) do |
6 | if not (bullet.frozen and counters["game is paused"] > 0) then |
7 | bullet.frozen = false |
8 | bullet.x = bullet.x + math.cos(bullet.angle) * 350 * dt |
9 | bullet.y = bullet.y + math.sin(bullet.angle) * 350 * dt |
10 | local in_bounds |
11 | = -10 <= bullet.x and bullet.x <= 810 |
12 | and -10 <= bullet.y and bullet.y <= 610 |
13 | if not in_bounds then |
14 | bullet.deleted = true |
15 | end |
16 | end |
17 | end |
split-apart-bullet-move.nv
· 1.1 KiB · Text
原始文件
Playground
|#port, on move bullet, needs, @move bullet, reads, @bullet index|
|#port body, on move bullet, lua|
local dt = state.dt
local bullet = state.bullets[bullet_index]
bullet.x = bullet.x + math.cos(bullet.angle) * 350 * dt
bullet.y = bullet.y + math.sin(bullet.angle) * 350 * dt
|#port, on is bullet fronze, needs, @is bullet frozen, reads, @bullet index|
@bullet is frozen
|#port body, on is bullet frozen, lua|
counters["bullet is frozen"] = state.bullets[bullet_index].frozen and 1 or 0
|#port, on is bullet out of bounds
, needs, @is bullet out of bounds
, reads, @bullet index|
@bullet is out of bounds
|#port body, on is bullet out of bounds, lua|
local bullet = state.bullets[bullet_index]
local in_bounds
= -10 <= bullet.x and bullet.x <= 810
and -10 <= bullet.y and bullet.y <= 610
counters["@bullet is out of bounds"] = in_bounds and 1 or 0
|#port, on mark bullet for deletion
, needs, @mark bullet for deletion
, reads, @bullet index|
|#port body, on mark bullet for deletion, lua|
local bullet = state.bullets[bullet_index]
bullet.deleted = true
1 | |#port, on move bullet, needs, @move bullet, reads, @bullet index| |
2 | |#port body, on move bullet, lua| |
3 | local dt = state.dt |
4 | local bullet = state.bullets[bullet_index] |
5 | bullet.x = bullet.x + math.cos(bullet.angle) * 350 * dt |
6 | bullet.y = bullet.y + math.sin(bullet.angle) * 350 * dt |
7 | |
8 | |#port, on is bullet fronze, needs, @is bullet frozen, reads, @bullet index| |
9 | @bullet is frozen |
10 | |#port body, on is bullet frozen, lua| |
11 | counters["bullet is frozen"] = state.bullets[bullet_index].frozen and 1 or 0 |
12 | |
13 | |#port, on is bullet out of bounds |
14 | , needs, @is bullet out of bounds |
15 | , reads, @bullet index| |
16 | @bullet is out of bounds |
17 | |#port body, on is bullet out of bounds, lua| |
18 | local bullet = state.bullets[bullet_index] |
19 | local in_bounds |
20 | = -10 <= bullet.x and bullet.x <= 810 |
21 | and -10 <= bullet.y and bullet.y <= 610 |
22 | counters["@bullet is out of bounds"] = in_bounds and 1 or 0 |
23 | |
24 | |#port, on mark bullet for deletion |
25 | , needs, @mark bullet for deletion |
26 | , reads, @bullet index| |
27 | |#port body, on mark bullet for deletion, lua| |
28 | local bullet = state.bullets[bullet_index] |
29 | bullet.deleted = true |