Join us on Discord!
You can help CodeWalrus stay online by donating here.

Metal Slug: Assault

Started by matrefeytontias, March 14, 2015, 11:52:39 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

matrefeytontias

Well I did want to write about it anyway, but I wanted to wait until I had at least something to show. Since you asked for a description, well, there you went :P

It's usually true that developers are more inclined to work on a game if they see that people want to hear about it. I think daily activity is good, but only as long as it is constructive, because if said activity can be summed up as a guy posting "what's new ?" every day, then yes it's going to be annoying.

Of course there are benefits. Programming in assembly lets you make programs that run as fast as they can get, and since the game will be pretty heavy I wanted to be able to perform a maximum of optimization. Besides, and as you said, I've always wanted to make a real game with ASM.
  • Calculators owned: TI-83+.fr, TI-Nspire CAS prototype, TI-84+ CSE, TI-Nspire CX
My TI games (some got their own article on non-calc websites !) : http://www.ticalc.org/archives/files/authors/112/11202.html

My moozik (100% free metal) : http://www.soundcloud.com/matrefeytontias

Dream of Omnimaga

It depends of the person. If some people get bugged enough, it can actually produce the opposite effect or even the project demise, because some authors collapse under pressure. Hence why it's best to not do it too often. Also, when newbies bump the topic 1 year after the last update and everyone thinks a new update was posted right before, then it gives false hopes.

Also I hope you don't have too much of an hard time coding this in ASM Matref, especially with all the hit boxes and collision stuff.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

matrefeytontias

Don't worry about that, that's the fun part :P if it's too easy it's no fun.

Also, I successfully implemented non-vertical lines physics. In the following screenshot, imagine that the lines are there, because I'm too lazy to draw them and they won't even be drawn in the final game anyway :P

  • Calculators owned: TI-83+.fr, TI-Nspire CAS prototype, TI-84+ CSE, TI-Nspire CX
My TI games (some got their own article on non-calc websites !) : http://www.ticalc.org/archives/files/authors/112/11202.html

My moozik (100% free metal) : http://www.soundcloud.com/matrefeytontias

Duke "Tape" Eiyeron

Nice work, pal! We can't wait to see moar progress coming!
  • Calculators owned: A lot.

aetios

ceci n'est pas une signature

Dream of Omnimaga

Quote from: matrefeytontias on May 10, 2015, 06:18:00 PM
Don't worry about that, that's the fun part :P if it's too easy it's no fun.
they won't even be drawn in the final game anyway :P


There will be no graphics other than the square in the final version? O.O


Just kidding, nice progress you got there. I'm glad that diagonal lines did not cause too many slowdowns for collision.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

matrefeytontias

Why would they ? Internally they're just like any other line.

Also, I probably said it before but the algorithm I wrote for collision has  O(1) complexity, so that's pretty cool :P
  • Calculators owned: TI-83+.fr, TI-Nspire CAS prototype, TI-84+ CSE, TI-Nspire CX
My TI games (some got their own article on non-calc websites !) : http://www.ticalc.org/archives/files/authors/112/11202.html

My moozik (100% free metal) : http://www.soundcloud.com/matrefeytontias

Snektron

Ohh awesome :D. I want to get to know the inner workings of a physics engine too some day, even if it's just a simple one. Anyway nice progress :)
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


matrefeytontias

This particular "physics engine" if you want to call it that way has nothing particular, really. It's just a trick I thought of that makes use of Cartesian line equations.

I store lines as 10-bytes objects in an array, structured as follows (in parentheses are bytes) : startX (2), startY (2), endX (2), endY (2), vectorX (1), vectorY (1). I store the directional vector as left to right.
Also, I'm tempted to add a vectorC field, that would be the "c" in ax + by + c = 0, a Cartesian line equation. Right now, the equation for a certain line is calculated by vecY * x - vecX * y + c = 0, where c = vecX * startY - vecY * startX (because obviously the point (startX, startY) belongs to the line, so we know the equation equals to 0 and thus we can calculate c). As I'm writing it, I think I'll be precalculating the vectorC value for each line. It's not too much of a hassle anyway.

Here's the current algorithm (note that it's not finished) : for every entity (as in, object that must have physics applied to it) :
  • Apply velocity to entity. For me, it's just adding DX and DY to X and Y, really.
  • Find the line the entity is above/below/on. A line fits if startX <= entityX <= endX.
  • Once you've got the correct line, apply the cartesian equation for this line to the entity : vecY * entityX - vecX * entityY + c, and see the sign of the result.
  • If the result is positive, because I chose to make the directional vector of the line go from left to right, that means the entity is under the line (at its right actually), so there is a collision and the entity needs to be put back on the left of the line. If there were no collision, continue the physics iteration is done for this entity.
  • If there is a collision, put the entity back in place. I do that by resolving the equation for Y with X fixed, so that the entity is "pushed back up" by the ground. Since we have ax + by + c = 0 and b is different than 0 since the line is not vertical, we have y = - (c + ax) / b. By doing this, I have the Y value which is so that the point (entityX, Y) is on the line. Then, I just do entityY = Y + feetHeight + 1, so that the entity is actually one pixel above the line, ie on the ground and not in it.
This algorithm is pretty good because it has no loop, pretty much. The only loop is the one that finds the correct line, but it's only two comparisons, so it's not that bad.

Because of the way it is designed right now, the algorithm does not allow for platforms because it does not allow an entity to be at the right of a line. That is pretty easy to fix though, or at least that's what I believe. The trick is to, for each line that the entity is above/below/on (there can be several platforms on top of each other), do two check steps, once before applying velocity and one after applying velocity. If the signs of the two results of the Cartesian equation are different, it means that the entity has gone through a platform during this physics iteration, and thus must be put back in place. Another small trick is to check only for the head of the entity if DY > 0, and only for its feet if DY < 0, since he moves according to the sign of DY (its Y velocity). I'll be implementing that after vertical lines, which I'm working on right now.
  • Calculators owned: TI-83+.fr, TI-Nspire CAS prototype, TI-84+ CSE, TI-Nspire CX
My TI games (some got their own article on non-calc websites !) : http://www.ticalc.org/archives/files/authors/112/11202.html

My moozik (100% free metal) : http://www.soundcloud.com/matrefeytontias

Snektron

Oh, interesting read :) Does it have a gravity vector?
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


matrefeytontias

Ah yeah I forgot that bit. Yeah, I have a constant that I keep adding to each entity's Y velocity.
  • Calculators owned: TI-83+.fr, TI-Nspire CAS prototype, TI-84+ CSE, TI-Nspire CX
My TI games (some got their own article on non-calc websites !) : http://www.ticalc.org/archives/files/authors/112/11202.html

My moozik (100% free metal) : http://www.soundcloud.com/matrefeytontias

Powered by EzPortal