8 point collision , what I know

Having trouble compiling code? Getting an unexpected error? Player not appearing on screen? Seeking answers on how to do a particular thing? This is the forum you're looking for, to ask other NESmaker users for assistance.
User avatar
fearspork
Posts: 35
Joined: Tue Aug 14, 2018 6:59 pm

8 point collision , what I know

Post by fearspork » Tue Oct 09, 2018 11:58 pm

i dont know 6502 assembly code and i have no interest in learning, what i do want to do is solve a common problem a lot of us are having with larger players sliding through platforms with out shrinking the hit box, 6502 is a super abstract and old language, googling tile collision will find you stuck in 15 year old dead threads with people who expect you to know 6502 assembly code. so here's what I've figured out

the bounding box is not actually a box , the way its laid out in the platform module is in 4 points labeled 0,1,2,3 that are checked one at a time for collisions with solid tiles. although almost every single game checked collisions differently and with different code , this basic idea is a super common way it was done , the problem with larger sprites and player characters is that the points are stretched to a point where the collisions aren't being detected in the middle, the solution then is to add more points to check

if you imagine your player is on a grid like battle ship each point on the grid has an address like C6 or B4 ( but i dont know how those addresses are written in assembly) in memory they are not stored in a grid they're stored in a straight line to be reassembled as a grid on your screen later, so if you had a 8x8 grid it would be 0,1,2,3,4,5,6,7,... and then the second line down would start at 8,9,10...ect probably in hex values. in the code the number of addresses need to be defined and then a way to retrieve each point and then what to do with the points and then the reactions of these points.

in the platform module there is a .ASM file called TileCollision_Platform_simple_alt.asm wich i am sure is what defines all of this in NESmaker Platform Module. in the file there is already the code for 6 point tile collision but its disabled some how because i'm assuming games run better with less points to individually check.

HandleTileCollision:
;; uses collisionPoint0,1,2,and 3
;; makes use of left+bbox_left, top+bbox_top, width and height of an object to form bounding box.
;; gets collision data for each point.

;LDA ObjectFlags,y
;AND #%10000000 ;; ignore background collisions?
;BEQ dontIgnoreBackgroundCollisions
;LDA Object_flags,x
;AND #%01000000
;BEQ dontIgnoreBackgroundCollisions

;RTS
dontIgnoreBackgroundCollisions:

;;;=== HANDLES TOP LEFT CORNER
LDA xHold_hi
CLC
ADC ObjectBboxLeft,y ;; y is still loaded with object type, so this reads from lut table.
STA tileX
LDA yHold_hi
CLC
ADC ObjectBboxTop,y
STA tileY
JSR GetTileAtPosition
LDA collisionTable,y
;; y is now loaded with tile type
STA collisionPoint0
;;; if it is solid, disregard the other collisions, this should *stop us*.
LDY Object_type,x

;;; === handles top right corner
LDA tileX
CLC
ADC ObjectWidth,y
STA tileX
JSR GetTileAtPosition
;; y is now loaded with tile type
LDA collisionTable,y
STA collisionPoint1

LDY Object_type,x

;;; === handles bottom right corner
LDA tileY
CLC
ADC ObjectHeight,y
STA tileY
JSR GetTileAtPosition
LDA collisionTable,y
;; y is now loaded with tile type
STA collisionPoint2

LDY Object_type,x

;;; === handles bottom left corner
LDA tileX
SEC
SBC ObjectWidth,y
STA tileX
JSR GetTileAtPosition
LDA collisionTable,y
;; y is now loaded with tile type
STA collisionPoint3

;;;;;;;;;;;;;;;;;;six point collision
LDY Object_type,x

;;; === handles bottom left corner
LDA ObjectHeight,y
LSR
STA temp
LDA tileY
SEC
SBC temp
STA tileY
JSR GetTileAtPosition
LDA collisionTable,y
;; y is now loaded with tile type
STA collisionPoint4

LDY Object_type,x

;;; === handles bottom left corner
LDA tileX
clc
adc ObjectWidth,y
STA tileX
JSR GetTileAtPosition
LDA collisionTable,y
;; y is now loaded with tile type
STA collisionPoint5

LDY Object_type,x ;; final restoring corrupted y value




LDA collisionPoint0
ORA collisionPoint1
ORA collisionPoint2
ORA collisionPoint3
ORA collisionPoint4
ORA collisionPoint5
; ;;; all collision points were zero.
BEQ noCollisionHappened

JMP collisionHappened


