Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411508 Posts in 69374 Topics- by 58429 Members - Latest Member: Alternalo

April 26, 2024, 08:40:02 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogsProject Rain World
Pages: 1 ... 226 227 [228] 229 230 ... 367
Print
Author Topic: Project Rain World  (Read 1447158 times)
Christian
Level 10
*****



View Profile WWW
« Reply #4540 on: August 26, 2015, 04:30:38 AM »

Just remembered you can't aim in Rain World. So does the hook just latch onto the closest structure?
Logged

Visit Indie Game Enthusiast or follow me @IG_Enthusiast to learn about the best new and upcoming indie games!
TheWing
Level 1
*



View Profile WWW
« Reply #4541 on: August 26, 2015, 04:42:02 AM »

Just remembered you can't aim in Rain World. So does the hook just latch onto the closest structure?

In the gif it seemed to shoot 45 degrees up in the direction you're facing
Logged

- - - -
Paul
Level 1
*


View Profile
« Reply #4542 on: August 26, 2015, 05:03:54 AM »

The rope script is decently solid, and uncharacteristically clean/self contained compared to the utter mess my code usually is, so if anyone's interested in it I can hit you up with the source.

Could I actually get a copy of the source? I made something very similar a few months back, that you can see here, so it would be great to compare the methods and see what you did different. I actually punctuated each corner of the tile with a "Rope Point" object in the end, to avoid the rope sticking to corners it shouldn't. It's an option for more complex shapes too

Good work  Smiley, It looks really nice and smooth!
Logged
JLJac
Level 10
*****



View Profile
« Reply #4543 on: August 26, 2015, 05:25:44 AM »

@JobLeonard, your sketch illustrates the method I use nicely Smiley I don't see the need for the convex hull though - I just use a line/vector distance to check which point that the rope hit first (on your sketch that top left one) and because that point will be convex and far out from the middle, it'll be one of the convex hull vertices either way, without having to explicitly calculate it. The concave points (such as the one in that crevice on the shape in your sketch) there's really no reason to bother with at all, because as long as the tips of the rope have terrain collision those can never end up inside a sweep.

@Christian, TheWing, yep, 45 unless you hold up, then straight up. And a little bit of auto aim - if the original aim direction seems to be all empty of terrain it'll check a few angles to the sides as well and see if any of those hit something.

@Paul, wow yeah, that looks super similar! Let me know what was and wasn't the same in the code!

Code:
public class Rope
{
    public Room room;
    public Vector2 A, B, lastA, lastB;
    public float totalLength;
    public List<Corner> bends;
    float thickness;

    public RopeDebugVisualizer visualizer;
    public List<Corner> corners;

    public Vector2 AConnect
    {
        get
        {
            if (bends.Count == 0) return B;
            else return bends[0].pos;
        }
    }
    public Vector2 BConnect
    {
        get
        {
            if (bends.Count == 0) return A;
            else return bends[bends.Count - 1].pos;
        }
    }

    public struct Corner
    {
        public FloatRect.CornerLabel dir;
        public Vector2 pos;
        public Corner(FloatRect.CornerLabel dir, Vector2 pos)
        {
            this.dir = dir;
            this.pos = pos;
        }
    }

    public Rope(Room room, Vector2 initA, Vector2 initB, float thickness)
    {
        this.room = room;
        A = initA;
        lastA = initA;
        B = initB;
        lastB = initB;
        totalLength = Vector2.Distance(initA, initB);

        bends = new List<Corner>();
        corners = new List<Corner>();

        this.thickness = thickness;

        //finds all the corners and stores them in a list. This could also be done locally on the fly, for very large spaces with lots of corners that might be preferable performance-wise.
        for (int x = 0; x < room.TileWidth; x++)
            for (int y = 0; y < room.TileHeight; y++)
                if (room.GetTile(x, y).Solid) {
                    if (!room.GetTile(x - 1, y).Solid) {
                        if (!room.GetTile(x, y - 1).Solid && !room.GetTile(x - 1, y - 1).Solid)
                            corners.Add(new Corner(FloatRect.CornerLabel.D, room.MiddleOfTile(x, y) + new Vector2(-10f - thickness, -10f - thickness)));
                        if (!room.GetTile(x, y + 1).Solid && !room.GetTile(x - 1, y + 1).Solid)
                            corners.Add(new Corner(FloatRect.CornerLabel.A, room.MiddleOfTile(x, y) + new Vector2(-10f - thickness, 10f + thickness)));
                    }
                    if (!room.GetTile(x + 1, y).Solid) {
                        if (!room.GetTile(x, y - 1).Solid && !room.GetTile(x + 1, y - 1).Solid)
                            corners.Add(new Corner(FloatRect.CornerLabel.C, room.MiddleOfTile(x, y) + new Vector2(10f + thickness, -10f - thickness)));
                        if (!room.GetTile(x, y + 1).Solid && !room.GetTile(x + 1, y + 1).Solid)
                            corners.Add(new Corner(FloatRect.CornerLabel.B, room.MiddleOfTile(x, y) + new Vector2(10f + thickness, 10f + thickness)));
                    }
                }

        //  visualizer = new RopeDebugVisualizer(this);

    }

