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.

Newcomers DBPro Corner / how do i do collision for a moving platform with an object on it

Author
Message
fussy123
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location:
Posted: 19th Oct 2002 00:20
so it will toggle the other direction when the object On the platform hits something but also go the other direction when the platform hits something with the object still on it..
imtrying real hard to describe what i mean .. if you have seen the sorcery game by paul jefferies you know what i mean.. i cant seem to get it right...
ChipOne
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 19th Oct 2002 00:44
what I believe you mean is this:

1) you have a platform that moves from side to side of a room. when it hits a wall, it reverses direction.

2) a player does some action, and that action reverses the direction of the platform at that instant.

If that's the case, here's what you do:
1) store the direction the platform is moving in a global variable (or in a global array if you have lots of platforms).

2) check OBJECT COLLISION(PlatformNumber,0) each frame. if the number that is returned from OBJECT COLLISION is not the object number of your character, then it has hit something else (i.e., the wall). reverse the direction it is moving.

3) if the player does whatever it is that s/he is supposed to do, toggle the direction as well.

A really simple technique to do this would be to write a function called TogglePlatformDirection(PlatformNumber) and call it each time you want to switch directions.

(in the sample below, you'll need to figure out what TheCurrentPlatformThePlayerIsOn is equal to. i don't know how you're keeping track of this, but i assume you know where the player is...)



hope that helps.

cheers.

-= i only do what my rice krispies tell me to do =-
ChipOne
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 19th Oct 2002 00:45
sorry...forgot a line in there:



-= i only do what my rice krispies tell me to do =-
fussy123
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location:
Posted: 19th Oct 2002 02:21
thanks for the help , but im using darkbasic not darkbasic pro does the global dim thing work in that version also.. i couldnt get it to ..

ChipOne
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 19th Oct 2002 09:29
just take out the global. DB functions can see dim'd arrays.

-= i only do what my rice krispies tell me to do =-

Login to post a reply

Server time is: 2024-11-23 18:08:23
Your offset time is: 2024-11-23 18:08:23