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.

DarkBASIC Discussion / *HELP* I have no idea how to make a teleporter!

Author
Message
cowboy21
16
Years of Service
User Offline
Joined: 10th Feb 2009
Location:
Posted: 11th Feb 2009 05:37
I'm making a game that uses multiple rooms and i want to teleport between them. Only problem is, i have no idea how to make this happen. If anyone has working code i could download, that would be awesome.

Or, you can just tell me how lol
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 11th Feb 2009 17:49
When you hit the "teleporter" change the player's position to its exit. Teleporters can be kept track of using arrays like this:

Teleporters(5,2)

Where 5,1 would be the object number for a teleporter and 5,2 would be its exit. This can work both ways so that 3 can exit at 4, and then for 4, you have it's exit at 3 (or another number if you want it to get a little crazy).

*NOTE: The number 5 was an arbitrary number I chose. Change it to however many teleporters you plan to have.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Yodaman Jer
User Banned
Posted: 11th Feb 2009 18:04 Edited at: 11th Feb 2009 18:52
The way I once did a teleporter (over a year ago now...) was fairly straightforward and very primitive. Here's an example....



Run that and see what happens. Some of that code is from the codebase (I used it in a recent project of mine), I'm not nearly that clever in programming yet.


Er, I forgot to add the collision commands..hehe...fixed now...

Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Feb 2009 06:04
ummm he sinks through the floor other then that it works great lol i tried to fix it... idk why i couldn't hahahaha i added volocity though lol anyways i think bn2s is going to work better for him but he needs to remember to not teleport him into another box so then he would be in a infinite loop of teleports hahahahha that would be hilarius lol
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 12th Feb 2009 08:26
Quote: "he would be in a infinite loop of teleports hahahahha that would be hilarius lol "


unless of course he makes it only trigger when you hit an object (which teleports and sets a flag variable to 1) and then the flag is set to 0 when you STOP colliding with the box at the other side. The teleporter would only work if the flag is 0, so the teleporters won't work again until the player steps OUT of a teleporter.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Feb 2009 21:32
Best thread title in a while lol
All you need are two locations stored in memory, BN2 touched on using arrays...
Quote: "Teleporters(5,2)

Where 5,1 would be the object number for a teleporter and 5,2 would be its exit. This can work both ways so that 3 can exit at 4, and then for 4, you have it's exit at 3 (or another number if you want it to get a little crazy).
"

but using different fields to store different types of data can get confusing, you'd have to remember which numbers mean exits and which mean objects. Using multiple arrays uses no more memory and sometimes less. (If you're not familiar with arrays look at TDK's tutorials; its one of the stickied threads on this board.)

It would be too easy if you could go from any teleporter to any other, life just isn't that simple for computer game characters .
So like BN2 said we need to store which teleporters link together.

Ok, so when our character uses a teleporter the computer will check this array to see where to zap him to and hey presto, he'll
be there before you can say "that's a nifty piece of code!"


That's the relationship between the ports taken care of, now we need position them. Seeing as this is in 3D we can use the position of the teleporter object, seems logical enough.
Like BN2 hinted at, the teleporter number wont neccessarily be the same as the object number for that teleporter. So many numbers my head hurts . Let's make an array to store which Teleporters belong to which objects.

I've intentionally given different numbers so we don't get confused between our theoretical teleporter and the 3D object of our teleporter.
Sounds confusing having two representations of our teleporters but you have to remember that computer graphics don't act like real objects, in fact they don't act at all, so we have to control everything in the background like a puppeteer.
OK, so lets use this new data...


That's basically it, sorry I'm getting a bit bored now

One more thing
That code will send your player back and forth between teleporters because there's no switch. Switches are pretty simple to write once you get the idea. Here's one...

That switch just gives one "pulse" when you press return because newin=1 and oldin=0 but when the next loop starts oldin becomes 1 too so the switch doesn't "fire" any more.

It's possible to make more complex switches, see if you can make one that acts like a light-switch, turning on the first time you press it and off the second time.

The Universe has been erased by a mod because it was larger
than 240x80 pixels.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 13th Feb 2009 07:02
exactly! lol your always great at writing examples obese hahhaa
Yodaman Jer
User Banned
Posted: 13th Feb 2009 19:46
Obese, you're fantastic!! That example looks great!

I do wonder why my collision didn't work for my example..not that it matters, but that does bug me. Hehe. 'Bug'. Hehe.

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 13th Feb 2009 21:04
@Yodaman Jer

Your collision didn't work because of the collision type you set on the objects. You can only use

get object collision x()
get object collision y()
get object collision z()

if you create an object collision box or static collision box around the object.

Here's a correction of your example with just a change in the collision type though I'm not sure what you were doing with the teleportation:



Enjoy your day.
Yodaman Jer
User Banned
Posted: 13th Feb 2009 21:09
Oh! I don't know what I was thinking....hehe. Thanks Latch. I should have studied the differences between collision types a bit better than I did.

So, cowboy21, having any luck?

arbiter chewbacca hybrid
16
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 18th Feb 2009 20:38
We have the same avatar

Login to post a reply

Server time is: 2025-05-18 12:18:05
Your offset time is: 2025-05-18 12:18:05