    public void Reset()
    {
        bends.Clear();
    }

    public void Update(Vector2 newA, Vector2 newB)
    {
        lastA = A;
        lastB = B;
        A = newA;
        B = newB;

        //sweep terrain to add bend points
        if (bends.Count == 0)
            CollideWithCorners(lastA, A, lastB, B, 0, 0);
        else {
            CollideWithCorners(BConnect, BConnect, lastB, B, bends.Count, 0);
            CollideWithCorners(lastA, A, AConnect, AConnect, 0, 0);
        }

        //delete bend points where the rope has come free of the corner
        if (bends.Count > 0) {//could optimize here by making it only check first and last bend point
            List<int> deleteBends = new List<int>();
            for (int i = 0; i < bends.Count; i++) {
                Vector2 prev = A;
                Vector2 nxt = B;
                if (i > 0) prev = bends[i - 1].pos;
                if (i < bends.Count - 1) nxt = bends[i + 1].pos;
                if (!DoesLineOverlapCorner(prev, nxt, bends[i])) {
                    deleteBends.Add(i);
                }
            }
            for (int i = deleteBends.Count - 1; i >= 0; i--)
                bends.RemoveAt(deleteBends[i]);
        }

        //Calculating new total length of rope
        if (bends.Count == 0)
            totalLength = Vector2.Distance(A, B);
        else {
            totalLength = Vector2.Distance(A, AConnect) + Vector2.Distance(BConnect, B);
            for (int i = 1; i < bends.Count; i++)
                totalLength += Vector2.Distance(bends[i - 1].pos, bends[i].pos);
        }


        if (visualizer != null) visualizer.Update();
    }

    private void CollideWithCorners(Vector2 la, Vector2 a, Vector2 lb, Vector2 b, int bend, int recursion)
    {
        Corner? firstCollision = null;
        float firstCollisionDist = float.MaxValue;
        foreach (Corner c in corners)
            if (DoesLineOverlapCorner(a, b, c)
                && c.pos != la && c.pos != a && c.pos != lb && c.pos != b
                // && Custom.BetweenLines(c.pos, la, a, lb, b) && Custom.BetweenLines(c.pos, la, lb, a, b)//old sweep function that would give some false positives
                && (Custom.PointInTriangle(c.pos, a, la, b) || Custom.PointInTriangle(c.pos, a, lb, b) || Custom.PointInTriangle(c.pos, a, la, lb) || Custom.PointInTriangle(c.pos, la, lb, b))
                && Mathf.Abs(Custom.DistanceToLine(c.pos, la, lb)) < Mathf.Abs(firstCollisionDist)) {
                firstCollision = c;
                firstCollisionDist = Custom.DistanceToLine(c.pos, lastA, lastB);
            }

        if (firstCollision.HasValue) {
            Vector2 bendPoint = firstCollision.Value.pos;
            bends.Insert(bend, firstCollision.Value);

            Vector2 divPoint = Custom.ClosestPointOnLine(la, lb, bendPoint);

            CollideWithCorners(divPoint, bendPoint, lb, b, bend + 1, recursion + 1);
            CollideWithCorners(la, a, divPoint, bendPoint, bend, recursion + 1);
        }
    }

    public bool DoesLineOverlapCorner(Vector2 l1, Vector2 l2, Corner corner)
    {
        IntVector2 cornerDir = new IntVector2((corner.dir == FloatRect.CornerLabel.A || corner.dir == FloatRect.CornerLabel.D) ? -1 : 1,
            (corner.dir == FloatRect.CornerLabel.A || corner.dir == FloatRect.CornerLabel.B) ? 1 : -1);

        if (l1.y != l2.y)
            if ((cornerDir.x < 0 && (Custom.HorizontalCrossPoint(l1, l2, corner.pos.y).x < corner.pos.x))
                || (cornerDir.x > 0 && (Custom.HorizontalCrossPoint(l1, l2, corner.pos.y).x > corner.pos.x)))
                return false;

        if (l1.x != l2.x)
            if ((cornerDir.y < 0 && (Custom.VerticalCrossPoint(l1, l2, corner.pos.x).y < corner.pos.y))
                || (cornerDir.y > 0 && (Custom.VerticalCrossPoint(l1, l2, corner.pos.x).y > corner.pos.y)))
                return false;

        return true;
    }

}
Logged
Franklin's Ghost
Level 10
*****



