#GrubStomper29's Project Thread

3400 messages ยท Page 4 of 4 (latest)

raven halo
#

case in point

hushed crescent
#

that would not matter at all

#

unless your resolution algorithm is extremely, extremely fragile

#

which is a bigger issue

raven halo
#

okay

#

here it is

#

if (displacement.x > 0.0f)
{
    fixX = pos.x + hitbox.max.x - tilePos.x;
    return true;
}
else if (displacement.x < 0.0f)
{
    fixX = (pos.x + hitbox.min.x - (tilePos.x + 1.0f));
    return true;
}
hushed crescent
#

you need to combine your resolution and do it via vector math

#

generally speaking in a physics engine you find the resolution vector between a pair of contacts and apply them, with the vector being the shortest direction + distance required to move them apart

#

so you need to do some logic to choose the minimum direction and then calculate the distance from there, then apply that vector

raven halo
#

what's sat?

hushed crescent
#

separating axis theorem, you can find tons of info on it if you search, it's pretty much the most popular algorithm/approach for finding intersections between physics objects

#

the theorem itself just dictates that you can have a specific set of axes upon which you check intersection independently, and two shapes intersect if and only if they intersect when projected onto every axis

#

and the convenient thing is that the algorithm inherently is set up to give you the framework for finding the minimum axis of penetration, plus it's very simple for AABB vs. AABB like you have

raven halo
#

okay

#

or...

