Iros

Use this forum to share and discuss Uzebox games and demos.
User avatar
nicksen782
Posts: 667
Joined: Wed Feb 01, 2012 8:23 pm
Location: Detroit, United States
Contact:

Re: Iros

Post by nicksen782 » Sat Sep 23, 2017 4:25 am

How would this work? Granted, I'm asking for my own game that has jumping in it. I'm only doing a simple set of frames for y-- followed by y++ until the character lands.

User avatar
Artcfox
Posts: 944
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: Iros

Post by Artcfox » Sat Sep 23, 2017 5:38 am

L4rry wrote:
Fri Sep 22, 2017 7:46 pm
I went through various jumping curves and platform heights during development. In the end, I decided on the current feel after having to get rid of using floating point numbers for my physics because it's too slow and takes up too much memory (and even flash space). So I'm using integer calculations with frame counting for precision. And it's not very precise as a result. It seemed a good balance in the end.
I used all integer-only calculations for the entire physics and collision system in Bugz, and then later added subpixel calculations (fixed point) so if you want to take a peek how Bugz does it, look at the structures defined in entity.h and the entity_update function in entity.c from https://github.com/artcfox/bugz

The end result is pretty complicated (because I added one-way tiles, and ladders), but if you look through the git history, you'll be able to see how my physics engine started (really simple) and then progressed as I added more and more stuff to it.

User avatar
Artcfox
Posts: 944
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: Iros

Post by Artcfox » Sat Sep 23, 2017 5:55 am

Here is the physics tutorial I followed when creating Bugz: http://codeincomplete.com/posts/tiny-platformer/

If you read that article and his next tutorial, you should be able to follow the Bugz source code a lot easier, because my engine started out as a direct C port of that JavaScript code, and then completely evolved from there from floating point into integer math, then I fixed a bunch of bugs that he had in his engine, and then I added one-way tiles, ladders, fire, and then I converted everything into fixed point math. (I used enough of his tutorial code that I felt it appropriate to credit him in my copyright notice for the engine.)

There are tons of little things that go into platformers that I had no clue were there until I made one without them and it felt awkward to play. That's all the polish and special cases in my code, like variable height jumping, being able to jump for X frames after "falling" (so you don't have to get the timing just perfect for jumping off the edge of a cliff, because humans won't) or being able to press jump before you hit the ground and still having it register when you finally do hit the ground (because again, if you want to jump as soon as you hit the ground, you'll press jump too early and it won't register because you are still technically falling), or if you are under a low ceiling and you press jump, it doesn't register until you aren't under the low ceiling any more (because again you'll press jump too early), etc... Getting Bugz polished up like that is what took the most work, so even though I started out following a tutorial, in the end I really felt like I transformed that code into something that I can call my own.

There are tons of great links at the bottom of his tutorial that describe a lot of what goes into 2D platformers that I ended up implementing. I spent weeks and weeks reading whitepapers and everything I could get my hands on about 2D platformers. "Level Up! The Guide to Great Video Game Design" is a great book that I'd recommend as well.

User avatar
L4rry
Posts: 239
Joined: Sun Dec 28, 2014 7:19 am
Location: Cape Town, South Africa

Re: Iros

Post by L4rry » Sat Sep 23, 2017 9:38 am

fixed point calculations. Never considered it. Thanks for the tip! I'll definitely have to look into that going forward with new projects.

User avatar
Artcfox
Posts: 944
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: Iros

Post by Artcfox » Sat Sep 23, 2017 10:06 am

L4rry wrote:
Sat Sep 23, 2017 9:38 am
fixed point calculations. Never considered it. Thanks for the tip! I'll definitely have to look into that going forward with new projects.
What really made fixed point "click" for me was someone asking me what the X and Y boundaries of the screen are, and then telling me to do all my calculations as if the boundaries were double or quadruple what they actually are. So instead of my X coordinates being 0-240, they could now range 0-960 (240 << FP_SHIFT), and do the same with Y. And carry that all the way through the physics calculations, and store it that way internally in the entity structure. You'll see that in my calculations that involve tiles, I use (TILE_WIDTH << FP_SHIFT) because I wasn't sure how many subpixels I wanted to use. I decided on an FP_SHIFT of 2, so I essentially treated the 8x8 tiles and sprites as if they were 32x32 pixels. Then only when it is time to actually render stuff and set the sprite coordinates in the kernel, you shift by FP_SHIFT the other way and that truncates the subpixels, but your internal x, y, dx, dy, ddx, ddy are still calculated with subpixel precision, so any remainders get carried through to the next frame making the motion and acceleration curves look super smooth.

If you look closely, one of the "polishing tweaks" I had to do after switching to fixed point was make a temporary truncated calculation in the physics engine for the X position because if it looked like you should fall down a hole on screen, I wanted you to actually fall down. Otherwise it was damn near impossile to fall down a 1 tile wide hole because you'd have to stop the little guy with all the invisible subpixels at 0. The symptom was it would look like you are standing over empty space next to a cliff, but internally your foot was still a subpixel or two (or three) on the cliff, causing you not to fall.

