Lunar Apogee [WIP] - Diagonal Character Movement

Orgia Mode

New member
Hey all, I need my character to move diagonally (on an isometric grid) in my game and I am able to do so by modifying the basic script (For example) from "StartMoving player1_object, MOVE_RIGHT" to "StartMoving player1_object, MOVE_RIGHT_UP" however this moves my character one pixel to the right an one upward. I actually need to move him TWO pixels to the right and ONE up... Understand?

What can I do to achieve this? Thanks!
 

FrankenGraphics

New member
Isometric games typically implement subpixel movement (subpixel acceleration, velocity and postion) on the representative field. They also typically separate the collision map from the representational map to simplify the collision handling a lot - but that's writing a half a new engine from scratch.

The general idea about subpixel movement is that you only move an object position a pixel once you get carry or borrow on that objects' subposition variable for that axis. A game with acceleration typically has subpixel movement, and so that's good for isometric games too. I haven't been able to look at NESmaker just yet but from the acceleration scheme in the tutorial that seems to be the case? So basically, what you want to do is make sure to halve the velocity that goes into your sub yPos counter, whatever that variable might be called. The procedure for dividing something by 2 in 6502 assembly is dead simple, since it's just one instruction. If the value to be divided is in the accumulator, then write LSR a. If you want to divide a variable somewhere in RAM, then write LSR MyVariable. That makes the accumulator or the variable halved.

In a simpler movement scheme without the need for acceleration on any actor, a simple bit flipping that represents ".5 pixels" could be had for the y axis. Each movement attempt, check if bit is 0. If so, bit is 1. On the other hand, if bit is 1, set bit to 0 and change y position by one. In assembly that is done with the BEQ or BNE instructions, which checks if a byte is = zero or nonzero, respectively, and if so makes a small jump to the address specified, circumvening code in-between.

Note that a position of 0.x pixels can never be represented by the graphics on the field of play, naturally, but that's the best that we've got and it looks right enough.
 

Orgia Mode

New member
So I guess Im in trouble then... I was going to leave collision detection and other assorted bits for after graphics design... I'll have to come up with a new idea before October then, huh?
LunarApogeeProto.PNG
LA2.PNG
Objects1.PNG
 

dale_coop

Moderator
Staff member
Incredibly beautiful graphics! o_O
I would have better knowledge in ASM, I would have help you (...still learning).
 

Orgia Mode

New member
dale_coop said:
Incredibly beautiful graphics! o_O
I would have better knowledge in ASM, I would have help you (...still learning).

Thank you Dale!
I have put much more time and effort into these assets than I would like to admit. I will not discard them though, I'll just have to wait it out and put Lunar Apogee on the backburner.
In the meantime I will consider other game ideas.
 

Goaterby

Member
@Orgia Mode

With tweaks to the tile positioning / sprites I think you can get away with realistic bounds and movement. Normal diagonal movement in an isometric space, unless you need it to be on a perfect grid for gameplay purposes, seems to look good enough in many cases. I have an example here:

You can see how the bounds of the room FEEL pretty isometric, even if it is not perfectly calculated movement / collision. It did take me a while to figure out how to make each tile fit properly within the 16x16 metatile arrangement though... Your stuff looks super neat (it reminds me of Solstice!) and will probably look fine even with diagonal movement that is not strictly 2:1 or whatever.


ozuIpLN.gif
 

Orgia Mode

New member
Goaterby said:
@Orgia Mode

With tweaks to the tile positioning / sprites I think you can get away with realistic bounds and movement. Normal diagonal movement in an isometric space, unless you need it to be on a perfect grid for gameplay purposes, seems to look good enough in many cases. I have an example here:

You can see how the bounds of the room FEEL pretty isometric, even if it is not perfectly calculated movement / collision. It did take me a while to figure out how to make each tile fit properly within the 16x16 metatile arrangement though... Your stuff looks super neat (it reminds me of Solstice!) and will probably look fine even with diagonal movement that is not strictly 2:1 or whatever.

That looks fantastic and yes, Solstice was a major influence on my childhood. So thank you for comparing the two.
I agree that the tile collision not being 1 to 1 would still be playable, but I wanted platforming elements such as in Solstice. Heavy use of a z-coordinate to simulate climbing the tower. I suppose I could have warp tiles on backgrounds that look like stairs instead of actual elevated tiles or elevators, but I feel like that kind of cheapens my vision. You see, my character was going to be unarmed so game play would consist of finding creative ways to avoid the roaming monsters as opposed to shooting them.

I love the rounded brickwork on your walls and door frames as well as your excellent usage of lighting both in the upward and downward stairways. Can I ask how many different background/ screen assets you have on screen?
 