#
while (pos.y + hitbox.max.y == std::ceil(pos.y + hitbox.max.y))
{
    pos.y = std::nextafter(pos.y, std::numeric_limits<float>::min());
}```
#

we are hacking it

hushed crescent
#

don't be the guy that makes a 2d sidescrolling indie game with bad collision

#

you have the power...

raven halo
#

bad collision code*

#

you're right

#

@hushed crescent what about swept, have you heard of that?

#

it doesn't look too hard

#

actually the AABB vs AABB (non-swept) section seems to be exactly what you're talking about

raven halo
#

glorious richter was right

hushed crescent
#

swept is for doing continuous collision detection, you basically smudge the AABBs along over time so you can catch if they met somewhere between frames

#

generally only necessary if you have stuff moving very fast, so fast that they might phase past each other in a single frame

raven halo
#

right

raven halo
#

not fast enough to phase through but fast enough for the penetration vector to be nonsensical

raven halo
keen forge
#

nice, you got built in spoodermain capabilities too

prisma otter
#

Getting closer

raven halo
#

yeah i think i just need to write my own slab method and swept functionality

#

the functions I'm finding on google arent working out too well

hushed crescent
#

you can probably extend it via convex polygon SAT, I don't know anything about CCD resolution

#

since a swept AABB is a sort of extended hexagon if you look at it

raven halo
#

you can do some fancy minkowski thing to turn it into ray vs aabb

raven halo
#

perhaps my linux needs a minecraft world

raven halo
#

im close to being back at square one

keen forge
#

gp does feel like playing Ludo

raven halo
#

im using swept aabb vs aabb to get a more accurate resolution vector

#

and that's working, im not really teleporting around anymore

#

but I still get stuck on floors/walls because the resolution vector fails to full push the player out

#

i imagine its due to float precision again

hushed crescent
#

are you just altering the position?

raven halo
#

as opposed to

hushed crescent
#

afaik there's a few ways to go about it, but the most common one I know of (sequential impulse) is just to apply a single frame impulse of velocity

#

so if you know you have a resolution vector r that encodes a certain direction/magnitude, you can apply an impulse of r / dt to resolve the collision

#

this works out well for a lot of reasons, particularly because you might have multiple objects you're intersecting at once, and in a physics engine you usually have multiple collision resolution sub-steps in a single frame

#

so usually your frame looks like

integrate_acceleration();

for (int i = 0; i < substepCount; ++i) {
  find_and_resolve_collisions();
  integrate_velocity();
}
#

it's also more temporally stable so if you're still stuck across frames you'll still have impulses applied proportional to how much you're still stuck

raven halo
#

2.00001383

hushed crescent
#

yeah there's literally always gonna be floating point error

#

but if you use sequential impulse it should be more manageable

#

oh yeah, one more thing you can do if you use sequential impulse is apply Baumgarte stabilization

#

idk the fancy mathematical rigor behind it, but basically you have 2 error factors: an allowable penetration depth and a damping factor on the impulses

#

so instead of resolving with a pulse of r / dt, you resolve with (r / dt) * 0.999 or something, and allow 0.0001 units of allowable intersection (or whatever you find via tuning that works for both those factors)

#

but before you add that, just try simple sequential impulse with r / dt

raven halo
hushed crescent
#

yeah

#

and of course in intergrate_velocity in the loop above, you just do pos += vel * dt, then reset vel to 0

raven halo
#

since no velocity would persist across frames

raven halo
#

wait...i'm goated

hushed crescent
#

you don't have to reset your velocity, you just have to make sure that you calculate a net velocity for each sub-step and make sure it doesn't run away on you

raven halo
#

i think i got it fixed

#

rn I'm not doing swept and just adding the resolution vector to the player pos

raven halo
#

bruh it rained a little and now theres a layer of ice covering all the snow

winged ruin
#

Dont even start. We had this for week covering the snow and basically everything. The first day when I stepped out of my house I started sliding into incoming traffic bleakekw

#

Once I managed to slide my way into tram stop. I saw a guy sliding 100 metre slope downwards with his ass

mystic kettle
#

We have like a 3 cm permanent layer of ice on every road. It's been going for a month probably. I gave up going outside

raven halo
#

primary inspiration for my physics engine

dry basalt
#

Absolutely wild shit

raven halo
#

Metal Gear Solid is a metroidvania

raven halo
#

jazz with xylophone and electric fiddle?!

raven halo
#

i have achieved phuysics

#

slopes are still a little janky

keen forge
#

whenever i see the red square jump, i make a :boing.flac: noise

#

very cool seeing others making progress in their prijects

raven halo
#

sometimes the player gets caught on that little corner when going up a left facing slope

#

it doesn't happen on right facing slopes so I believe this has to do with the order of collision resolution

#

which is done left to right, bottom to top

raven halo
#

production of this game must halt momentarily

#

I have come across a 39 hour youtube video

#

nvm, its metal gear and i havent yet played 4 so I'm avoiding spoilers

raven halo
#

New Acerola video mentions Cave Story many times ๐Ÿ™‚

raven halo
#

been real busy

#

i believe the next step is to give our guy a gun

#

ah only after i fix slope physics

raven halo
#

i think theres a lot of value in games that can be played through in one sitting

#

those vs longer games are like movies vs series, both good for unique reasons

prisma otter
#

Can you give me some examples? I'd be interested in trying them

worldly acorn
#

Squirrel stapler

raven halo
#

ive heard a lot of good stuff about squirrel stapler

#

ddlc unironically

#

a long sitting (~5 hr) but still feasible

worldly acorn
#

It's just a bizarre experience that can be had in one or two sittings, it's a perfect example of the kind of thing an indie game can do that a big commercial game can't

#

There's also that Miziziziz game Wrought Flesh that is similar although it's a bit longer now I think

prisma otter
#

I'm aiming for ASO to be around 10 hours, so like 3-4 sittings

#

I think that's a good length

#

I finished Return of the Obra Dinn in around 3 sittings, that was fun

raven halo
#

i hate online classes bro

#

interpersonality is being replaced and sanity is the tuition

dry basalt
#

The only online class I took ruined my gpa

#

I got a 68 in statistics, the rest of my classes are like 80+ lol

raven halo
#

they were classes i had to take and the only offerings were online

dry basalt
#

That sucks

#

Good luck

raven halo
#

just one semester

#

hopefully when i transfer to umd such a problem will go away

prisma otter
raven halo
prisma otter
#

It literally never came up once since I graduated

raven halo
#

yeah maybe im putting too much effort into these classes

prisma otter
#

Nobody is gonna ask you what your GPA was. Try hard people just put it on their resume if it was really high

raven halo
#

doesnt sound worth maintaining straight As

#

which ive been doing ever since i got a B in an AP class in freshman high school

#

time to throw in the towel methinks

worldly acorn
raven halo
#

well I think I'll have to do online physics over the summer

#

hopefully itll be using math i already know

#

somewhat related, I need to write an essay for a college application of which I'm already guaranteed admission

#

i guess i should still tryhard a little in case the essay is also considered for scholarships

raven halo
#

the best thing about taking a break from this is that main.cpp isnt 1000 lines long

#

so when i do come back I'll actually understand my own code

raven halo
#

history class is very hard

worldly acorn
#

Good

#

I've heard unfortunate stories about humanities classes getting easier because people come into college barely knowing how to read and write lol

#

So I'm glad to hear they are trying to maintain their standards lol

raven halo
#

oh some of the other humanities i took were a joke

#

technical writing and health

prisma otter
#

What kind of history? Any particular specialization? I love history

raven halo
#

US History of course

#

i think ancient to civil war

#

i don't find the surface level post US civil war stuff interesting

worldly acorn
#

ancient to civil war sounds pretty neat to me

raven halo
#

Rhodesian history wasn't offered ๐Ÿ˜ฅ

prisma otter
worldly acorn
prisma otter
#

One of my favourite courses back in high school was "History of the world: 1453-Present"

#

A good film is also "History of the world: Part I" KEKW

raven halo
raven halo
#

by the way, i still have all those reference pictures of the southern leopard frog

#

I'll dm them to anyone who wants

raven halo
raven halo
keen forge
#

i like these little clips of progess a lot

raven halo
#

thanks, ill keep spamming them

#

maybe I record each hit resolution in an array then undo whatever is invalidated by slope physics

raven halo
#

i feel an urge to buy a monitor and gpu despite not playing anything demanding in months

#

maybe a monitor makes sense since mine is small and 60hz

worldly acorn
#

So is mine lol it doesn't bother me

raven halo
#

ive heard praise and glory for 120hz

prisma otter
#

Don't buy a GPU lol, you will never financially recover KEKW

#

120hz is amazing but you will not be experiencing it unless you are playing older games or have an insane GPU

raven halo
#

tax returns baby, immeaserable wealth and fortune unto me

keen forge
#

a large monitor makes programming on it a sexy time

raven halo
#

i could also convert my pc to sff, but thatd require a new mobo and psu

#

and likely all new cooling

#

the worst thing about my current monitor is that it only has 1 hdmi port

keen forge
#

i have a shitty samsung neo g7, its a 43", 4k, 144hz with some pseudo hdr

#

its shitty because its not oled hehe, but large fonts in 4k look neat in the IDE

#

or even kmscon on lunix when ze puter is booting

#

satisfactory looks great on it (probably because you do get some hdrisms, and you usually dont really have dark spots in that game)

#

check rtings.com and or hardware (or now monitor) unboxed on youtube

#

before that one i had a 32" 1440p monitor that was a nice upgrade already, i would never go below 32" again, ever .... if you have space

raven halo
#

is oled that good?

#

I've never tried it

keen forge
#

ive never seen it in person but its supposedly like once you have it you dont want to go back ๐Ÿ˜„

dry basalt
#

like half the time in ff7 rebirth if im not in an area with dense foliage, ez 120fps

prisma otter
#

I assume you are using FSR to do that

raven halo
#

oled is probably out of the budget

dry basalt
#

Usually get 70-100 fps, dips into 60 sometimes

#

At 1440p

raven halo
#
  1. Detect collision
  2. Apply resolution
  3. Repeat 1&2 until no collision is detected
#

ofc getting stuck inside a block will crash the game

raven halo
#

or i try resolving collision starting with tiles closest to the center

raven halo
#

the way I did it at first was accumulate a resolution vector for all regular tiles, but if the player collided with a slope tile, the resolution would immediately apply directly to the position

#

now its consistent in that slope resolution is added to the accumulation res vector

#

well I can't complain

#
if (hit.intersection && (hit.delta.x > 0.0f || hit.delta.y < 0.0f || pos.y < tilePos.y))
{
    delta += hit.delta;
    return false;
}
else if (hit.intersection && relativePos.y < relativePos.x + hitbox.max.x)
{
    if (hit.delta != glm::vec2{ 0.0f, 0.0f })
    {
        float desiredY = std::min(tilePos.y + std::max(relativePos.x + hitbox.max.x, 0.0f), 
        tilePos.y + 1.0f);

        delta.y += desiredY - pos.y;
    }

    return false;
}
else 
{
    return false;
}
#

this is the resolution code for a left-facing slope tile (i.e., y = x). Read and weep serfs

#

i should add more comments to my code methinks

raven halo
#

unfortunately its not a magic bullet

#

aaannnd messing with reaper broke sdl3, so now my crap doesnt compile

#

easy fixz

#

so the final remaining physics bug is as follows:

#

collision resolution from slopes is always vertical so theres no horizontal push to prevent this

raven halo
#
if (thereWasVerticalCol)
{
  vel.y = 0.0f;
}
else if (thereWasHorizcol)
{
  vel.x = 0.0f;
}
#

since the slope is a vertical col, any subsequent horiz col wont reset the horiz vel

#

so that buggy collision detection still occurs but doesnt do anything perceivable due to this cursed thing

raven halo
raven halo
#

betteryet, if downwards resolution is applied when theres already upwards, then -displacement.x should be applied to horizontal res

#

more on this later

raven halo
#

i dont even care about half life. i just see the hope gifs and my day gets a little brighter

prisma otter
#

Hope is a nice thing to have, the gif is very well done

keen forge
#

HL1 > HL2

mystic kettle
keen forge
#

i disagree, but ^ this ^ a funny response

raven halo
#

theyre both cool peices of history but not very good games

#

gaming got much better in 2004 when fun was imvented

keen forge
#

roblox/wow fanboy spotted

hushed crescent
#

roblox would've been 2006/2007 at least

#

I assume its 2004 because of cave story

raven halo
#

yeah well i take it back, i forgot about mgs2

#

but cavestory, mgs3, and the NDS in 2004

#

then all the wii stuff in 2006

raven halo
#

the sun is slowly returning

#

were gonna make it

raven halo
#

i finished better call saul season 1, the colors were very vibrant

raven halo
#

this was shot in 2015? i couldve sworn we had lost color tv by that time

raven halo
#

rediscovery of the century

raven halo
#

well driving in this blizzard tonight i became a sailor

raven halo
#

i have begun the joys of html and css webdev

#

you react with the bleakekw but i am having fun

worldly acorn
#

I've just heard things

#

The only web dev I've done was writing HTML by hand which is quite ok and results in positively based looking sites

raven halo
#

well im making myself a website

#

but I'll keep that on the low for now

worldly acorn
#

Neat

raven halo
#

internet archive?...

worldly acorn
#

Lmao

raven halo
#

i understand this is an edit of the laughing guy but it looks like that fnaf duck

raven halo
#

incoming crunch

#

big annotated bib for english and huge project for history due within 1.5 weeks

raven halo
#

i have a puppy german shepherd i need to watch, so i cant really sit in a small room with my desk

#

I'm mostly hunched over on a couch with a laptop in my lap

prisma otter
#

~~He's ~~ She's so cute froge_love

worldly acorn
#

The ear ratio is out of control

hushed crescent
#

I'm all ears

raven halo
#
  1. the guitar riff in the verse is great, and so is the harmonization
  2. Carlos Santana intro
  3. conveys an emotion I've never gotten from a song before
raven halo
raven halo
#

i dont like gen ed chemistry class

#

the stereotypes are true, theres no learning the how or why, just memorizing rules and letters

#

fortunately there shouldnt be anymore of this or english to complete my degree

#

i think itll just be compsci, circuitry, physics, and math stuff which should be good fun

worldly acorn
#

That's just how chem is

#

It's practical

#

It gets easier

#

There isn't really any way to derive it from first principles, at some point you're always going to just have to remember the priorities of the periodic table

raven halo
#

yeah I'm good

#

the crickets are chirping and the stars are visible

raven halo
#

metric system is pretty dope

#

i like that when you convert between units, "1" is a pretty solid guess

prisma otter
#

He's seen the light

raven halo
#

it blew my mind to learn cm^3 is a mL

prisma otter
hushed crescent
#

if you guessed 0.157 stone, you are right

mystic kettle
#

Which stone

raven halo
#

that one

mystic kettle
#

I imagine that's how empirical system was made

worldly acorn
#

The only thing I don't use the metric system for is the temperature of the weather and aircraft altitude

#

Oh and human weights and heights

#

Just don't have an intuition for the metric versions of those

raven halo
#

i think the school work load will subside a bit so hopefully i can get back to this

#

i want to do the physics in substeps, maybe 8, so i dont need to rely on my perfect collision res as much

#

then ill give our little red box a remington 870 or something

raven halo
#

scratch does a lot of really weird stuff but ngl i miss /0 returning infinity

#

i know its not technically correct but i think it makes a lot more sense in practice than return nan

#

but i suppose we do want to keep c++ consistent with accepted math

prisma otter
#

I mean also the hardware will generate a NaN so it's best to just what the hardware does

#

It's not even really a C++ thing

#

Until c++20 I think the standard allowed floating point math to be entirely implementation defined

#

But they changed it to follow the IEEE standard

#

Which in practice is what the hardware does anyway

raven halo
#

added substeps and with only 4 the physics is already smooth as butter ๐Ÿ˜ฉ

#

i spoke too soon

#

i call this the gauntlet

raven halo
#

call my physics theoretical the way it guesses where the player should be

#

i am once again splitting collision across the axises because any viable combined solution i dabbled in, like sequential impulse, is overkill

#

who in the world need sequential impulse for a metroidvania? anyways, I now solve the slope collision in the vertical half, which is done before the horizontal half

raven halo
#

the solution? temporarily apply the horizontal displacement for that frame to calculate how high up the slope to go

raven halo
#

the only glaring issue remaining is that slopes can push the player into a block above his head, and im dreaming up a hack to fix it

hushed crescent
#

Dope Rhymes: Lee=Emceeยฒ
Sick Beats: "Caged Bird (Instr.)" by RJD2

I wake up and take a look around me, astounding,
I'm stranded in strange and cavernous surroundings,
Robot built with scientific efficiency, but
Who I am and how I got here is a mystery
To find out, I'ma have to explore,
My adventure started when I walked through the door,
It's ...

โ–ถ Play video
#

reposting, if you want the direct 4ching link just let me know

raven halo
#

developer is listening

#

and it slaps

raven halo
#

i am a certified genius

#

heres physics

raven halo
#

@hushed crescent the Cave Story Lyrical Walkthrough has inspired me, i will now be attempting to beat the Sacred Grounds with minimal HP

#

words cannot express the difficulty of this challenge

raven halo
raven halo
#

i have introduced the scene struct

#

bikeshedding time

raven halo
#

alright guys

#
struct Scene
{
  Level level = {};
  LevelEditor levelEditor = {};
};```
or
```c++
struct Scene
{
  Level* level = {};
  LevelEditor* levelEditor = {};
};```
#

