Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / 2D Collision

Author
Message
cloneddude
20
Years of Service
User Offline
Joined: 29th Oct 2003
Location:
Posted: 10th Nov 2003 12:25 Edited at: 12th Nov 2003 21:58
I need help with my collision, what I thought was fixing it, was actually a step in the wrong direction. As well as the source (I have cut all the bits that don’t make sense if you don’t have the bitmaps with them) I am providing a zip file of all the .bmps.



Click here for the .zip file

I have gotten rid of the code that was causing me problems, now this is what I would like some help with:



Basically the ‘man’ image can freely move around inside the white square, as soon as a black border hits the middle of the ‘man’ image he stops moving and the background scrolls. If the ‘man’ hits a wall while he’s freely walking around in the white square, he is stopped from going any further in that direction, but the problem is when the background is scrolling the collision does not work. I tried to fix it by replacing:



With:



But this is where I got a load of errors, can someone please help? If you can't help but know of a different way i could do it, please say.

erm...
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 10th Nov 2003 12:46
You don't really need any collision to do that. Just use the man's X,Y coordinates like...

Pseudo code

If player x > 700
If player x < 100
If player y > 500
If player y < 100

Then scroll...

That's all you need.

Pincho.
cloneddude
20
Years of Service
User Offline
Joined: 29th Oct 2003
Location:
Posted: 10th Nov 2003 12:49 Edited at: 10th Nov 2003 14:10
i don't quite understand, where would that go???

also 'Pseudo code' what is Pseudo is that someone or a set of commands or something else???

erm...
Erusuwasu
20
Years of Service
User Offline
Joined: 21st Sep 2003
Location: Where am I? I think I\'m lost...
Posted: 10th Nov 2003 22:17
"Pseudo" means false. So when someone says Pseudo code they are essentially saying "False Code".

What this means is, that their code is only a representation of the code needed. In other words it's not in proper DB syntax or it's not complete. You need to make it that way for it to work.

I've got DBClassic and Photoshop Skillz and I'm not afraid to use um!
cloneddude
20
Years of Service
User Offline
Joined: 29th Oct 2003
Location:
Posted: 10th Nov 2003 23:54
chears Pincho, i didn't quite understand what you meant but i tried what i thought you were trying to say, and it worked. It isn't perfect but its getting their.

erm...
cloneddude
20
Years of Service
User Offline
Joined: 29th Oct 2003
Location:
Posted: 11th Nov 2003 23:01
I've tried out your methoud Pincho and i'm still getting the same problems as before. Basically when the scrolling wall (background)hits the man all the tiles pasted after the collided one are Y+2 or X+2 depending on the direction that the man is going. its quite hard to explain so i have included a picture:



If you still don't understand run this script (bitmaps can be found in the zip file above):


I'd be very gratful if someone could try and see if they could fix it or have any ideas what theproblem might be.

erm...
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 12th Nov 2003 11:03
I can't view the code for some reason, and I can't download it either. Maybe you haven't turned......

Sync On

Sync

Do this and the screen will no be drawn until all the blocks have been moved.

Pincho.
cloneddude
20
Years of Service
User Offline
Joined: 29th Oct 2003
Location:
Posted: 12th Nov 2003 12:09
Wierd, dunno whats gone wrong there, i hava turned sync on.

CODE:

SET DISPLAY MODE 320, 200, 16
HIDE MOUSE

REM * LOADING FILES

LOAD IMAGE "MAN.BMP", 1
LOAD IMAGE "0001.BMP", 101

REM * LOADING VARIABLES

MANX = 150
MANY = 90
WORLDX = 0
WORLDY = 0

REM * SYNC SETTINGS

SYNC ON
SYNC RATE 0

REM * START LOOP

DO
CLS

REM * LOADING VARIABLES

OLDMANX = MANX
OLDMANY = MANY
OLDWORLDX = WORLDX
OLDWORLDY = WORLDY