User avatar
Gosma
Posts: 66
Joined: Thu Oct 24, 2013 7:31 pm
Location: Santos, Brazil

Re: Iros

Post by Gosma » Wed Oct 04, 2017 8:18 pm

Just passing by...

Amazing work you have!

User avatar
L4rry
Posts: 239
Joined: Sun Dec 28, 2014 7:19 am
Location: Cape Town, South Africa

Re: Iros

Post by L4rry » Wed Oct 04, 2017 11:20 pm

Gosma wrote:
Wed Oct 04, 2017 8:18 pm
Just passing by...

Amazing work you have!
Thanks Gosma, I do try!

User avatar
Jubatian
Posts: 1355
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Iros

Post by Jubatian » Sun Jan 14, 2018 9:42 pm

I didn't think I could complete the current release, but I did! :)

I got a score of 2574, guess not much, I was really really praying to get through the levels themselves. The bosses once knowing what to do weren't hard, maybe the final boss after the last space shooter stage is a bit too repetitive. Maybe randomize firing somewhat so it can not be done by repetitive sweeps? (Tank Fu's boss is still amazing by the way, there you also did a change, now that submarine is impossible for me & friends, but that just adds to the coolness factor in that game after a two player match-up)

The space shooter stage is great for Mode 3. Maybe give it a compile with the newest kernel, on later stages it occasionally seems to repeat frames due to (still) running out of CPU, and the new inline mixer is faster, giving you more VBlank time which could get this better again.

User avatar
L4rry
Posts: 239
Joined: Sun Dec 28, 2014 7:19 am
Location: Cape Town, South Africa

Re: Iros

Post by L4rry » Mon Jan 15, 2018 6:36 am

Jubatian wrote:
Sun Jan 14, 2018 9:42 pm
I didn't think I could complete the current release, but I did! :)

I got a score of 2574, guess not much, I was really really praying to get through the levels themselves. The bosses once knowing what to do weren't hard, maybe the final boss after the last space shooter stage is a bit too repetitive. Maybe randomize firing somewhat so it can not be done by repetitive sweeps? (Tank Fu's boss is still amazing by the way, there you also did a change, now that submarine is impossible for me & friends, but that just adds to the coolness factor in that game after a two player match-up)

The space shooter stage is great for Mode 3. Maybe give it a compile with the newest kernel, on later stages it occasionally seems to repeat frames due to (still) running out of CPU, and the new inline mixer is faster, giving you more VBlank time which could get this better again.
I'm glad you made it through :) Yeah, with the current build, it's not to challenging to complete once you figure out the patterns. Thanks for the suggestions too. I think I'll implement some improvements to the game as a way to verify my new windows development environment. So look forward to the following in the near future:
  • Add alternate boss strategy (or two) that is selected at random so as not to have a single behavior pattern.
  • Add version string to splash screen.
  • Move credits to game startup screen and include credit for music in the game itself
  • Build with latest kernel
  • Add some unpredictability to final boss battle

User avatar
L4rry
Posts: 239
Joined: Sun Dec 28, 2014 7:19 am
Location: Cape Town, South Africa

Re: Iros

Post by L4rry » Fri Jan 19, 2018 11:06 am

Jubatian wrote:
Sun Jan 14, 2018 9:42 pm
I didn't think I could complete the current release, but I did! :)

I got a score of 2574, guess not much, I was really really praying to get through the levels themselves. The bosses once knowing what to do weren't hard, maybe the final boss after the last space shooter stage is a bit too repetitive. Maybe randomize firing somewhat so it can not be done by repetitive sweeps? (Tank Fu's boss is still amazing by the way, there you also did a change, now that submarine is impossible for me & friends, but that just adds to the coolness factor in that game after a two player match-up)

The space shooter stage is great for Mode 3. Maybe give it a compile with the newest kernel, on later stages it occasionally seems to repeat frames due to (still) running out of CPU, and the new inline mixer is faster, giving you more VBlank time which could get this better again.
nicksen782 wrote:
Sat Sep 09, 2017 8:03 pm
In the future it would be wise to also include the version number on the game's title screen.
I've created release v2.0 for Iros. The roms are linked in the original post or you can grab them from the wiki

Release Notes:
- Each end-of-level boss now has subtle strategy variations
- Final boss has variable shot speed and behavior. Makes for a sterner challenge.
- Added attribution screen when the game boots.
- Added game release version string on the attribution screen.
- The final level bonus is multiplied by the lives remaining. The base value is now 200 instead of 500.
- Compiled with latest kernel.

If you want to check out the changes but don't want to play the entire game, feel free to use the god mode builds.

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests