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 / Teleporting to rooms

Author
Message
Fear For Hire
12
Years of Service
User Offline
Joined: 18th May 2012
Location:
Posted: 18th May 2012 17:13
Hi I'm having a bit of trouble with some of my coding in creating a secret room. I'm basically green to this whole thing. In fact greener than grass. I want it so when I go into a certain corner I teleport to another room. But when I go there it still confines me to the same room. Anyone willing to help me figure out what I'm doing wrong? Please and thank you.


if P1Xcol#<-1640 then P1Xcol#=-1640 REM west wall
if P1Zcol#<-829 then P1Zcol#=-829 REM south wall
if P1Xcol#>148 then P1Xcol#=148 REM east wall
if P1Zcol#>912 then P1Zcol#=912 REM north wall
position object 11, P1Xcol#,P1Y#,P1Zcol#
if P1Xcol#<=-1630 and P1Zcol#<=-820 then position object 11,525,0,14
if P1Xcol#>235 then P1Xcol#=235
if P1Zcol#>-178 then P1Zcol#=-178
if P1Xcol#<853 then P1Xcol#=853
if P1Zcol#<426 then P1Zcol#=426
position object 11, P1Xcol#,P1Y#,P1Zcol#
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 18th May 2012 23:27 Edited at: 19th May 2012 00:14
I need a bit more info about your code. Where is this corner that should teleport you? Where should it teleport you to?

At a quick glance, this line put object 11 back to where to the collision happened: position object 11, P1Xcol#,P1Y#,P1Zcol#

I hope you have fun coding

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 19th May 2012 09:33
It seems it would be easier to use the object collision commands to check if indeed the player has moved into a wall or to the teleport spot. Before the player moves, store the x#, y# and z# coordinates for the player object. You then move the player and check to see if a collision with a wall occurred. If it does, you place it back where it was originally.

Regarding the teleport spot, if you determine the player is at the teleport spot, you simply position the player object where you want it to go. I whipped up a very quick example:



Bear in mind, this is a very crude example that I put together in a few minutes. You move the player sphere using the arrow keys. If you hit a wall, the player will not advance and it will tell you the object number you are colliding with. If you get to the 'teleport spot' at 147, 59 (x and z), it will move you to the next room.

So many games to code.......so little time.

Login to post a reply

Server time is: 2024-11-23 20:31:57
Your offset time is: 2024-11-23 20:31:57