Commit Graph
100 Commits
Author SHA1 Message Date
robert 16842c13f7 Docs for objects.rs 2025-08-12 23:18:33 -05:00
robert e199db16eb Docs for machinery.rs 2025-08-12 23:01:32 -05:00
robert f17910daef Docs for lib.rs 2025-08-12 22:41:37 -05:00
robert 70f2313766 Improve documentation for the events
Basic checks / Basic build-and-test supertask (push) Has been cancelled
2025-08-12 11:33:00 -05:00
robert 58bbc1e614 Fix documentation links 2025-08-11 23:50:43 -05:00
robert 79679759c5 Move HUD spawning system into widgets
It actually needs to be completely replaced. When that finally happens,
the new bits will live here.
2025-08-11 23:42:06 -05:00
robert 0e517de419 Move the title screen stuff into widgets.rs 2025-08-11 23:40:52 -05:00
robert cb2b57449a Create a "widgets" module (by moving title scene)
The non-gameplay scenes are really just a bunch of widgets. I'm going to
put them all together and then bundle the functionality with some
exported plugin builders.
2025-08-11 23:39:42 -05:00
robert 9a262fcffc Move Lifetime component to machinery module 2025-08-11 23:34:12 -05:00
robert 34ee2fcc7d Create a "machinery" module for game systems
I'm not sold on the name, but anyway.

This module will hold the systems that power the main game mechanics, as
well as a few extra items to support that (in particular, the Lifetime
component).
2025-08-11 23:28:39 -05:00
robert 93da225636 Move resources to a resources.rs submodule 2025-08-11 23:19:06 -05:00
robert cd194e2dbf Move collision system to physics module 2025-08-11 23:07:18 -05:00
robert 1369a3092f Move the ship & bullet systems into the object mod 2025-08-11 23:01:14 -05:00
robert 619037dab0 Move asteroid spawning & splitting systems
They deal with events, but are directly related to how the Asteroid
object interacts with the events, so I'm putting them here.
2025-08-11 22:59:20 -05:00
robert c1b69c412a autoformat 2025-08-11 22:48:08 -05:00
robert d8a83b77c2 Move ship & bullet to the objects module 2025-08-11 22:47:48 -05:00
robert f5ff7c8779 Move Asteroid components to the objects.rs mod 2025-08-11 22:44:05 -05:00
robert f4484f759f Move SpawnAsteroid event into events.rs 2025-08-11 19:16:34 -05:00
robert 571b910945 Rename "event" module to be plural "events.rs" 2025-08-11 19:14:22 -05:00
robert 804186ea2f Handle player ship destruction... some of it...
Basic checks / Basic build-and-test supertask (push) Has been cancelled
The player will be respawned, their lives decreased, and the board
cleared. The UI doesn't update, and the sudden snap to a freshly reset
board is quite jarring. The state transition to GameOver stops the game,
but there isn't anything else running in that state so it just looks
frozen.

Basically, there's a ton left to do, but technically I have handled
player ship destruction!
2025-08-10 21:29:25 -05:00
robert 45b1fe751f Create the asteroid splitter to break down rocks.
Basic checks / Basic build-and-test supertask (push) Has been cancelled
2025-08-10 20:45:08 -05:00
robert 3d28d489b0 Fix: Pass size through to spawned asteroid
I actually have most of the asteroid's destruction handling system done
and found this bug.

Asteroid *assets* are selected based on the size set in the spawn event,
but the `Asteroid` Component itself was left hard-coded to the smallest
size.
2025-08-10 18:46:49 -05:00
robert cdd665cc93 Add bullet on-impact despawning system 2025-08-10 18:43:56 -05:00
robert 364fbd7530 Use the lifetime limiters on Bullets & Asteroids
Basic checks / Basic build-and-test supertask (push) Successful in 7m3s
Closes #14

Despawn bullets to limit range.