Goaterby

Member
Hmm yeah I dunno about the Z issue. Maybe what you could do is make a smaller tileset, or characters whatever so you can fit more on screen and simply have each screen be more winding so that there are multiple paths to sneak around patrols or something... Or maybe have the warps themselves lead to the different routes you can choose from? It sounds like a tough problem to solve, I wish I could be of more help but my grasp of 6502 ASM is tenuous at best.

In regards to how I fit the stuff, I have included the files below. It is a single background tileset and a screen specific one for doors, such that I can change em with the different environments(cave, hellscape, forest etc.) to suit the rest of it, or to add item tiles when I don't need an upstair and a downstair, for instance. Floor variation, edges, and graphics are achieved by using paths (very carefully, this took the most tweaking to make convincing / functional, and there are still some odd spots sometimes. The ambiguous tileset / darkness helps mask this). The advantage to mix and matching paths for this is you can have almost unlimited variation in floor graphics / arrangement so it feels like there are more tiles than there actually are.

Edit: sorry for the multiple image weirdness. The post editor is doing strange things when I go to attach stuff (i.e. telling me there is nothing attached, previewing with nothing, then showing like 6 of them...? Maybe I am just doing something stupid). There are only three files that should be there: the background tiles, the screen specific tiles, and the path image.
 

Attachments

  • PathTiles00.png
    PathTiles00.png
    3.7 KB · Views: 3,008
  • BckCHR_00.png
    BckCHR_00.png
    3.9 KB · Views: 3,005

Orgia Mode

New member
Goaterby said:
Hmm yeah I dunno about the Z issue. Maybe what you could do is make a smaller tileset, or characters whatever so you can fit more on screen and simply have each screen be more winding so that there are multiple paths to sneak around patrols or something... Or maybe have the warps themselves lead to the different routes you can choose from? It sounds like a tough problem to solve, I wish I could be of more help but my grasp of 6502 ASM is tenuous at best.

In regards to how I fit the stuff, I have included the files below. It is a single background tileset and a screen specific one for doors, such that I can change em with the different environments(cave, hellscape, forest etc.) to suit the rest of it, or to add item tiles when I don't need an upstair and a downstair, for instance. Floor variation, edges, and graphics are achieved by using paths (very carefully, this took the most tweaking to make convincing / functional, and there are still some odd spots sometimes. The ambiguous tileset / darkness helps mask this). The advantage to mix and matching paths for this is you can have almost unlimited variation in floor graphics / arrangement so it feels like there are more tiles than there actually are.

Edit: sorry for the multiple image weirdness. The post editor is doing strange things when I go to attach stuff (i.e. telling me there is nothing attached, previewing with nothing, then showing like 6 of them...? Maybe I am just doing something stupid). There are only three files that should be there: the background tiles, the screen specific tiles, and the path image.

Whoooooooa your paths are excellent! Thank you. I'll have to draw up some paths too becuase that really clears up the BckCHR tileset a lot!
 

FrankenGraphics

New member
Thinking about it twice, while separating the collision plane from the representational one requires a a bit of restructuring in the underlying template, there is actually one more method which should be more easy to hack on top of the pre-existing one. It is not just as efficient. I'll get to that.

NESmaker uses a tile grid where you check for coarse collisions, just like zelda or SMB or whatever. Now, you've got plenty of tiles. You can use some of those to call a narrow-phase collision routine.

Some games, especially games that use curved slopes etc, has two phases of colission detection. If a "block" is wholly comprised of solid or nonsolid, you can stay in broad phase collision, which is efficient. When you step on a tile that is supposed to have pixel for pixel detection, you step into the narrow phase, which calculates a high-precision collision.

The crux is that you need to be mindful of how many actors that need to have that fine detection degree simultaneously. You can most likely get away with one or two, and probably three, maybe 4, depending on the weight of the rest of your/nesmakers' code.

