-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce2933d
commit 0684ffe
Showing
46 changed files
with
703 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,113 @@ | ||
export * from "./src/runtime/Game"; | ||
export * from "./src/runtime/IsometricGame"; | ||
export * from "./src/runtime/IsometricWorld"; | ||
export * from "./src/runtime/StateBuffer"; | ||
export * from "./src/runtime/World"; | ||
export * from "./src/graphics/Camera"; | ||
export * from "./src/graphics/Renderer"; | ||
export * from "./src/ecs/Component"; | ||
export * from "./src/ecs/System"; | ||
export * from "./src/ecs/Entity"; | ||
export * from "./src/ecs/systems/core/ActionSystem"; | ||
export * from "./src/ecs/systems/core/CommandSystem"; | ||
export * from "./src/ecs/systems/core/ControlSystem"; | ||
export * from "./src/ecs/systems/core/CooldownSystem"; | ||
export * from "./src/ecs/systems/core/DamageSystem"; | ||
export * from "./src/ecs/systems/core/EffectsSystem"; | ||
export * from "./src/ecs/systems/core/ExpiresSystem"; | ||
export * from "./src/ecs/systems/core/FogSystem"; | ||
export * from "./src/ecs/systems/core/NPCSystem"; | ||
export * from "./src/ecs/systems/core/PhysicsSystem"; | ||
export * from "./src/ecs/systems/core/SightSystem"; | ||
export * from "./src/ecs/systems/gameplay/ZomiSpawnSystem"; | ||
export * from "./src/ecs/systems/gameplay/GunSystem"; | ||
export * from "./src/ecs/systems/gameplay/SkellySpawnSystem"; | ||
export * from "./src/ecs/systems/net/NetClientSystem"; | ||
export * from "./src/ecs/systems/net/NetServerSystem"; | ||
export * from "./src/net/Client"; | ||
export * from "./src/net/DelaySyncer"; | ||
export * from "./src/net/NetProtocol"; | ||
export * from "./src/ecs/systems/ui/ChatBubbleSystem"; | ||
export * from "./src/ecs/systems/ui/ClickableSystem"; | ||
export * from "./src/ecs/systems/ui/DebugSystem"; | ||
export * from "./src/ecs/systems/ui/HealthBarSystem"; | ||
export * from "./src/ecs/systems/ui/InputSystem"; | ||
export * from "./src/ecs/systems/ui/NametagSystem"; | ||
export * from "./src/ecs/systems/ui/RenderSystem"; | ||
export * from "./src/ecs/entities/buttons/ConnectButton"; | ||
export * from "./src/ecs/entities/buttons/FullscreenButton"; | ||
export * from "./src/ecs/entities/buttons/HomeButton"; | ||
export * from "./src/ecs/entities/buttons/ShopButton"; | ||
export * from "./src/ecs/entities/characters/Skelly"; | ||
export * from "./src/ecs/entities/characters/Spaceship"; | ||
export * from "./src/ecs/entities/characters/Zomi"; | ||
export * from "./src/ecs/entities/players/Noob"; | ||
export * from "./src/ecs/entities/SystemEntity"; | ||
export * from "./src/ecs/entities/objects/Ball"; | ||
export * from "./src/ecs/entities/objects/InviteStone"; | ||
export * from "./src/ecs/entities/objects/Goal"; | ||
export * from "./src/ecs/entities/objects/Portal"; | ||
export * from "./src/ecs/entities/objects/Projectile"; | ||
export * from "./src/ecs/entities/terrain/Background"; | ||
export * from "./src/ecs/entities/terrain/FloorTiles"; | ||
export * from "./src/ecs/entities/terrain/LineWall"; | ||
export * from "./src/ecs/entities/ui/HUD"; | ||
export * from "./src/ecs/entities/ui/Chat"; | ||
export * from "./src/ecs/entities/ui/Cursor"; | ||
export * from "./src/ecs/entities/ui/FpsText"; | ||
export * from "./src/ecs/entities/ui/Joystick"; | ||
export * from "./src/ecs/renderables/Button"; | ||
export * from "./src/ecs/renderables/DebugBounds"; | ||
export * from "./src/ecs/renderables/HealthBar"; | ||
export * from "./src/ecs/entities/ui/Shop"; | ||
export * from "./src/ecs/entities/ui/Minimap"; | ||
export * from "./src/ecs/entities/ui/Scoreboard"; | ||
export * from "./src/ecs/entities/ui/ScorePanel"; | ||
export * from "./src/ecs/renderables/TextBox"; | ||
export * from "./src/ecs/commands/DebugCommand"; | ||
export * from "./src/ecs/commands/GameCommand"; | ||
export * from "./src/ecs/commands/SpawnCommand"; | ||
export * from "./src/ecs/components/Actions"; | ||
export * from "./src/ecs/components/Clickable"; | ||
export * from "./src/ecs/components/Collider"; | ||
export * from "./src/ecs/components/Effects"; | ||
export * from "./src/ecs/components/Data"; | ||
export * from "./src/ecs/components/Debug"; | ||
export * from "./src/ecs/components/Expires"; | ||
export * from "./src/ecs/components/Gun"; | ||
export * from "./src/ecs/components/Health"; | ||
export * from "./src/ecs/components/Input"; | ||
export * from "./src/ecs/components/Networked"; | ||
export * from "./src/ecs/components/NPC"; | ||
export * from "./src/ecs/components/Player"; | ||
export * from "./src/ecs/components/Position"; | ||
export * from "./src/ecs/components/Renderable"; | ||
export * from "./src/ecs/components/Team"; | ||
export * from "./src/ecs/components/Money"; | ||
export * from "./src/ecs/actions/abilities/Boost"; | ||
export * from "./src/ecs/actions/PlayerActions"; | ||
export * from "./src/ecs/actions/ToggleVisible"; | ||
export * from "./src/ecs/actions/abilities/IceWall"; | ||
export * from "./src/ecs/actions/attacks/Reload"; | ||
export * from "./src/ecs/actions/attacks/Shoot"; | ||
export * from "./src/ecs/actions/attacks/ZomiAttack"; | ||
export * from "./src/ecs/actions/movement/Point"; | ||
export * from "./src/ecs/actions/movement/Chase"; | ||
export * from "./src/ecs/actions/movement/Head"; | ||
export * from "./src/ecs/actions/movement/Move"; | ||
export * from "./src/ecs/actions/movement/WASDInputMap"; | ||
export * from "./src/ecs/actions/movement/VehicleMovement"; | ||
export * from "./src/ecs/components/Controlling"; | ||
export * from "./src/sound/Sounds"; | ||
export * from "./src/utils/MathUtils"; | ||
export * from "./src/utils/PixiUtils"; | ||
export * from "./src/utils/RapierUtils"; | ||
export * from "./src/utils/StringUtils"; | ||
export * from "./src/utils/SystemUtils"; | ||
export * from "./src/runtime/Game" | ||
export * from "./src/runtime/IsometricGame" | ||
export * from "./src/runtime/IsometricWorld" | ||
export * from "./src/runtime/StateBuffer" | ||
export * from "./src/runtime/World" | ||
export * from "./src/graphics/Camera" | ||
export * from "./src/graphics/Renderer" | ||
export * from "./src/ecs/Component" | ||
export * from "./src/ecs/System" | ||
export * from "./src/ecs/Entity" | ||
export * from "./src/ecs/systems/core/ActionSystem" | ||
export * from "./src/ecs/systems/core/CommandSystem" | ||
export * from "./src/ecs/systems/core/ControlSystem" | ||
export * from "./src/ecs/systems/core/CooldownSystem" | ||
export * from "./src/ecs/systems/core/DamageSystem" | ||
export * from "./src/ecs/systems/core/EffectsSystem" | ||
export * from "./src/ecs/systems/core/ExpiresSystem" | ||
export * from "./src/ecs/systems/core/FogSystem" | ||
export * from "./src/ecs/systems/core/NPCSystem" | ||
export * from "./src/ecs/systems/core/PhysicsSystem" | ||
export * from "./src/ecs/systems/core/SightSystem" | ||
export * from "./src/ecs/systems/gameplay/ZomiSpawnSystem" | ||
export * from "./src/ecs/systems/gameplay/GunSystem" | ||
export * from "./src/ecs/systems/gameplay/SkellySpawnSystem" | ||
export * from "./src/ecs/systems/net/NetClientSystem" | ||
export * from "./src/ecs/systems/net/NetServerSystem" | ||
export * from "./src/net/Client" | ||
export * from "./src/net/DelaySyncer" | ||
export * from "./src/net/NetProtocol" | ||
export * from "./src/ecs/systems/ui/ChatBubbleSystem" | ||
export * from "./src/ecs/systems/ui/ClickableSystem" | ||
export * from "./src/ecs/systems/ui/DebugSystem" | ||
export * from "./src/ecs/systems/ui/HealthBarSystem" | ||
export * from "./src/ecs/systems/ui/InputSystem" | ||
export * from "./src/ecs/systems/ui/NametagSystem" | ||
export * from "./src/ecs/systems/ui/RenderSystem" | ||
export * from "./src/ecs/entities/buttons/ConnectButton" | ||
export * from "./src/ecs/entities/buttons/FullscreenButton" | ||
export * from "./src/ecs/entities/buttons/HomeButton" | ||
export * from "./src/ecs/entities/buttons/ShopButton" | ||
export * from "./src/ecs/entities/characters/Piggo" | ||
export * from "./src/ecs/entities/characters/Skelly" | ||
export * from "./src/ecs/entities/characters/Spaceship" | ||
export * from "./src/ecs/entities/characters/Zomi" | ||
export * from "./src/ecs/entities/players/Noob" | ||
export * from "./src/ecs/entities/SystemEntity" | ||
export * from "./src/ecs/entities/objects/Ball" | ||
export * from "./src/ecs/entities/objects/InviteStone" | ||
export * from "./src/ecs/entities/objects/Goal" | ||
export * from "./src/ecs/entities/objects/Portal" | ||
export * from "./src/ecs/entities/objects/Projectile" | ||
export * from "./src/ecs/entities/objects/Tree" | ||
export * from "./src/ecs/entities/terrain/Background" | ||
export * from "./src/ecs/entities/terrain/FloorTiles" | ||
export * from "./src/ecs/entities/terrain/LineWall" | ||
export * from "./src/ecs/entities/ui/HUD" | ||
export * from "./src/ecs/entities/ui/Chat" | ||
export * from "./src/ecs/entities/ui/Cursor" | ||
export * from "./src/ecs/entities/ui/FpsText" | ||
export * from "./src/ecs/entities/ui/Joystick" | ||
export * from "./src/ecs/renderables/Button" | ||
export * from "./src/ecs/renderables/DebugBounds" | ||
export * from "./src/ecs/renderables/HealthBar" | ||
export * from "./src/ecs/entities/ui/Shop" | ||
export * from "./src/ecs/entities/ui/Minimap" | ||
export * from "./src/ecs/entities/ui/Scoreboard" | ||
export * from "./src/ecs/entities/ui/ScorePanel" | ||
export * from "./src/ecs/renderables/TextBox" | ||
export * from "./src/ecs/commands/DebugCommand" | ||
export * from "./src/ecs/commands/GameCommand" | ||
export * from "./src/ecs/commands/SpawnCommand" | ||
export * from "./src/ecs/components/Actions" | ||
export * from "./src/ecs/components/Clickable" | ||
export * from "./src/ecs/components/Collider" | ||
export * from "./src/ecs/components/Effects" | ||
export * from "./src/ecs/components/Edible" | ||
export * from "./src/ecs/components/Data" | ||
export * from "./src/ecs/components/Debug" | ||
export * from "./src/ecs/components/Expires" | ||
export * from "./src/ecs/components/Gun" | ||
export * from "./src/ecs/components/Health" | ||
export * from "./src/ecs/components/Input" | ||
export * from "./src/ecs/components/Inventory" | ||
export * from "./src/ecs/components/Name" | ||
export * from "./src/ecs/components/Networked" | ||
export * from "./src/ecs/components/NPC" | ||
export * from "./src/ecs/components/Player" | ||
export * from "./src/ecs/components/Position" | ||
export * from "./src/ecs/components/Renderable" | ||
export * from "./src/ecs/components/Team" | ||
export * from "./src/ecs/components/Money" | ||
export * from "./src/ecs/actions/abilities/Boost" | ||
export * from "./src/ecs/actions/PlayerActions" | ||
export * from "./src/ecs/actions/ToggleVisible" | ||
export * from "./src/ecs/actions/abilities/IceWall" | ||
export * from "./src/ecs/actions/attacks/Reload" | ||
export * from "./src/ecs/actions/attacks/Shoot" | ||
export * from "./src/ecs/actions/attacks/ZomiAttack" | ||
export * from "./src/ecs/actions/movement/Point" | ||
export * from "./src/ecs/actions/movement/Chase" | ||
export * from "./src/ecs/actions/movement/Head" | ||
export * from "./src/ecs/actions/movement/Move" | ||
export * from "./src/ecs/actions/movement/WASDInputMap" | ||
export * from "./src/ecs/actions/movement/VehicleMovement" | ||
export * from "./src/ecs/entities/items/Axe" | ||
export * from "./src/ecs/entities/items/GunItems" | ||
export * from "./src/ecs/components/Controlling" | ||
export * from "./src/sound/Sounds" | ||
export * from "./src/utils/MathUtils" | ||
export * from "./src/utils/PixiUtils" | ||
export * from "./src/utils/RapierUtils" | ||
export * from "./src/utils/StringUtils" | ||
export * from "./src/utils/SystemUtils" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,56 @@ | ||
import { Action, Gun, KeyMouse, PositionProps, Projectile, Team, TeamColors, onHitTeam, playSound, random } from "@piggo-gg/core"; | ||
import { Action, Character, Gun, KeyMouse, PositionProps, Projectile, Team, TeamColors, onHitTeam, playSound, random } from "@piggo-gg/core" | ||
|
||
export const Shoot = Action<KeyMouse & { id: number }>(({ world, params, entity }) => { | ||
export const Shoot = Action<KeyMouse & { id: number, character: Character }>(({ world, params, entity }) => { | ||
|
||
if (!entity) return; | ||
if (!entity) return | ||
|
||
const { gun, position, team } = entity.components; | ||
if (!gun || !position || !team) return; | ||
const { position, team } = params.character.components | ||
const { gun } = entity.components | ||
if (!gun || !position || !team) return | ||
|
||
if (gun.canShoot(world, params.tick, params.mouse.hold)) { | ||
gun.didShoot(world); | ||
gun.didShoot(world) | ||
|
||
const { x, y } = position.data; | ||
const { speed } = gun; | ||
const { x, y } = position.data | ||
const { speed } = gun | ||
|
||
// distance to mouse | ||
let dx = params.mouse.x - x; | ||
let dy = params.mouse.y - y; | ||
let dx = params.mouse.x - x | ||
let dy = params.mouse.y - y | ||
|
||
// normalize | ||
const hyp = Math.sqrt(dx * dx + dy * dy); | ||
let vx = dx / hyp * speed; | ||
let vy = dy / hyp * speed; | ||
const hyp = Math.sqrt(dx * dx + dy * dy) | ||
let vx = dx / hyp * speed | ||
let vy = dy / hyp * speed | ||
|
||
// spawn bullet at offset | ||
const offset = 30; | ||
const Xoffset = offset * (vx / Math.sqrt(vx * vx + vy * vy)); | ||
const Yoffset = offset * (vy / Math.sqrt(vx * vx + vy * vy)); | ||
const offset = 30 | ||
const Xoffset = offset * (vx / Math.sqrt(vx * vx + vy * vy)) | ||
const Yoffset = offset * (vy / Math.sqrt(vx * vx + vy * vy)) | ||
|
||
const pos: PositionProps = { x: x + Xoffset, y: y + Yoffset, velocity: { x: vx, y: vy } }; | ||
const pos: PositionProps = { x: x + Xoffset, y: y + Yoffset, velocity: { x: vx, y: vy } } | ||
|
||
world.actionBuffer.push(world.tick + 3, entity.id, { action: "spawnBullet", params: { team, gun, ...pos, id: params.id } }); | ||
world.actionBuffer.push(world.tick + 3, entity.id, { action: "spawnBullet", params: { team, gun, ...pos, id: params.id } }) | ||
|
||
playSound(world.client?.sounds[gun.name]); | ||
playSound(world.client?.sounds[gun.name]) | ||
|
||
// auto reload | ||
if (gun.data.clip === 0) { | ||
const reload = entity.components.actions?.actionMap["reload"]; | ||
if (reload) world.actionBuffer.push(world.tick + 1, entity.id, { action: "reload" }); | ||
const reload = entity.components.actions?.actionMap["reload"] | ||
if (reload) world.actionBuffer.push(world.tick + 1, entity.id, { action: "reload" }) | ||
} | ||
} | ||
}) | ||
|
||
export const SpawnBullet = Action<PositionProps & { team: Team, gun: Gun, id: number }>(({ world, params }) => { | ||
|
||
const { team, gun } = params; | ||
const { team, gun } = params | ||
|
||
world.addEntity(Projectile({ | ||
id: `projectile-${random()}`, | ||
pos: params, | ||
radius: gun.bulletSize, | ||
color: TeamColors[team.data.team], | ||
onHit: onHitTeam(team.data.team, gun.damage) | ||
})); | ||
})) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Component } from "@piggo-gg/core" | ||
|
||
export type Edible = Component<"edible"> & { | ||
data: { | ||
hunger: number | ||
} | ||
} | ||
|
||
export type EdibleProps = { | ||
hunger: number | ||
} | ||
|
||
export const Edible = (props: EdibleProps): Edible => ({ | ||
type: "edible", | ||
data: { | ||
hunger: props.hunger | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.