View Profile WWW
« Reply #4544 on: August 26, 2015, 06:07:13 AM »

Update 466

Grappling hook!





This got paged so thought I'd bring it over.

Reason I joined the forums years ago was to find out how to code a grappling hook mechanic for a spiderman like game, so nice surprise seeing this in Rain World. Never did figure it out but glad my favourite game on these forums and most looked forward to game is going to have some of it. Can imagine spending hours just swinging around.

My old post.
Hey guys, new here and just thought i'd see if anyone knows how to code in AS3 a grappling hook like spiderman swing from the old amiga game

.
Logged

JobLeonard
Level 10
*****



View Profile
« Reply #4545 on: August 26, 2015, 06:15:08 AM »

Quote
I just use a line/vector distance to check which point that the rope hit first (on your sketch that top left one) and because that point will be convex and far out from the middle
So you have to calculate the distance of every point in the sweep every frame? Does that scale? Although, I guess for the current use case you'll never have to test more than a handful of points, so it won't really be an issue even if it doesn't.


Anyway, the thing with my image example was that the sweep moved far enough at once to require wrapping around two points. If I read your implementation correctly it solves this by restarting the sweep with recursion from the new bendpoint, like so:



Right?
Logged
Christian
Level 10
*****



View Profile WWW
« Reply #4546 on: August 26, 2015, 06:17:04 AM »

Was typing "dynamic ecosystem" while I was posting about Rain World on another forum, and that got me thinking

Has the slugcat's relation in the world been expanded? So far, it can only eat bats, but with so many more species now, seems like it would have a less picky diet. Same for the lizards and vultures.
Logged

Visit Indie Game Enthusiast or follow me @IG_Enthusiast to learn about the best new and upcoming indie games!
JLJac
Level 10
*****



View Profile
« Reply #4547 on: August 26, 2015, 07:03:32 AM »

@Franklins Ghost, thanks! I actually did spend too much time swinging around once I implemented the thing, so I had to remove the player from the development room to be able to continue hahaha :D

@JobLeonard, yup exactly, when hitting a corner I split the rope in two at that point and then apply the same logic on both the new segments recursively - stepping down in a tree like way until all the intersecting points have been handled. I actually only calculate distance for the points that are inside the sweep area, but what points are inside the sweep area is determined using a triangle/point overlap which calls the line/point distance three times haha  Cheesy So yeah...

Working with Rain World has made me become pragmatic rather than idealistic when it comes to optimization - usually all attempts at optimization of stuff like this are utterly soaked by some pathfinding line that is called 14 000 times per frame, outweighing anything that could or couldn't be done differently in a thing like this astronomically. So I've started to gravitate towards writing the easiest, cleanest solution, and then if there is a performance problem optimize it. So far, no problem with performance! Most rooms seem to have less than 100 convex corners anyways, so it blazes through those pretty quickly. If I were to optimize however, I'd take out the tiles that are affected by the sweep and find the corner points in there frame by frame. As most swipes are probably very small and not overlapping any corners that'd likely save some time. For a non-tile based situation like your sketch you could divide the space into sections and only check the points in the affected sections.

I do think that the convex hull algorithm could be useful as an optimization in a non-tile based scenario, but it would have to be complemented by something, as not every convex vertex is necessarily part of the convex hull:



@Christian, no comments  Who, Me? Yet  Who, Me?
Logged
oahda
Level 10
*****



View Profile
« Reply #4548 on: August 26, 2015, 09:15:44 AM »

I don't think I got an answer last time in the midst of all the deer talk, so I'll try again: will it be possible to play the game without killing stuff and eating bats? Again, if not, please consider. :3 Really excited about RW but so very tired of that sort of stuff... But I'd love to play it as a fully stealth kind of game and I think anybody would appreciate options anyway, if it's not too much extra work.
Logged

Teod
Level 1
*



View Profile
« Reply #4549 on: August 26, 2015, 09:29:40 AM »