i'm sure that re-enabling this is super easy for some one who knows how to code, but i dont know what i'm looking at and i cant simply cut and paste someone else's code from some other indie game because every game does this different and the little bit of code i did find i'm sure is not compatible with NESmaker. im sure also it would be easy to add 2 more points to this to make an 8 point collision detection's again i dont know how to do that and the more points you add the slower the game will get.

i've looked at hours of youtube videos and scoured old dev blogs and this was the best resource i could find http://forums.nesdev.com/viewtopic.php? ... 2&start=60 . i hope this gets solved soon or that i at least helped someone who doesn't code what is happening when you slide through a platform
Last edited by fearspork on Thu Oct 11, 2018 9:56 pm, edited 1 time in total.
User avatar
jorotroid
Posts: 85
Joined: Wed Aug 08, 2018 7:48 pm
Location: California
Contact:

Re: 6 point collision , what I know

Post by jorotroid » Wed Oct 10, 2018 8:28 am

I am confused. That is the code for 6 point collision detection and it's not disabled. Isn't TileCollision_Platform_simple_alt.asm the default collision detection routine for the platformer module? It's working for me. How big is your player character? If its bounding box is bigger than 4 sprites tall, then you would need more that 6 points.
User avatar
fearspork
Posts: 35
Joined: Tue Aug 14, 2018 6:59 pm

Re: 6 point collision , what I know

Post by fearspork » Wed Oct 10, 2018 12:19 pm

my player is 4(8x8)tiles wide by 3(8x8)tiles tall. this code explained by joe on facebook only checks 4 points and that it maxes out at a 1(8x8) wide by 2(8x8) tall character. the current work around suggested by dale_coop is to make the bounding box a max of 1(8x8) wide by 2(8x8), http://nesmakers.com/viewtopic.php?f=19&t=211 this works but makes other problems. its suggested by joe in the tutorial that we can change the current 4 points to 8 points , but that it slows down the game and its not native to the NESMaker front end and that explaining the ASM would take too long. it looks to me like that is the working 6 point code but perhaps the 2 middle points are not defined so when this script goes to check for them it just skips the missing points, maybe its just a ;; some where blocking the middle points from working ? maybe i miss understood and all 6 points are working and i really need 8 points , i have no clue this looks like alphabet soup to me. here is a post of the same problem from some one else with screen shots so you can see what i'm talking about http://nesmakers.com/viewtopic.php?f=23 ... sion#p5989
User avatar
fearspork
Posts: 35
Joined: Tue Aug 14, 2018 6:59 pm

Re: 6 point collision , what I know

Post by fearspork » Wed Oct 10, 2018 12:49 pm

this is cut and paste from face book i changed My name to Fearspork... i'm the friend ....

FEARSPORK so i have a friend ... who's in project settings>script setting> i'm going through the visible asm. files menu. witch asm. script changes to a 6 or 8 point collision detection and how Do i add that.... i'm asking for a friend
Manage

· Reply · 6d
Joe Granato
Joe Granato If you're not super clear on ASM, it might be best posed to the forums for multiple reasons:

1) lots of people with at least a little ASM experience there
2) It's not possible to write code in FB like it is there.
3) What you learn, others can learn from.

:-)
Manage
Like
· Reply · 6d

Joe Granato Though to give you a clear idea, you can look at your tile collisions script in your script manager. You can see how collision points 1-4 are figured. Then you'd just have to make a 5th and sixth, and just like 1-4 check to see what's there, and react accordingly, you'd do the same for 5&6.

(this would also require you to to add variables for those two new collision points).

So it's actually pretty easy for someone who can read the ASM. But if you're not there yet, my advise is don't stress about that part of it yet, continue to use NESmaker and the tutorials as learnign the basic interface. :-)
Manage
Like
· Reply · 6d

FEARSPORK thank you for the response, but if its on there its not coming up in any of my searches, theres a lot of post suggesting to do this but no one explains how, Dale_coop who is a monster on the forum has the biggest post but his solution is to just make the hit box smaller, but that results in enemy attacks going through the players head or sinking much too far into the floor, also i know nothing about coding, zero, so i dont even know what files to look at in what folder and if its even adding to my game or what.... i mean my friend
Manage
Like
· Reply · 6d

Joe Granato Haha. Right. That's why I say that you're probably not to the point of digging deep in the ASM. So for the time being, you have a few choices. You can make your block areas thicker. You can make your character smaller, as is intended in that tutorial module, or you can figure out a reason to make this a mechanic in your game. That module isn't designed to use characters bigger than 16x16 for collision detection. It's not a hard ASM change, and I'm sure there will be scripts that handle it by the community if not from us before long. But that shouldn't concern you too much at this point, because if you're not at the point where you'd feel comfortable making those changes anyway, you shouldn't be trying to create your opus game yet...you're just learning the tool. Stick close to the tutorials until you're more comfortable and broader base of possibilities / more code options / deeper tutorials open up on the forums :-)
3

