Pix Engine: Platformer Engine

I understand that, but this is not a game, this is an engine… if you see this from the engine perspective, everything is working fine.

2 Likes

yeah it like unity is a engine not a game

Yes, but a lot smaller. It would be at the end a small engine / set of tools for people to make games

1 Like

This is a pretty solid engine, but one thing that worries me is the fact that static collisions work by storing a 2,764,800 item array in this demo. I know computers have a lot of RAM but if every element took up one byte (which is very unlikely each element in an untyped array probably uses more than one byte), that would be a 2.76 mb array. Which is a lot of memory. It’s bigger than the Forum Fighters file. I’m pretty sure there’s a less memory-intensive way of doing this. For example, space partitioning. Also I’m nitpicking but it’s never spelled “Physic” despite Unity’s API spelling it like that sometimes. It’s always “Physics”.

Thank you for your important feedback as always.

Thanks, I’m currently trying to make it so it is easy to use…

That is almost right, 3 720p screens @ pixUnit of 10. ((3x1280x720)/10 = 276,480)… ten times less… The engine has the pixUnit as a setting, so users can set this to pixUnit to 1, and then we would have your number in this demo. We don’t need a pixUnit of 1, is too greedy.

Yes. It is very unlikely that a machine can’t allocate some MBs in RAM for a game these days. In other hand, processing frame by frame (in Wickeditor) is a problem. That’s why I rather prefer getting this small hit in memory (which for most users would be totally transparent), than having the engine, for every single frame, verifying for every single platform, enemy, bullet, etc if they collide.

The performance results are great, I’m able to run this small demo using my low-end computer at almost 60fps. The same machine couldn’t run Flashy Adventures at 30fps, it went down to 20fps or lower in some game parts.

It could, in some cases, depending on stage size… and it can be definitely optimized… I’m storing object’s indexes… but I could store object’s references… or I could store const zeroes for the free spaces… I would have to experiment a little bit it these make any difference at all…

Every Level will use the same array… so the array will always load at run time when you start a level… so when you transition from level to level, the array will be deleted and then created again.

I’m pretty sure that you know the difference between memory and file size, so you are just doing an analogy I think.

It should, and if you want to find a better way to accomplish this, you are more than welcome to collaborate with me in this project. (At the same time, it would not represent a problem in almost any PC)

lol I know… in Spanish “Física” doesn’t end with ‘s’, which in Spanish we use it for plural… Similar to English. I might do a find all / and replace all the instances of “Physic” to correct it.

Oh, ok. I was looking through your code (I ripped it from the html file) and didn’t notice the default setting. Or what most of it was doing.

But I was thinking of a way to decrease the size of that array yet still retaining the same useful data. I see that in your code you’re using a regular Array that stores “pointers” to each platform. As far as I know, it only uses these pointers to get the class type of the platform. So a memory optimization I suggest is making an array of 4-byte integers, and each element would represent the class type of the platform. You would do this by using a Uint8Array, then treating the lower and higher half of each byte as a separate element using bitwise operators. I’m sure 16 different recognizable class types is enough.

For example, to initialize the array you would write

this.table = new Uint8Array(Math.ceil(this.maxCol * this.maxRow / 2));
// divide by 2 since each byte holds 2 elements

and to extract the higher and lower 4 bits of each byte you would write

var byte = this.table[i];
var hi = (byte >> 4) & 15;
var lo = byte & 15;
2 Likes

I was looking for these kind of things in js, and I was under the impression that I could not manage to have a fixed 8bit element array type… if this exists, then the hit in memory would almost disappear.

Within the engine, every platform, door, etc… is represented by a number within that array… if we had a huge Level, we would need to have 255+ platforms or walls to get to 8 bit element limit… Within this demo I have 53 as a maximum number… I could see levels with more than 255, so I think that 16bits array should be the way to go…

Update: Thank you… I think you are into something here… I’ll take a look to your approach:

1 Like

Not only the type, because I need the instance as well… the instance has data like position, platform friction for that specific platform etc…

1 Like

Thank you @pumpkinhead… It seems that js uses 8 bytes to store a single number… We may be improving the mem alloc 4 times by using a Uint16Array which allows the engine to store at least 65535 different platforms, portals, collectibles, etc… per level… which is more than sufficient :star_struck:

1 Like

Here is what I ended up doing… It will be asking for more memory resources based on end-user needs…

Screen Shot 2022-02-19 at 1.21.59 PM

I’m still very busy, but from time to time I’m working on fixing bugs and adding stuff. There is a lot to do, but I’ll be releasing the first version of this engine most likely within the next month, so stay tuned.

2 Likes

Engine under this link:
https://drive.google.com/file/d/1wXmV5_Hd2HWM7sOKuZhBhpWWI1DTuz2a/view?usp=sharing

Engine Tutorials here:

2 Likes

how do I get rid of the grid in the bg when I press play?

1 Like

That will be discuss in the next tutorial. You are running the engine in debug mode. I’ll tey to put together the next one for this tuesday at ETC night.

1 Like

it bugged out and now it wont let me place anything

Yup, it is important to save your work constantly… but in most of the cases for 1.19.4, you should be able to refresh the page and reload the work if you only have one wick editor tab open at the time.

this engine works really good and I like it, I would still rather use @awc95014’s engine tho because its easier to work with and the one downside to your engine is that you have to be ultru precise on where you place the blocks and it is takes a lot of time to actually make something with it. im not trying to say that your engine isn’t good or anything, Im just saying that its a little too advanced for me and it just takes a bit too much time for me.

1 Like

Yes, we have now 3 to 4 platform engines to use. I love @awc95014 engine as well. :blush:

You could also try to decrease your pixUnit to 1. So then you dont have to be that precise anymore. The downside is that requires more memory from your machine.

Hey @Jovanny I made a little platformer, adventure game based off of Hollow Knight using your engine & I was wandering if you can either implement or teach how to add wall jumping to my character.

1 Like