Despawn asteroids to limit random garbage floating around the scene.
2025-08-10 17:14:26 -05:00
robert 2f463303a0 Create Lifetime component and system
Closes #13

The lifetime component, and system to operate it, are ready! Now I can
delete things that have lived for too long.
2025-08-10 17:07:20 -05:00
robert 8d689d7842 Wire in the bullet & asteroid destruction events 2025-08-10 16:49:22 -05:00
robert 65f28e832f Implement basic gun controller
Basic checks / Basic build-and-test supertask (push) Successful in 7m3s
The spacebar fires the gun, bullets are spawned on top of the ship with
a velocity that sends them forward (relative to the ship).

I still need a despawn mechanism, and a fire rate control. To despawn
things, I'm already planning a `Lifetime` component. For rate of fire,
an additional component will be created and attached to the player ship.
2025-08-10 13:30:42 -05:00
robert dea8a0dc1a Fix: apply thrust input properly
Basic checks / Basic build-and-test supertask (push) Successful in 7m11s
Yay for funny coordinate spaces. I was, again, using the wrong
operations to get the 2D Cartesian angle and apply force to the ship.
2025-08-09 16:25:19 -05:00
robert 6191fde25a Fix: apply steering input properly
The ship in Asteroids isn't expected to spin up while holding a steering
direction, but that's exactly what I just made it do.

Fix that problem by assigning, not accumulating, the angular velocity
for the ship.
2025-08-09 16:09:54 -05:00
robert d4f11faf5a Fix: integrate rotation *correctly*
Something something quaternions are hard. I thought I would take the two
"things", add them together, and then put them back into the transform.

That's clearly not how it works :v
2025-08-09 16:04:51 -05:00
robert e841facf73 Remove Rotation component, update usage sites 2025-08-09 16:04:12 -05:00
robert 939ffc70a1 Add AngularVelocity, begin removal of Rotation
The rotation component is also redundant with Bevy's transform
component.

This new component and system fill the physics role, but the input
handling code needs to be updated.

Player steering still functions because it uses the `Rotation` component
to direct the force vector. The force is correctly applied to the linear
velocity vector. An improvement would be to have a force/impulse
accumulator so I could account for mass, but I'm not going to do that
right now.
2025-08-09 15:50:54 -05:00
robert 877c7f93d7 Drop TODO to combine phys fns, update docstring
Replacing the `Position` component with direct manipulation of the
transform functionally completed the TODO. The functions weren't exactly
combined, but the resulting behavior might as well have been.

I've updated the docstring to (exist, actually. yay syntax) describe the
system accurately.
2025-08-09 15:26:28 -05:00
robert 2b1a0f386e Add an angular velocity component 2025-08-09 15:14:05 -05:00
robert 515ecaac27 autoformat 2025-08-09 15:11:57 -05:00
robert 3922cac3d7 Finish removal of Position
The component has been completely removed, and all call sites are fixed
to use the Transform directly.
2025-08-09 15:10:44 -05:00
robert e834d94b8a Use Transform not Position in wrapping system 2025-08-09 15:08:15 -05:00
robert ad5e86a06b Begin removal of Position component
The position component is redundant with the built-in Bevy Transform.
I've updated the velocity integrator to use the transform directly.