well the editor is more of a system so ig that shouldnt be in there

raven halo
#

i think direct ownership will make the most sense

#

so the question now is what does and doesnt belong in the scene struct

#

i.e. whats part of the scene and whats not

#

ig the player is part of the scene, so he can go in it

#

level is, level editor is not since its a system

#

(level refers to the tiles)

#

then there will need to be entities and enemies

#

pretty easy right

prisma otter
raven halo
#

also sooner than later i should give bullet better collision detection

#

since they move fast, i should give them longer hitboxes or something

hushed crescent
#

projectiles are usually fine being raycast

#

or shapecast if they're big enough

raven halo
#

ah yeah raycasting!

raven halo
#

going along nicely

#

i might want some sort of event system

worldly acorn
#

I forget are you doing this project ECS-style

raven halo
#

nah

#

there arent too many entities to worry about yet anyways

#

just the player and his bullets

#

so my scene update looks like this ```c++
void Scene::update(float deltaTime, std::unordered_map<SDL_Keycode, bool> keyStates,
bool updatePlayer)
{
if (updatePlayer)
{
player.update(deltaTime, keyStates, level, bullets);
}

updateBullets(deltaTime);

camera.pos += (player.pos - camera.pos) / 100.0f;

}

worldly acorn
#

Yeah

#

Just the most direct way

#

What are you thinking of making events for

raven halo
#

so at the very least, some way for the player update to send data back to the scene. ig thats more feedback than events

#

ill probably just return something like vector<Event> from Whatever::update()

#

anyways heres entities

#

i gotta give them guns too

worldly acorn
#

I don't think scene changes and stuff necessarily need events

#

Personally I think I'd just set a flag in the game state that a global game system then reads at the end

raven halo
#

oh yeah flags

#

maybe i keep those flags in a 64 bit enum and return state changes from a function

#

sfx? maybe i just let anything anywhere make a sound effect

#

demon synthesize me some sounds man

worldly acorn
#

I would just fill your struct full of bools

#

Don't worry about packing them unless you need them to be sent over the network or something

#

You can find free sfx I can try to help you make some later

prisma otter
raven halo
#

sometimes your RAM needs rest, thats what bools are for

#

@keen forge youll love this one

raven halo
raven halo
#

i did not enjoy inception

#

if you take away the novelty of shared dreams, its just a bad action movie

#

there were also no moments of silence, there was some royalty free esque orchestra track playing throughout the entire movie

#

this is the same guy that made inception? wow

raven halo
prisma otter
#

Rip

raven halo
#

well, "2D Game" has earned the latter part of its title

raven halo
#

clangd broke and all my code has the red underline ๐Ÿ™

keen forge
#

that usually fixes itself when you restart the ide

#

i have clangd crash more than once today too for some reason

raven halo
#

Anyone dabbled with sdl's text rendering? Is it any good?

keen forge
#

i have not, or not that i remember

raven halo
#

@prisma otter what do you use?

#

for text rendering

#

Happy Easter everyone btw

prisma otter
raven halo
#

its always a great pleasure when an NVidia driver update on linux REDUCES the opengl version

raven halo
#

i dont really play demanding games anymore so im considering yeeting my 3050 in favor of some cheap amd card

#

especially if it will let me use wayland and hdr

prisma otter
#

AMD is pretty good on linux

#

But I can use wayland on Nvidia it works great

#

As for HDR...

#

I wouldn't count on it lol

raven halo
#

darn

raven halo
#

psa

#

do not update to nvidia driver 595

#

it, at least on my system, did not include 32 bit drivers

#

stay on 580

prisma otter
#

Unless you mean windows

#

But i thought you were on linux

raven halo
#

steam seems to want a 32 bit driver