How To

Why does it not collide with all cells all the time

0

GAMELEGEND 2020-05-06 14:23 (Edited)

and isnt there a better way to do sprite and cell collision there as got to be right
I think i know why it does not collide with all cells everytime but maybe i dont

Sandbox.nx | Open in app
2020-05-06 14:23

Timo 2020-05-06 16:12 (Edited)

When you move to a direction, it's better to check the points of both corners and not only one in the center of the side.


GAMELEGEND 2020-05-06 16:18 (Edited)

Oh ok thanks


was8bit 2020-05-06 17:38 (Edited)

Timo already has this licked here....

https://lowresnx.inutilis.com/topic.php?id=318

Let me fix your code with the parts he uses for that issue, and i will post it here :)


was8bit 2020-05-06 17:46

Here you go ... its what i personally use too :)


was8bit 2020-05-06 17:49 (Edited)

I added RING which references char#4 a ring image i added to show how to add things the player can interact with.. just add code as you see where to reflect WHAT you want to happen when a player touches it..

currently ring simply disappears and makes a noise... you can add whatever code you want for each different char# a player touches :)


GAMELEGEND 2020-05-06 17:59

Thanks i will check this when im done playin call of duty


GAMELEGEND 2020-05-06 18:44

The only thing i dont understand is CHECKCOLL just calls CHECKCELL so what is the point of having 2 sub programs or is CHECLCOLL doing more than just callin CHECKCELL


was8bit 2020-05-06 18:45

:)


was8bit 2020-05-06 18:51

one CALL is made for a direction a player wants to move... CHECKCOL (you dont want to put a ton of code here, just a SUB that checks if the desired direction is OK to move into or not...

CHECKCOL uses 4 CALLS for each of the 4 possible corners of movement... one CHECKCELL call is made for each corner, to determing if all 4 corners are OK to move into... if any one corner is NOT ok, then the movement is denied

CHECKCELL checks one specific corner cell, if it is OK to move into this corner, it returns OK

Note, R=-1 represents TRUE or OK... R=0 represents FALSE or NOT OK


was8bit 2020-05-06 18:53 (Edited)

The statement...

IF R THEN

Is shorthand for IF R=-1 or if it is TRUE.. TRUE FALSE were keywords in original LOWRES, but were removed from NX lowres, so it is not as readable but that is what it "means"


GAMELEGEND 2020-05-06 18:54

In a little bit i will post this program with the way i code to see if i did it right


was8bit 2020-05-06 18:58

Hmmm. I have NEVER succeded doing sprite to cell collisions on my own that work... Timo's math for that code is the ONLY math that works...

You can redo the code, but for EACH desired move you will have to check ALL 4 CORNERS of where you want to go, and only allow movement if ALL 4 CORNERS are clear... and deny movement otherwise...

It is OK to write out the code longhand if you prefer, you just have to use Timo's math or it won't work....


GAMELEGEND 2020-05-06 20:00

It makes so much sense now
Now i can finally make the games i have been wanting to make

Big big thanks to timo and was8bit
super big THANK YOU
:) :D :) :D :) :D :) :D :) :D :) :D :) :D :) :D :) :D :) :D :) :D :) :D :) :D :) :D

Sandbox.nx | Open in app
2020-05-06 20:00

GAMELEGEND 2020-05-06 20:05 (Edited)

One question though look at character #18 foot would be checking the white pixel the gray pixel or the empty pixel between them

#2:MAIN CHARACTERS
00000000000000000000000000000000
00000000000000000000000000000000
03040B0D0F0E071803070C0A0809041F
C020D0B0F070E018C0E03050109020F8
03040B0D0F0E071803070C0A0809041F
C020D0B0F070E018C0E03050109020F8
03040B0D0F0E071803070C0A0809041F
C020D0B0F070E018C0E03050109020F8
03040808080C071803070F0F0F0B041F
C02010101030E018C0E0F0F0F0D020F8
03040808080C071803070F0F0F0B041F
C02010101070E018C0E0F0F0F09020F8
03040808080E071803070F0F0F09041F
C02010101030E018C0E0F0F0F0D020F8
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
21232138190909023F3F3F271F0F0706
84C4841C98909060FCFCFCE4F8F0F060
2123211C090906003F3F3F130F0F0600
84C4841C98909060FCFCFCE4F8F0F060
21232138190909063F3F3F271F0F0F06
84C4843890906000FCFCFCC8F0F06000
22272138190909063F3F3F271F0F0F06
44E4841C98909060FCFCFCE4F8F0F060
2227211C090906003F3F3F130F0F0600
44E4841C98909060FCFCFCE4F8F0F060
22272138190909063F3F3F271F0F0F06
44E4843890906000FCFCFCC8F0F06000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
0000182C3C1800000018241000000000
0052D3D352101000006EEFEF6E2C0800


was8bit 2020-05-06 22:30

The ONLY way you can have pixel perfect collision checks is between one sprite with another sprite... all other checks are purely mathematical, as in the entire invisible 8x8 tile block is being checked...


GAMELEGEND 2020-05-06 22:30

Ok


was8bit 2020-05-07 11:08

So, for example, you can use a sprite for a fancy doorway, but then if the background is scrolling you would have to also manually move the doorway to make it appear as if it too is scrolling with the background...

For sprite to sprite contact checking you use SPRITE HIT command and HIT ..

The downside is that layering can be an issue, and you only 64 sprites (0-63) at one time...


GAMELEGEND 2020-05-07 11:12 (Edited)

Why cant i use 0 - 191
Last time i tried to use sprites on the 3rd character page and things were actin weird but that was a long time ago when i was still a rookie
So i dont know if it was me not knowing what i was doin or lowres


was8bit 2020-05-07 12:15 (Edited)

Sprite #'s 0-63 are for sprite reference
Character #'s 0-255 are for character reference
Char#'s 0-191 are available for all purpose graphics

Char#'s 192-255 (page 4) are reserved for the FONT SET, leave blank to use the default FONT SET, or use the FONT button add and even customize your own font set

SPRITES dont actually hold any graphics, they simple hold one reference char# from the character set... SPRITE, Sprnum,Xnum,Ynum,Charnum

the Char# is actually the top-left of the block, so best practice is to keep the whole block together on one page... for size 3 (4x4) it is best to keep the whole block on one page... so if your char# for size3 sprite is #140 then all of the char# the sprite will use are:
140,141,142,143
156,157,158,159
172,173,174,175
188,189,190,191


Log in to reply.