Physics still works, but things still set their initial locations
through the Position component. I'll need to fix all those call sites.
2025-08-09 15:05:02 -05:00
robert 3d0da6df2d Fix module-level docstring in asteroids & config
I made a comment to help me remember the purpose, but if I do it this
way `cargo doc` will render it out to the actual documentation.
2025-08-09 14:55:07 -05:00
robert 73b97ad15c Re-order use statements, prefer crate mods first 2025-08-09 14:53:50 -05:00
robert 61c57783f1 Split physics parts into a submodule
The physics sim bits (that aren't Rapier2d) are now in their own
submodule. I've included the `Wrapping` marker component because it
doesn't really have anywhere else to live, and it's kinda sorta related
to the physics. It controls the motion of objects... that's physics. :p

There are name collisions between Rapier2d's `Velocity` and my own, but
that's a problem for later. I've used more specific type paths where
necessary to maintain the previous behavior.

The `physics::Position` component can go away completely. It's just an
extra copy of some of the built-in `Transform` data. I'm pretty sure it
only exists because I didn't realize I could rely on directly
manipulating the transform when I started this project.
2025-08-09 14:46:56 -05:00
robert 809810b8ce First parts of a collision event handler
Basic checks / Basic build-and-test supertask (push) Successful in 7m15s
I've added a new `event` module to contain all the game's events (which
it does not. I'll collect them all later).

Using these events, the CollisionEvent listening system can watch for
any two colliders intersecting, check on what role they play (asteroid,
ship, bullet, etc), and re-emit an event for that specific thing. Each
component can then handle it's own destruction process.
2025-08-09 12:30:37 -05:00
robert 29735e7426 Move ship parts into it's own submodule 2025-08-08 22:03:34 -05:00
robert ab5f489450 Enable collision sensing for bodyless entities
Basic checks / Basic build-and-test supertask (push) Has been cancelled
Rapier expects to have a RigidBody attached to the entity, but I do not.

I'm not going to make one, either, because the objects in a game of
Asteroids don't need collision handling the way most games do. I just
need to know if two objects have started overlapping.

According to this: https://rapier.rs/docs/user_guides/bevy_plugin/colliders#collision-groups-and-solver-groups
only one of the two objects involved needs to have the ActiveEvents and
ActiveCollisionTypes components attached, so I've placed them on the
player ship.
2025-08-06 15:21:12 -05:00
robert d4ceaa6312 Add Sensor component to colliders 2025-08-06 14:44:38 -05:00
robert f553574e3e Beginning work with collision detection
Basic checks / Basic build-and-test supertask (push) Failing after 31s
I'm going to grab the Rapier physics library so that I don't have to do
my own collision detection mechanism. The last time I did this, I
simplified everything into circles. This time I'd like to have convex
hulls, particularly for the player ship.

Also the last time, I ended up rolling my own quadtree impl. I'm not
particularly interested in doing that again, and I'd like to learn more
of the broader Bevy ecosystem.
2025-08-06 13:05:12 -05:00
robert 96e9376330 Autoformat before physics feature
Basic checks / Basic build-and-test supertask (push) Successful in 6m47s
2025-08-06 12:32:42 -05:00
robert 07105760f5 Bump Rust edition to 2024
Basic checks / Basic build-and-test supertask (push) Failing after 27s
2025-07-30 22:41:43 -05:00
robert 1555c93bed Set asteroid velocity so they move into play area
Basic checks / Basic build-and-test supertask (push) Successful in 6m24s
It's functional, if not especially interesting. Forward to the next
thing!
2025-07-29 17:44:33 -05:00
robert 2b93654491 Randomly assign asteroid spawning positions
Basic checks / Basic build-and-test supertask (push) Successful in 6m23s
I need to close the circle down to touch the corners of the play area,
but this demonstrates the principle.

Next, I need to generate a velocity and "fix" it so that the asteroid
crosses through the viewport. I left a TODO about this, which I think
will work well enough. Although it might allow for some asteroids to
slip past, or bias the density in a funny way.

Oh well, it's just an Asteroids game.
2025-07-29 16:31:35 -05:00
robert c80ada4aa6 Add "rand" crate, store an RNG in AsteroidSpawner 2025-07-29 13:32:26 -05:00
robert eee039339e Asteroid spawner now uses info from event message
Basic checks / Basic build-and-test supertask (push) Has been cancelled
Closes #4: "Convert asteroid spawning system into an event listener"
2025-07-29 13:26:41 -05:00
robert 04f192b62a Drop never-used import
Thanks, VSCode. I really like when you import things I'm not actually
trying to use. SMH my head.
2025-07-29 13:17:01 -05:00
robert 2dd3b2ff61 Fix case on AsteroidSize enum variants
Basic checks / Basic build-and-test supertask (push) Successful in 6m28s
Closes #9: "Fix case on AsteroidSize enum variants"
2025-07-29 13:15:54 -05:00
robert 2c43bc699e Begin work on event-based asteroid spawning
The events are being emitted by the spawn manager, and consumed by the
spawn_asteroid system. Now to wire in the spawn properties, and then
make a good spawning manager.
2025-07-29 13:12:22 -05:00
robert 911b6c5fe7 Fix visibility & add constructors, program builds
Basic checks / Basic build-and-test supertask (push) Successful in 6m29s
2025-07-29 12:54:09 -05:00
robert 71ec77f5b1 Move asteroid bits to another module
Now to fix the visibility issues and make the program compile again...
2025-07-29 12:48:54 -05:00
robert 5dfe11d31f Remove unused color import
Basic checks / Basic build-and-test supertask (push) Successful in 6m30s
2025-07-29 11:59:36 -05:00
robert 40102bf46b Drop ThrusterColors component
Basic checks / Basic build-and-test supertask (push) Successful in 6m26s
I've already moved these resources to the GameAssets Resource, now I can
delete the Component struct itself.
2025-07-29 11:57:52 -05:00
robert 0eac337c00 Update spawn_player to use new GameAssets
Basic checks / Basic build-and-test supertask (push) Has been cancelled
2025-07-29 11:54:39 -05:00
robert 3d4e0afc58 Swap asteroid-spawning to use new GameAssets 2025-07-29 11:51:12 -05:00
robert f62ab2c95d New GameAssets resource to hold all my assets
I'm finally getting around to centralizing all the assets instead of
letting spawners load their own.

I'm missing some assets, which may eventually be filled by textures
instead of solid-colors and simple shapes

I also need to hook up all the functions to use this thing instead.
2025-07-29 11:48:02 -05:00
robert 6681b25728 Functional prototype of WIP asteroid spawning
Basic checks / Basic build-and-test supertask (push) Successful in 6m36s
It needs a whole lot more work, but hey, look: A rock!

... well a circle, anyway.
2025-07-28 15:35:50 -05:00
robert 68a8de1809 Make player ship wrap by marking it with Wrapping
Basic checks / Basic build-and-test supertask (push) Failing after 3m2s
2025-07-28 09:15:23 -05:00
robert a6622f24b5 Add new "Wrapping" marker component
Not everything needs to wrap, so I'll use a marker component for the
ones that do. At the moment, I'm thinking only the player's ship will
wrap around. Asteroids can be de-spawned and re-spawned, and bullets can
simply evaporate.
2025-07-27 19:36:05 -05:00
robert c37887b0e7 Remove unused system inputs for prep widget 2025-07-27 16:20:40 -05:00
robert 31451732c4 Finish the countdown anim with a progress bar
Basic checks / Basic build-and-test supertask (push) Successful in 6m40s
2025-07-27 16:18:51 -05:00
robert 4ecbfaa370 Implement (most of) the timer countdown
Basic checks / Basic build-and-test supertask (push) Failing after 26s
The timer-wrapper thing was marked as a Component rather than a
Resource, which I have fixed.

The update function is about as straight forward as can be:
1. tick the timer
2. read the value out, format it for display,
3. check if the timer is expired, change states if so.
2025-07-27 14:42:50 -05:00
robert eb50655671 autoformat 2025-07-27 12:57:56 -05:00
robert a7d54c9192 Impl "get-ready"s despawn function 2025-07-27 12:57:07 -05:00
robert fccd2e6a8b Impl the "get-ready" widget's spawn function 2025-07-27 12:56:42 -05:00
robert efabcbf636 Start submodule to impl the "Get ready" spinner 2025-07-27 11:58:58 -05:00
robert f848de6b2e Replace usage of another deprecated function
Basic checks / Basic build-and-test supertask (push) Failing after 29s
2025-07-27 11:08:59 -05:00
robert e605bbf80d Spawn just one camera (it's messing with egui)
Basic checks / Basic build-and-test supertask (push) Failing after 27s
The egui debug inspector disappears when switching scenes, which seems
to be related to the camera change. I'm not going to dig into why
exactly this is happening. I'll just create one camera and keep it.
2025-07-27 11:05:49 -05:00
robert 39bddf1c9e Fix: only run space-to-start when on title screen 2025-07-27 10:43:28 -05:00
robert 477460ad2f Fix: Mark the main-menu camera so it despawns
The camera spawned for the main menu wasn't given the TitleUI marker
component, so it wouldn't despawn when changing to the game scene.
2025-07-27 10:41:00 -05:00
robert c11322969c Finally impl the "space to start" feature 2025-07-27 10:40:37 -05:00
robert 7123192271 Implement the main menu despawn function 2025-07-27 10:33:53 -05:00
robert 9a2381249f autoformat 2025-07-27 10:31:24 -05:00
robert f68d841e52 Switch to non-deprecated .single_mut() method 2025-07-27 10:31:12 -05:00
robert 88db8a868a Make the Lives(i32) resource appear on debug UI 2025-07-27 10:30:11 -05:00
robert 584a30f7f8 Add bevy-inspector-egui so I can fiddle with values easier 2025-07-27 09:45:33 -05:00
robert 430b77be2e Fix: add game entities only when in Playing state 2025-07-27 09:32:49 -05:00
robert 6eb69f476f Split title screen into it's own mod & Plugin
Basic checks / Basic build-and-test supertask (push) Failing after 28s
2025-07-27 09:31:09 -05:00
robert a4409cb946 Bump to Bevy 0.16 2025-07-26 19:38:49 -05:00
robert 38fbc85505 Autoformat 2025-07-26 18:59:56 -05:00
robert 08c9625e71 Remove all usage of old Mesh & Material bundles 2025-07-26 18:57:47 -05:00
robert 96aff4ae46 Chain method calls, drop intermediate vars 2025-07-26 18:47:18 -05:00
robert a52311eac6 Switch to new Camera2d struct over cam bundle 2025-07-26 18:45:02 -05:00
robert cf678f9f16 Update spawn_screen function 2025-07-26 18:44:10 -05:00
robert 2f9afaeac1 Replace spawn_ui implementation 2025-07-26 18:30:38 -05:00
robert 7f5a166f10 Hack to get ship meshes back in place 2025-07-26 18:19:50 -05:00
robert 5e6440340f Rename time elapsed method usage 2025-07-26 18:01:06 -05:00
robert 290aab45f5 Bump to Bevy 0.15, enable dynamic linkage
The dynamic linkage is for improving testing cycle time, not for any direct impl reason.
2025-07-26 17:55:22 -05:00
robert 406e611e31 Autoformat to make the checker happy
Basic checks / Basic build-and-test supertask (push) Failing after 44s
2025-02-01 17:28:37 -06:00
robert c86cd0d642 States, I guess. Now to do the others
Game states are named and used to toggle behavior. Now to rewrite those
things to do the *right* behavior.
2024-11-29 16:45:52 -06:00
robert f114203665 Title menu, but always present. Time for states!
I've made a quick title menu, but it is always present. I'll need to set
up some game state stuff so I can flip between play modes.
2024-11-29 16:01:23 -06:00
robert 37d7c1db42 Spawning score and lives UI elements, no logic
I have basic UI elements! They can't be updated, yet, and there's still
no game logic to allow the player to affect it on their own.
2024-11-28 11:56:42 -06:00
robert a61d400c64 Add mob wrap-around system 2024-11-28 10:14:55 -06:00
robert 941c2f6bea World size configuration
The WorldSize is a Resource so that I can use it in the entity wrapping
system. The size is pulled from a public constant in the config.rs file,
and the window is made that same size.
2024-11-28 09:50:13 -06:00