REM * CONTROLS

IF DOWNKEY() = 1 AND MANY < 170 THEN MANY = MANY + 2
IF DOWNKEY() = 1 AND MANY = 170 THEN WORLDY = WORLDY - 2

IF LEFTKEY() = 1 AND MANX > 60 THEN MANX = MANX - 2
IF LEFTKEY() = 1 AND MANX = 60 THEN WORLDX = WORLDX + 2

IF RIGHTKEY() = 1 AND MANX < 260 THEN MANX = MANX + 2
IF RIGHTKEY() = 1 AND MANX = 260 THEN WORLDX = WORLDX - 2

IF UPKEY() = 1 AND MANY > 60 THEN MANY = MANY - 2
IF UPKEY() = 1 AND MANY = 60 THEN WORLDY = WORLDY + 2

REM * PRINT LEVEL + TILE PROPERTIES

FOR A = 0 TO 19
FOR B = 0 TO 19
READ DATA

REM * TILES START
REM * TILE 1


REM ****************************************************


REM * ONLY SHOW TILES ON SCREEN
IF (B*16)+WORLDX > 320 OR (B*16)+WORLDX < -16 OR (A*16)+WORLDY > 200 OR (A*16)+WORLDY < -16
ELSE

REM * PRINT IMAGES
IF DATA = 1
PASTE IMAGE 101,(B*16)+WORLDX,(A*16)+WORLDY,1

REM * HIT TEST
IF MANX+8=>(B*16)+WORLDX AND MANX-8<=(B*16)+(16+WORLDX) AND MANY+8=>(A*16)+WORLDY AND MANY-8<=(A*16)+(16+WORLDY)

IF MANX = 60 OR MANX = 260 OR MANY = 60 OR MANY = 170
WORLDX = OLDWORLDX
WORLDY = OLDWORLDY
ELSE
MANX=OLDMANX
MANY=OLDMANY
ENDIF

ENDIF

ENDIF

ENDIF


REM ****************************************************


REM * TILES END

NEXT B
NEXT A

REM * PRINT LEVEL END

PASTE IMAGE 1,MANX-8,MANY-8,1

REM * END LOOP + LOOP

RESTORE
SYNC
LOOP

REM * DATA FILE

DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1, , , , , , , , , , , , , , , , , , ,1
DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

erm...
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 12th Nov 2003 16:27 Edited at: 12th Nov 2003 16:31
Quote: "IF DOWNKEY() = 1 AND MANY = 170 THEN WORLDY = WORLDY - 2
"


These are your problems. They are still being used when the player is touching the sides of the map. I hope that helps you.

Pincho.
cloneddude
20
Years of Service
User Offline
Joined: 29th Oct 2003
Location:
Posted: 12th Nov 2003 21:57 Edited at: 12th Nov 2003 22:00
chears Pincho that helped alot, although i still have one problem (soz to keep on asking just i got proggrammers syndrome, where you've been working on something for so long that you can't even notice the most obvious error). Basically i've fixed the problem i had before but the man can only move right and down, can anyone help???



erm...
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 12th Nov 2003 23:55 Edited at: 12th Nov 2003 23:57
Quote: "IF MANX-8 > (B*16)+(16+WORLDX)
"


I had a mess around with the code. I couldn't fix it, but I think it has something to do with the.........

For A
For B

IF MANX-8 > (B*16)+(16+WORLDX) ' ManX + 270 nearly works!
IF MANY-8 >(A*16)+(16+WORLDY)

Next B
Next A

Because MANX + 270 is close to working, I think that there is a problem there somewhere.

Pincho.
cloneddude
20
Years of Service
User Offline
Joined: 29th Oct 2003
Location:
Posted: 13th Nov 2003 00:53
interesting, chears for all your help pincho, you've been a BIG help.

erm...

Login to post a reply

Server time is: 2024-04-28 01:09:44
Your offset time is: 2024-04-28 01:09:44