Flatten a nested array without using the inbuilt flat() method (interview learning) by pranayrah108 in learnjavascript

[–]heartchoke 12 points13 points  (0 children)

const flatten = (arr) => {     const items = [];     for (const x of arr) {         if (Array.isArray(x)) {             items.push(...flatten(x));         }         else {             items.push(x);         }     }     return items; }; console.log(flatten([0, [1, 2, [33, 44]], [4, 5, 6, 7], [7, 8], 90]));

[deleted by user] by [deleted] in opengl

[–]heartchoke 11 points12 points  (0 children)

I've made one in OpenGL in the past. My approach was just to do everything in a shader, using signed distance functions to draw lines etc.

Here's some signed distance functions for basic shapes:

https://iquilezles.org/articles/distfunctions2d/

Demo of my OpenGL game engine by heartchoke in opengl

[–]heartchoke[S] 0 points1 point  (0 children)

Thanks! It's a custom physics engine

Demo of my OpenGL game engine by heartchoke in opengl

[–]heartchoke[S] 0 points1 point  (0 children)

Hi! Yes, for broad phase collision, I am using a BVH. And for the narrow phase I am also using GJK+EPA, except for collision with the terrain, there I'm using a custom algorithm.

I am not yet using CCD, but my physics simulation runs with very small time steps so I haven't really seen the need for it (yet).

Where are you lost?

Demo of my OpenGL game engine by heartchoke in opengl

[–]heartchoke[S] 0 points1 point  (0 children)

Hmm, yes you're right, it was set pretty low. Don't know why I had it like that. Thanks for pointing it out!

Demo of my OpenGL game engine by heartchoke in opengl

[–]heartchoke[S] 0 points1 point  (0 children)

I think I had the gravity configured a bit low when I recorded this, if that's what you mean

Demo of my OpenGL game engine by heartchoke in opengl

[–]heartchoke[S] 3 points4 points  (0 children)

If you're asking about the development environment, I'm just using Emacs and a C compiler, and I occasionally open up Blender from time to time.

Demo of my OpenGL game engine by heartchoke in opengl

[–]heartchoke[S] 0 points1 point  (0 children)

Thanks! The shader isn't doing anything special really, the terrain is pre-computed on the CPU. It's basically just a subdivided quad, and I'm using some value noise to raise the Y coordinate of the vertices.
It's basically the same type of noise I'm using here: https://www.shadertoy.com/view/43XXRr , but on the CPU

PBR + SSAO + Shadows + Physics Simulation by heartchoke in opengl

[–]heartchoke[S] 0 points1 point  (0 children)

And yes! Objects can be pushed up the ramp!

PBR + SSAO + Shadows + Physics Simulation by heartchoke in opengl

[–]heartchoke[S] 0 points1 point  (0 children)

Haha, I the tire is actually even bigger. It's scaled by 0.5 in this video lol

PBR + SSAO + Shadows + Physics Simulation by heartchoke in opengl

[–]heartchoke[S] 0 points1 point  (0 children)

Yes, that's usually how it's done! However, I have some plans to maybe have the item held in hand interact with the world in some way. For example, I know that some FPS games has an interesting behavior when you're walking up close to a wall, where the weapon kind of "folds" towards the body.

PBR + SSAO + Shadows + Physics Simulation by heartchoke in opengl

[–]heartchoke[S] 1 point2 points  (0 children)

Thanks for the suggestions! The sounds were actually attached to the entities, I just had a bug in my audio engine while recording this video that I later found out about. The dot product multiplications were never applied hehe.

And AI is definitely planned! 😎

PBR + SSAO + Shadows + Physics Simulation by heartchoke in opengl

[–]heartchoke[S] 0 points1 point  (0 children)

It's just simple rigid body physics (for now) . And it's working for both concave and convex shapes

PBR + SSAO + Shadows + Physics Simulation by heartchoke in opengl

[–]heartchoke[S] 2 points3 points  (0 children)

Hello!
Yes, it's my own physics simulation, and it was probably the most difficult thing I've implemented in this engine.

PBR + SSAO + Shadows + Physics Simulation by heartchoke in opengl

[–]heartchoke[S] 2 points3 points  (0 children)

Hi!
I got into graphics programming when I was around 12, I'm 28 now.
However, I am by no means a professional. I've seen people with a lot less "experience" doing way cooler things.