Can you catch the bats using the grappling hook?
Was typing "dynamic ecosystem" while I was posting about Rain World on another forum, and that got me thinking

Has the slugcat's relation in the world been expanded? So far, it can only eat bats, but with so many more species now, seems like it would have a less picky diet. Same for the lizards and vultures.
While it sure would be interesting to have multiple types of edible creatures, that risks breaking one of the core gameplay elements - migration of the food source that forces player to explore. It will be harder to balance that in a more complex system.

As for the ecosystem point of view, even if slugcats only eat one other species, they sure interact with a lot more than that, so they aren't really left out. Although I think it would make sense to show somehow that slugcats can eat other things. For instance, we could have the ability to kill and eat leeches. Being high risk low reward option it won't be something players rely on, so it can be ignored when looking at a big picture. Or make the slugcat take tiny bites of some types of fruits he carries, but then make a face/sound indicating unpleasant taste.
Logged
Christian
Level 10
*****



View Profile WWW
« Reply #4550 on: August 26, 2015, 09:33:23 AM »

I don't think I got an answer last time in the midst of all the deer talk, so I'll try again: will it be possible to play the game without killing stuff and eating bats? Again, if not, please consider. :3 Really excited about RW but so very tired of that sort of stuff... But I'd love to play it as a fully stealth kind of game and I think anybody would appreciate options anyway, if it's not too much extra work.
Given that slugcat is a predator too, you're going to have eat. Would remove a lot of tension and pacing if you didn't have to catch bats

But as for stealth, I've played the alpha a lot and stealth is always the best option. I tend to be more aggressive because I like messing with the AI and the combat is fun, but fleeing and hiding is always better than fighting. You die fast, you're always outnumbered and outgunned. Being sneaky is the key to survival
Logged

Visit Indie Game Enthusiast or follow me @IG_Enthusiast to learn about the best new and upcoming indie games!
oahda
Level 10
*****



View Profile
« Reply #4551 on: August 26, 2015, 09:36:46 AM »

I obviously meant not having to eat anything at all, Teod. :p

How have players responded to this anyway? Isn't that sort of management something people mostly just find annoying and boring in a game that isn't The Sims? Why not add the need to pee too then? xP
Logged

Christian
Level 10
*****



View Profile WWW
« Reply #4552 on: August 26, 2015, 10:00:28 AM »

I obviously meant not having to eat anything at all, Teod. :p

How have players responded to this anyway? Isn't that sort of management something people mostly just find annoying and boring in a game that isn't The Sims? Why not add the need to pee too then? xP
I can only speak for myself. But it isn't actually management like in a Sim. Eating the bats is less survival game hunger mechanic, and more "collect X amount of item" this level. (At least in the alpha)

Also in a sim/survival game, hunger management is merely a side aspect to worry about. While here, due to bat migration, it acts a subtle means to drive the player to explore and venture to new areas. You have to go to new places to find more bats eventually.

Personally I think it's a brilliant way to guide players without a big arrow or compass.
Logged

Visit Indie Game Enthusiast or follow me @IG_Enthusiast to learn about the best new and upcoming indie games!
tortoiseandcrow
Level 2
**


View Profile
« Reply #4553 on: August 26, 2015, 12:12:34 PM »

Speaking for myself as well, I found that catching bats never felt like a imposition. Its like collecting coins or powerups in Mario - just part of the rhythm of the game, and necessary for your progression. There's a real sensation of feeling like you're a part of an ecosystem. You not only have to avoid being eaten, but must also eat in order to survive yourself. There is a tension reminiscent of the way that a nature documentary will follow around the emergent drama of a day in the life of an animal. Hunger provides your ultimate motivation for everything you do (and in fact, for everything else in the game). So, if your concern is about whether hunting is a distraction from the rest of the game, I can assure you that it is not.

Note: from my experience of the alpha, it is entirely possible to play the game without purposelessly killing other animals. In fact, it is appropriately difficult (often impossible) to just run around murdering all of the predators hunting you.
« Last Edit: August 26, 2015, 12:38:35 PM by tortoiseandcrow » Logged
Paul
Level 1
*


View Profile
« Reply #4554 on: August 26, 2015, 12:16:41 PM »

@Paul, wow yeah, that looks super similar! Let me know what was and wasn't the same in the code!