Other drawbacks are there too: You want to limit the amount of geometrical shape types (i'd guess 2 per angle) and maybe a round shape for pillars, or else you wind up with a *lot* of collision tile definitions. Each narrow phase collision map requires 16 or 32 bytes for a 16x16 pixel area if you bitpack them, and depending on whether you can get away with a halved collision resolution on the x-axis (which seems entirely plausible for an isometric game). 16 or 32 bytes doesn't seem like a lot, but consider that multiplied by each shape, and that's not the end of it. Your map data size may need to expand if you need too many special collision tiles, which is worse.

If geometry is kept simple (ie straight isometric lines only), it might not be too heavy for the game to compute in good time without using any stored colission data at all except where the line of collision is supposed to be, so that would at least free up all the individual collision micro maps.

So just like with everything else on the nes, it is a tradeoff between what features you want to premiere at the expense of others. But at least this option is more straightforward to jigsaw into the existing rpg/adventure module.

The previously mentioned method (while doable) requires you to separate physics and representation logic, which also changes the object size/structure... not bad at all, but it's a bit more surgical in nature and so it'd depend on how ones’ willingness to carefully modify this + how conveniently written NM is with this type of modicifation in mind.
 

Kasumi

New member
Easier, (but still out of scope without a decent amount of code) is running the logic of the game as if it was not isometric, and then drawing the characters as if it was.
https://www.youtube.com/watch?v=r3rWmflqwuo
The top left view in that video is the "regular" world, which is very easy to check collision with. Positions in this "regular" are then converted to isometric on screen coordinates.

The really hard part about an isometric game on NES is having sprites go behind the background, though. You can avoid the need for it in level design, but if you don't you're into very dense programming territory.
 

Orgia Mode

New member
FrankenGraphics said:
Thinking about it twice, while separating the collision plane from the representational one requires a a bit of restructuring in the underlying template, there is actually one more method which should be more easy to hack on top of the pre-existing one. It is not just as efficient. I'll get to that.

NESmaker uses a tile grid where you check for coarse collisions, just like zelda or SMB or whatever. Now, you've got plenty of tiles. You can use some of those to call a narrow-phase collision routine.

Some games, especially games that use curved slopes etc, has two phases of colission detection. If a "block" is wholly comprised of solid or nonsolid, you can stay in broad phase collision, which is efficient. When you step on a tile that is supposed to have pixel for pixel detection, you step into the narrow phase, which calculates a high-precision collision.

The crux is that you need to be mindful of how many actors that need to have that fine detection degree simultaneously. You can most likely get away with one or two, and probably three, maybe 4, depending on the weight of the rest of your/nesmakers' code.

Other drawbacks are there too: You want to limit the amount of geometrical shape types (i'd guess 2 per angle) and maybe a round shape for pillars, or else you wind up with a *lot* of collision tile definitions. Each narrow phase collision map requires 16 or 32 bytes for a 16x16 pixel area if you bitpack them, and depending on whether you can get away with a halved collision resolution on the x-axis (which seems entirely plausible for an isometric game). 16 or 32 bytes doesn't seem like a lot, but consider that multiplied by each shape, and that's not the end of it. Your map data size may need to expand if you need too many special collision tiles, which is worse.

If geometry is kept simple (ie straight isometric lines only), it might not be too heavy for the game to compute in good time without using any stored colission data at all except where the line of collision is supposed to be, so that would at least free up all the individual collision micro maps.

So just like with everything else on the nes, it is a tradeoff between what features you want to premiere at the expense of others. But at least this option is more straightforward to jigsaw into the existing rpg/adventure module.

The previously mentioned method (while doable) requires you to separate physics and representation logic, which also changes the object size/structure... not bad at all, but it's a bit more surgical in nature and so it'd depend on how ones’ willingness to carefully modify this + how conveniently written NM is with this type of modicifation in mind.

Thats a bit much to digest all at once, but I get the gist. As for narrow Phase collisions I am only concerned a 1:2 slope from a corner to the midway point of a 16x16 tile. Round narrow phase collisions are not important (and a bit overkill imo). Like this:
nhyjcertxcvbhj.PNG
Kasumi said:
Easier, (but still out of scope without a decent amount of code) is running the logic of the game as if it was not isometric, and then drawing the characters as if it was.
https://www.youtube.com/watch?v=r3rWmflqwuo
The top left view in that video is the "regular" world, which is very easy to check collision with. Positions in this "regular" are then converted to isometric on screen coordinates.

The really hard part about an isometric game on NES is having sprites go behind the background, though. You can avoid the need for it in level design, but if you don't you're into very dense programming territory.

Hm, interesting. idk how I could incorporate it into NesMaker myself but its definitely the easiest to understand solution.
 

FrankenGraphics

New member
The beauty of a conditional fine precision collision routine that simply looks at, say, 8x16 bits of data for each trigged case is that it adds no additional complexity whatever shape you want. So if that sharp angle gives you problems (a player may get stuck on the y axis unless they back out to the right 2 pixels, depending on how movement and collision works), you can just round the corner like so (excuse the 3sec copypaste job). By comparison, a more math-derived method would leaner on ROM-size but doesn't allow for such easy data based fixes, especially as computation doesn't come cheap here.

Or, maybe, there isn't even a problem to solve in the first place if up-or downward pushes against a 1:2 wall are designed to attempt to push the player sideways along the wall in every possible case (common in many isometric games).
 

Attachments

  • 1.png
    1.png
    3.4 KB · Views: 1,596
Top Bottom