Like
· Reply · 6d

FEARSPORK i had to make the player big to make a no code melee attack solution, i made the player 4x3 tiles, the with is to add an animation for the melee weapon, i then added a blank tile in the projectile and timed it so it disappears at the end of the melee animation. so if i make it smaller ... more problems
Manage

· Reply · 6d
FEARSPORK i mean my friend

Like
· Reply · 6d

Joe Granato Again, here's what you're saying:

"I deviated from the things in the tutorial video, and now things don't work exactly like they do in the tutorial, and I don't know how to fix it".

To which I'm replying, "Right...I understand. For now, stick to the tutorial videos, and know that you're not creating your dream game, you're just using these as exercises to learn the basics of the tool. More tutorials, more modules, more code, more drop-in solutions will be developed as time goes on, which will help you make the exact game you want...but you're not there yet. Right now, stick to the tutorials. :-)"
User avatar
dale_coop
Posts: 1277
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: 6 point collision , what I know

Post by dale_coop » Wed Oct 10, 2018 1:05 pm

I think Joe's right. Currenlty NESMaker (even if released) is kinda still a WIP. The tutorial videos are made for us learning how to use the tool, understand the concepts, ... to prepare us for the moment when it will be finliazed (all the modules no more big changes).
So I will also recommend to stick to the video tutorials if you're not familiar (or at ease) with the asm code.

But some small experimentations is alway fun, ah ah ;)
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE
User avatar
fearspork
Posts: 35
Joined: Tue Aug 14, 2018 6:59 pm

Re: 6 point collision , what I know

Post by fearspork » Wed Oct 10, 2018 3:08 pm

hey dale_coop as far as i'm concerned you're the top user authority, but after talking to joe about it he did suggest that this is not a bug and so not a priority to fix and that if i wanted a no code solution that i would have to wait for the community to figure it out so... here i am in the community, the code is already there and joe suggested if you know asm its an easy fix. a lot of people have run into this problem and i feel the smaller hitbox solution has stopped other users from looking into this a little deeper -
User avatar
fearspork
Posts: 35
Joined: Tue Aug 14, 2018 6:59 pm

Re: 6 point collision , what I know

Post by fearspork » Wed Oct 10, 2018 3:31 pm

i actually have tinkered a bit i made in the neighborhood of 20 copies of my current game build and have cut and snipped and added various things into the code but its all a shot in the dark, ASM is so abstract and i dont know any code
User avatar
dale_coop
Posts: 1277
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: 6 point collision , what I know

Post by dale_coop » Wed Oct 10, 2018 3:40 pm

In fact, Joe loves to say you need to stick with the tutorial but that you can do it if you dig in the code. He wants teach you, how to use... and how to break his code!
Of course, he might help us and write that code for us if nobody found the solution. He knows that.
He's very smart, he wants us to lean and master the tool... learn the code, the limitations, the rules... until we are ready to break it ourself.

So I followed his advice, I just followed the tutorials (A LOT of times) and try learning how NESMaker tool works, how the engine works. And try to bend the things I now understand.
The collision code is still blurry for me. I Need to spend more time into it. But as a lot of people here, I am waiting for the 4.1 before diggin' more into the code, right now, because a lot of things will change.
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE
User avatar
fearspork
Posts: 35
Joined: Tue Aug 14, 2018 6:59 pm

Re: 6 point collision , what I know

Post by fearspork » Wed Oct 10, 2018 4:02 pm

yeah it probably not worth going crazy until 4.1 but after talking to him last week , he seemed to imply it was an easy fix, thats what got me on my quest again, even in the tutorial he suggests doing 8 points, the code for 6 points is there already. surely one of us nerds knows how this works
User avatar
fearspork
Posts: 35
Joined: Tue Aug 14, 2018 6:59 pm

Re: 6 point collision , what I know

Post by fearspork » Wed Oct 10, 2018 4:17 pm

what i figured out above though also explains why the number of tiles cant change to accommodate different animations, if you went from a 1x2 tiles to say 3x2 tiles it would change the adresses for the points on the bounding box mid animation, im sure there are ways to do this but would be way to complicated and take up more space in memory then you would save from the smaller frames in the animations
Post Reply