That's one nicely written script! The concept of creating bend points and the way they attach and detach to a tile is similar to my method (mine is a lot more messy :D), but the way the corners of the tiles are calculated are quite different. I used raycasts perpendicular to the rope to find tiles in the ropes path, whereas you seem to find all corners in a room, store them and then check the overlaps, which seems like a nicer solution! I initially used the raycasts to get the tile object and then calculate it's corners, but I had some issues when travelling at speed, where it would move too far in one frame and "bend" around the wrong corner of the tile. For this reason, I changed it so when the tile spawns, it creates corner "Rope Points" which would show if the corner is open to be attached to (i.e. is there a tile above this tile or to the side? If not then add a "Rope Point" to it as it is an open corner. This is now a swingable corner point. I chose this solution as have destructible terrain, so I need these corner points to be able to change dynamically).

Thanks for sharing the source, was pretty interesting to see another (and super good) solution to that problem!

Edited for clarity
« Last Edit: August 26, 2015, 12:32:31 PM by Paul » Logged
jamesprimate
Level 10
*****


wave emoji


View Profile WWW
« Reply #4555 on: August 27, 2015, 06:52:11 AM »

Quote from: Princessa
will it be possible to play the game without killing stuff and eating bats? Again, if not, please consider.

Most of the fundamental mechanics of Rain World are built around the core idea of the player creature being at the center of an ecological triangle as both predator and prey. Through that we're able to explore the concept of resource scarcity on a micro and macro scale through the narrative design, the world design and down through the gameplay, etc. What happens when an ecology of creatures (or civilizations) are forced to compete for a pool of dwindling resources in a world with a climate dangerously out of whack? I want the player to feel the existential pressures of this, the bleak prospect of comfort and even survival slipping further and further out of reach as time goes by, not through "enemies" or "bad guys" but only due to the consequences of the player characters basic needs for survival and the natural self-preservation behaviors of those around it. For me, thats the thesis of the game and something i feel very strongly about conveying, for reasons that should be fairly obvious.

That said, I really like the idea of the game not forcing a players hand, allowing the game to be playable in a variety of ways provided they fit the criteria of the central game mechanics of "get sufficient food" and "survive rain cycle". These are "emergent narrative paths" that open up based on how the player naturally approaches the game and i'd like to support and encourage them where possible. "Vegan Slugcat" is hard because it compromises a good deal of teh structure already in place, but if things work out in a certain way it could *possibly* be explored as an achievement path later in the polish phase. But other than the necessary sustenance it should currently def be possible to get through the game as a pacifist using entirely stealth and misdirection. In fact, Joar even has a system in place to reward altruistic behavior, though we'll keep quiet on the specifics of it for now.

Note: from my experience of the alpha, it is entirely possible to play the game without purposelessly killing other animals. In fact, it is appropriately difficult (often impossible) to just run around murdering all of the predators hunting you.

This is def a key element as well. Its not fleshed out yet, but there is also a system in place where the more aggressively you play, the more aggressive the creatures around you become. If you kill weaker creatures, it opens up their ecological niche to other more dangerous creatures, etc. Plays to both the thesis of the game and creates a challenging "warrior" emergent narrative path, etx etx.

A lot of this stuff is really "balance focused", so nothing were touching right now and very subject to change. Plenty of work to do just getting the core game and geography in place.
« Last Edit: August 27, 2015, 07:38:38 AM by jamesprimate » Logged

Torchkas
Level 10
*****


collects sawdust


View Profile WWW
« Reply #4556 on: August 27, 2015, 09:10:57 AM »

Quote
is there going to be in-engine reverb? the explosion sound effect is currently fading out way too fast

game looks pretty good though, can't really comment on it much since I haven't played it
Logged

jamesprimate
Level 10
*****


wave emoji


View Profile WWW
« Reply #4557 on: August 27, 2015, 09:30:42 AM »

i wouldnt take much from the audio in the coub videos, as coub automatically apply volume normalization and huge amounts of compression that isnt in the actual audio. you can hear it really strongly in the leviathan video, which should be all subtle background sounds and ambient water swishes with tons of headroom. whatev.
Logged

oldblood
Level 10
*****

...Not again.


View Profile
« Reply #4558 on: August 27, 2015, 10:04:51 AM »

I'm absolutely loving the sound direction... Wow. Awesome work James...

And that grappling hook/animal thing is amazing...
Logged

adge
Level 0
**


View Profile
« Reply #4559 on: August 27, 2015, 11:21:32 AM »

Can you kill species entirely from a game?  So that the system would break or at least alter the ecosystem?
Logged
Pages: 1 ... 226 227 [228] 229 230 ... 367
Print
Jump to:  

Theme orange-lt created by panic