Example

Need Help Collision

5

tolist 2020-01-04 20:44

Hi there, I'm new. I don't understand collision exactly. I looked at examples about collision but i do wrong. I want to share my file. If you look my file, I would glad. I share screenshot. There are walls from background in screenshot. I can't do add collision features them. Please help!!

Disk - Kopya.nx | Open in app
2020-01-04 20:44

Jonnywhateva 2020-01-05 00:45

I believe this is what you were trying to do.

Unnamed Program.nx | Open in app
2020-01-05 00:45

Timo 2020-01-05 08:22

Also there is no need to do CLS and COPY BG inside of the loop. This can be done once at start. Sprites are independent from the background.


G-9 2020-01-05 09:18

More amazing !


G-9 2020-01-05 09:18

!

Unnamed Program.nx | Open in app
2020-01-05 09:18

G-9 2020-01-06 07:21

...

Unnamed Program.nx | Open in app
2020-01-06 07:21

tolist 2020-01-07 09:23

Tnx for answers! I changed 1 to 0.5 for smooth solid but Player can get into the corner of the wall. How can I correct that?


G-9 2020-01-07 12:11

I’m don’t know


Jonnywhateva 2020-01-07 12:22

i know what you mean. You might have noticed that one change I made was I shifted the sprite over by -4 x and -4 y. This was so the collision would be checked from the center of the sprite. However if the center is in the next cell then it won't detect the collision even if part of the Sprite is hanging over the cell with the wall. One thing you could do is take out the -4x,y on the Sprite and add a second collision check if the Sprite is in more than one cell. So it would check two cells high or two cells wide or both. Maybe for example:
If int(x)<>x then
TOP2=CELL.C(INT(X/8)+1,INT(Y/8))
Else
TOP2=0
End if
And then in the game pad check:
If up(0) and top<>5 and top2<>5 then
And repeat for each direction


G-9 2020-01-07 12:23

Yeah but where is the example ?


Jonnywhateva 2020-01-07 12:48

oh sorry, I'll make one in just a minute


Jonnywhateva 2020-01-07 14:04

I did a little extra tweaking to make it work right. Close to, but not exactly what I first suggested. But this seems to be what you're trying to do.

Unnamed Program.nx | Open in app
2020-01-07 14:05

G-9 2020-01-09 06:27

You are the best !


Jonnywhateva 2020-01-09 11:40

:)


Log in to reply.