Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special tiles #43

Open
erlend-sh opened this issue Jul 27, 2021 · 5 comments
Open

Special tiles #43

erlend-sh opened this issue Jul 27, 2021 · 5 comments
Assignees
Labels
help wanted Extra attention is needed
Milestone

Comments

@erlend-sh
Copy link
Member

There’s a great number of special tiles to be made:

  • Slippery
  • Death spikes
  • Door
  • Mud
  • Some equivalent of water
  • Some equivalent of lava
  • Whirlpool
  • ???
@erlend-sh erlend-sh added the help wanted Extra attention is needed label Jul 27, 2021
@SirGiraffey
Copy link
Collaborator

Spelunky 2 has a nice underwater trap that I feel could fit Fish Game - Giant Clam - it stays open but when someone steps on its middle it closes almost instantly, crushing everything in it. It could contain powerful weapons to be a risky way of obtaining them, but one wrong move and both the fish and the weapon are crushed.
https://youtu.be/aI97n3pvjps?t=112

The same game also had a fitting design replacing the spikes - sharp coral plants
obraz

@olefasting
Copy link
Member

olefasting commented Oct 30, 2021

We can start thinking about adding this, now that we have the new map format. I will be implementing EnvironmentItem in the editor now, which is intended to represent things such as this, as well as sproingers etc.

@erlend-sh erlend-sh added the status:art-needed This task needs help from an artist. label Nov 9, 2021
@erlend-sh erlend-sh mentioned this issue Jan 24, 2022
@Zac8668
Copy link
Collaborator

Zac8668 commented Mar 8, 2022

Hey! I will claim this, I will use the EnviromentItem as olefasting quoted on the comment above, on a similar manner to the sproinger, I'm just not so sure how the Lava and Water equivalents would work, maybe it could be a tile and not an EnviromentItem, that would open more possibilities when making a map imo.

@Zac8668 Zac8668 self-assigned this Mar 8, 2022
@olefasting
Copy link
Member

Hey! I will claim this, I will use the EnviromentItem as olefasting quoted on the comment above, on a similar manner to the sproinger, I'm just not so sure how the Lava and Water equivalents would work, maybe it could be a tile and not an EnviromentItem, that would open more possibilities when making a map imo.

The EnvironmentItem has been removed from the API and these things are now implemented explicitly. See the sproinger for an example..

@erlend-sh erlend-sh removed the status:art-needed This task needs help from an artist. label Apr 5, 2022
@erlend-sh erlend-sh added this to the v0.6 milestone Jan 19, 2023
@zicklag zicklag modified the milestones: v0.6, v0.7 Feb 3, 2023
@zicklag
Copy link
Member

zicklag commented Mar 1, 2023

@TekhnaeRaav has a simple clam that he's going to get pushed up today or tomorrow.

@zicklag zicklag modified the milestones: v0.7, 0.8 Apr 1, 2023
github-merge-queue bot pushed a commit that referenced this issue Jan 25, 2024
Implement collisions for non-tile solids and a way to define them for
elements in a map's YAML. This makes the `CollisionWorld` account for
entities with the `Solid` component.

I started out trying to implement a door for #43 but quickly realized I
couldn't make a closed door solid. This is its own PR because I want to
make sure I'm going in the right direction here and discuss the
implementation.


https://github.com/fishfolk/jumpy/assets/25290530/3851d2b3-8f58-41c0-8462-9b641334d63a

## Changes

### Defining solids

Elements can be defined in each layer of a map's YAML file. Solids can
now be defined on an element with a `solid` object.

Example element in a map layer:

```yaml
  - pos: [630.0, 365.0]
    element: core:/elements/environment/demo_solid_box/demo_solid_box.element.yaml
```

Now, with a solid:

```yaml
  - pos: [630.0, 365.0]
    element: core:/elements/environment/demo_solid_box/demo_solid_box.element.yaml
    solid:
      enabled: true
      pos: [630.0, 365.0]
      size: [16.0, 16.0]
```

The solid has its own position and size since a collider may need to be
separate from the sprite. For example, the door sprite will need to be
very wide for when it's open but the collider for a closed door will be
very thin.

This was done by adding the new struct `ElementSolidMeta` to
`ElementSpawn`. I wanted it to be a `Maybe<ElementSolidMeta>` but got an
error from bones. My next best option was letting it be
default-initialized for all elements but provide an `enabled` boolean
that must be `true` for the solid to be created. Not ideal but it works.

Another downside is that the size of the solid collider has to be
defined *in the map*, whereas the size of the `KinematicBody` is often
defined in the element's `.yaml` data file and the size of the sprite is
defined in the element's `.atlast.yaml`. Maybe this can eventually be
moved into an element's asset configs.

### Collision detection

Solids get a `Collider` component like kinematic bodies, which are also
synced to the rapier colliders. This allows game code to easily control
the collider. e.g. the door will want to disable the collider when it's
open, which can be done by setting `Collider.disabled` to `true`.

I'm not convinced my changes to
`CollisionWorld::move_{horizontal,vertical}` are correct, but this seems
to mostly work.

Since the `CollisionWorld::tile_collision{,_filtered}` methods now
detect *any* collision they should be renamed to
`CollisionWorld::collision{,_filtered}`. If this is looking good so far
I will make that change.

### Game behavior

I added a few demo boxes to dev level 1 for testing. It works great from
the testing I did except for a couple minor bugs. If you slide into the
box to the left of where you spawn you stop short of the box. But if you
walk up to the box you collide with it as expected. Sliding into the one
in the far bottom right of the map behaves like you would expect. This
is all shown in the video.

Additionally, critters cause a lot of collision warnings:

> 2024-01-16T22:02:52.902798Z WARN jumpy::core::physics: Collision test
error resulting in physics body stuck in wall at Rect { min: Vec2(712.0,
96.1), max: Vec2(722.0, 106.1) }

Snails walk straight through solids, causing these warnings. Crabs may
attempt and fail to surface under a solid after burrowing, also causing
these warnings. I'm not sure what to do about this yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants