Example #1 I learned this method from Falacy, whenever I was viewing his source codes. mob |
Hello BYOND, I feel like putting something on BYOND. I'm going to do a couple of Spawn Point examples. It's not the best coding, there is probably a better way to do these, but I'm explaining my ways.
|
Why don't you guys use tags?
mob In map editor, right click a tile, go to edit instance, go to tag, type "start", hit ok, save, compile, run. |
You misunderstand bitflags, and that code won't work as expected. For example, (1 & 3) returns 1, which is a TRUE value. Further, the equality operator (==) would actually be as fast as, if not faster than, the binary AND operator (&) in this case.
You're also both making unnecessary calls to locate(). Also, as FIREking mentioned, the tag variable is perfect for this (I would even go so far as to say designed for this). |
DarkCampainger wrote:
Also, as FIREking mentioned, the tag variable is perfect for this (I would even go so far as to say designed for this). Yeah, it does pretty much does exactly the same as SpawnN basically. I know what I'll use next time whenever I need a single spawn :P |
Cool stuff, just noticed you spelled encase as incase. Generally if you're gonna share programs which have comments then in my opinion it's good to put them through a spell checker.
But that's just me being me so don't worry too much, it's just one spelling error. |
In case its not already apparent, you can do this with objects, and mobs. In the documentation for locate() it discusses the tag variable in more detail.
|
It's usually best to go via wikipedia for this, and some experimentation on your own so you understand or visualise the kind of transformation at work:
http://en.wikipedia.org/wiki/Bitwise_operation http://www.miniwebtool.com/bitwise-calculator/ I apologise for the slightly general seeming nature of the links. It's just that bitwise operations aren't really much of a BYOND specific notion so much as a binary mathematics notion. |
Stephen001 wrote:
It's usually best to go via wikipedia for this, and some experimentation on your own so you understand or visualise the kind of transformation at work: Another useful concept is bit-shifting. Edit: Ooops, looks like that article does explain bit-shifting. |
I've experimented with a number of ways to have players spawn randomly among mapped spawn points on specific maps, and came up with a method that I always use for this situation. This is generally for action games, especially when you re-spawn multiple times throughout a match, and when you want to have teams with separate sets of spawns. It's also nice because you don't have to mess around with tags or anything - just place the spawns and you are done:
turf |
Also, heres the same example using numbers as well, instead of type paths:
Probably not the besst examples, but this is a bit simpler.