« first day (1351 days earlier)      last day (3596 days later) » 

12:00 AM
Third option.
Entities don't have a position. It's all abstract.
Make a 4D game.
 
hehe
 
I'd keep the position tied to the entities themselves for easier access to it along the road
 
I keep the position on the entities
 
world.positionOf(someEntity) vs someEntity.position
in an architecture based on components, make a specialized component for this, like Unity does
each GameObject has a Transform component which provides stuff like position, scale, rotation etc.
 
But then the position is something you don't really know anything about. If I need to move the entity I won't be able to know if that "move" is allowed (eg. there's an obstacle or whatever). Seems pretty much pointless to me, to define the position within the entity.
 
12:02 AM
SFML has such a thing too.
It's called sf::Transformable.
You just inherit from it.
 
@Jefffrey I dunno, it depends on how you want things to work
 
Yeah, I guess.
 
in Unity I try to keep all specific behavior and stuff tied to each GameObject itself, and if the GameObject needs some info, it asks the rest of the world directly
this allows me to use prefabs
I drag & drop a premade... soldier, in some random scene
 
I don't think what Unity does is pretty relevant to what he's doing
 
and it starts analyzing the scene, surroundings and does pathfinding by itself
 
12:05 AM
He's not using it and whatever Unity does only applies to Unity
Unless he's doing ECS
 
I find it interesting nonetheless.
 
@Rapptz Unity is just an example of a valid architecture
 
I'm fascinated by architectures that actually work, as opposed to my architectures.
@AlexM. How does it "asks" the rest of the world?
 
various ways, from raycasting to events coming from its own colliders, references set at run time by searching the scene for objects matching a given criteria and references set in the editor by the developer
 
I liked tags in Unity
e.g. GameObject.FindWithTag("stuff");
 
12:10 AM
void OnCollisionEnter(Collider other)
{
      if (other.gameObject.Tag == "Tomato")
      {
              print(this.gameObject.name + " just hit a tomato!");
      }
}
@Rapptz yes, they're invaluable imo
I used them a lot lately to extend the editor with helpful tools to generate levels
 
I have a simple ECS but I don't feel comfortable with it
I don't like ECS too much
It's weird.
 
currently working on some hidden object mobile game, and there are around ~100 objects (including decorative objects) in each scene
placing them manually would have killed me lol
 
@Jefffrey Maybe both..
 
so I did a few scripts that perform all of it automatically, and use tags to mark the objects
so that I don't have to manage hundreds of references either manually or automatically
 
I'm assuming searching by tags is O(log(n))? (Just wondering).
 
12:14 AM
It's literally just a string member
 
it's O(n) where n is the number of objects in your scene
 
It's actually nothing really revolutionary
 
FindGameObjectWithTag stops at the first gameobject with that tag that it finds
 
@AlexM. Does Unity do collision detection for you?
 
You have a Collider component
 
12:15 AM
What do you mean by scene?
 
Scene is a level
 
a scene is a level
in which you place gameobjects
Application.LoadLevel("somescenename");
^ switching scenes in unity
 
Each game object is a set of components?
 
Yeah
Unity (ab)uses ECS.
 
I see.
 
12:16 AM
Everything is a component
Even the scripts.
 
@Rapptz Why "(ab)uses"?
 
ECS is weird man.
 
Ell
I really don't like the idea of entity component system
 
It felt pretty natural to me the first time I read about it.
 
12:17 AM
@Rapptz What is ECS?
 
entity component system
 
Ell
It just seems terrible to me for some reason
 
Nevermind...
:-)
 
@Jefffrey It's a bit awkward.
 
if I had to come up with a workflow for gamedev right now, I'd copy unity's
I feel most comfortable with it, and I like how it works
 
Ell
12:19 AM
If I had a character I might have Character : public RigidBody
And CharacterRenderer
 
it's basically the equivalent of auto&& ptr = get_ptr(); if(ptr) { /* do stuff */ }
at least that's how it feels like to me
(and that's how I implemented it, sorta)
 
Ell
To me as long as simulation and rendering and networking and input are separated its all dandy
Also ECS sounds stringly typed
 
It's statically typed I think.
Now I wonder though
Why can components be "null"?
 
I thought the whole ECS architecture is as dynamic as it can get.
 
@Rapptz in unity if a component "is" null, it means it doesn't exist on that entity
 
12:24 AM
I mean, you can load and switch components at runtime, no?
 
@AlexM. Yeah that's why it's null on my implementation too.
 
someObject.GetComponent<ComponentType>() //if it returns null, it means the component doesn't exist
 
Ell
I haven't seen unity, just a JavaScript one. Can't remember which but it was 'object.addComponent("physics")'
Makes me shudder
 
Meh strings.
 
var goblinInv = goblin.AddComponent<Inventory>() ;
goblinInv.AddItem(...);
 
12:25 AM
object.emplace<Physics>(args...) is how I do it in C++ land.
 
Does C++ have a form of Duck Typing?
In computer programming with object-oriented programming languages, duck typing is a style of typing in which an object's methods and properties determine the valid semantics, rather than its inheritance from a particular class or implementation of an explicit interface. The name of the concept refers to the duck test, attributed to James Whitcomb Riley (see history below), which may be phrased as follows: In duck typing, a programmer is only concerned with ensuring that objects behave as demanded of them in a given context, rather than ensuring that they are of a specific type. For exa...
 
templates
 
@Ell nah, it's not stringly typed (Unity that is)
 
@Rapptz thanks...
 
Ell
I don't understand the attractiveness of a dynamic system like that
Just compose everything into the class
 
12:28 AM
I like the RequireComponent attribute
[RequireComponent(typeof(Character))]
public class Inventory : MonoBehaviour
{
}
 
when you add an Inventory component to some gameobject, it automatically adds (if it doesn't exist) a Character component to it
you cannot delete the Character component as long as Inventory is there, as it is depended upon
 
@Rapptz Oh god my brain hurts after looking at that... are those variadic templates?
 
yes
 
In that code sample could you overload the insertion operator to avoid having to write this function?

void print(entity& e) {
auto position = e.get<position_component>();
auto health = e.get<health_component>();
std::cout << "position: (" << position->x << ", " << position->y << ")\nhealth: " << health->hp << '\n';
}
Or is that not possible because of the template?
 
12:42 AM
just defeats the purpose I think
it was just to showcase how entities work
not really anything special
 
OK, wasn't being critical or anything. Just trying to learn by looking and asking questions about other people's code.
 
I wonder if std::vector + std::binary_search et al are better.
It's random access and probably better for iteration
I don't know.
 
It looks like Python Copyright Violation question finally got DMCA'ed deleted.
That didn't take very long.
 
what?
 
57
Q: Question is a Copyright Violation?

LyndaWhen going through the review queue for suggested edits this question came up. The edit completely removed the question and I rejected it. The reason for the edit was: This problem was posted in violation of copyright as it belongs to O'Reilly School of Technology and is a live homework prob...

Hurry up and get to 10k. I'm not gonna screencap it since it was removed for DMCA.
 
user3010322
12:55 AM
std::map<std::type_index, std::size_t> indices; // use for search
std::vector<component> components; // use for iteration
 
user3010322
@Rapptz ^ I use that sometimes when I need both to be top-notch. Obviously the cost is space.
 
well I meant more so a "sorted" vector
boost has one
It's called flat_map and flat_set
that way you're good for both search and iteration
problem with using the standard library for that is that I never know when I should sort :v
cause I don't wanna sort too much
 
@AlexM. I don't one thing about ECS though. How do components interact with each other, if they are not supposed to be assuming other components exists? Message passing?
As an example, a fire (entity) and a person (entity), when the person position is over the fire, then the health of the person should decrease.
 
you can reference different components from other components w/o trouble
 
Hmm.
@AlexM. But then you couple them together, no?
Which is the opposite of what ECS is meant to do.
 
1:04 AM
the person collides with the fire, and in the person's collider's event you automatically get a reference to the fire's collider
 
check the collision
so you have onCollision(entity&, entity&)
 
which you can use to get access to the fire's gameobject, and thus to any other component the fire might have
 
and check their components
like Burnable or whatever
if(player.HasComponent<Burnable>()) { /* */ }
or whatever
 
@Jefffrey I guess
but a fire is automatically coupled to anything that might be burned by it
so it makes sense, I think
public class KillOrcsQuest : MonoBehaviour
{
	public Orc[] OrcsToKill;
}
here's a component that keeps track of other components in an array
 
C#?
 
1:07 AM
yeah
you can set those references in the editor, manually or at runtime
 
@AlexM. Orc is a component?
 
in the editor you just select the orcs (gameobjects with the Orc component) and then drag & drop them in KillOrcsQuest' visual representation of the array
@Jefffrey yes
 
isn't it an entity?
 
in this case it's a component, as it is a script that does... orc stuff
entities must be GameObjects
I never had to inherit from that now that I think about it
> Archaeologists have found 50,000-year-old Neanderthal poop geek.com/science/…
 
@AlexM. There's send message functionality :3
 
1:19 AM
yup
never used it myself
 
stringly typed programming :v
 
@Rapptz Go wash your mouth out with soap, young man! And don't let me catch you using language like that again, you hear me?
 
yes sir :(
 
ahaha
 
@Rapptz Much better!
 
1:32 AM
@Rapptz toString on everything?
 
@Rapptz Haha nice.
Good morning.
 
2:14 AM
Hi all
 
2:34 AM
Hinyth.
 
hi
 
hi
 
\o
anyone else here paying attention to Google IO?
 
2:43 AM
Nope
@Mysticial Stop ruining youtube
:(
 
New Doctor Who trailer released, after months of waiting, by the BBC. YouTube says "the uploader has not made this video available in your country." Go frak.
 
user3010322
Trolololol.
 
Yeah it's ancient
 
2:49 AM
Puppy was 6 when that article was first posted (and Jerry was 65)
 
Thus, a TIL.
 
> There are thought to have been fewer sperm donors after the right to anonymity was removed in 2005.
but why
 
user3010322
Because some almost-adult will come to you and tell you they're your son/daughter and you should take care of them and help them! :D
 
sperm is worth a bit here
 
@Rapptz Then how come most of it goes to waste? (sorry for the pun)
 
2:53 AM
because you touch yourself at night
 
^ that actually makes sense
 
user3010322
 
> Some clinics rely on imported sperm to keep up with demand.
Man, the UKIP is gonna throw a fit.
 
user3010322
Wait.
 
user3010322
3:07 AM
Why is there so much demand for sperm?
 
user3010322
Is there really such widespread infertility? o.0
 
ukip sounds like a legit name for a pokemon
 
user3010322
3:24 AM
mudkip
 
vote to remove hold?
0
A: C++ extend scope of automatic variable?

ChimeraAs a follow on to Lightness Races in Orbit's answer consider the following: #include <iostream> class Foo { private: int i = 4; public: Foo(){ std::cout << i << std::endl; }; Foo( int i) : i(i) { std::cout << i << std::endl; }; ~Foo() { std::cout << "Foo " <

I think I edited his question so it's more clear...
 
user3010322
@Rapptz Thought the sick, I figured it out!
 
..?
 
user3010322
We can now remove the static shared_ptr<userdata> thingies!
 
user3010322
userdata's state is stored completely inside of lua.
 
3:36 AM
I need to re-evaluate some of my life decisions.
 
user3010322
Which ones and why?
 
I'm talking to a scammer at 11:40 PM on skype
Do these people get bored?
 
user3010322
Lmao.
 
I wish I was joking.
 
@Rapptz It seems that you're the one who got bored.
 
user3010322
3:37 AM
@MarkGarcia He's trying to sink them to his level of boredom.
 
user3010322
This is kinda weird. I should probably make push an element of sol::userdata<T>
 
user3010322
because I'm doing a bunch of mutable operations on it from the outside. Which is... ... weird.
 
conversation
Some random guy added me on Skype
@MarkGarcia Yeah. Apparently bored enough to do this at night.
 
user3010322
wdhjwdhawkdjw
 
user3010322
y array_view no part of std:: ;~;
 
user3010322
3:41 AM
Gosh. Now I have to make a mini-one manually. Gaaawwwsh.
 
I don't like where this is going :v
 
user3010322
Well.
 
> [11:20:39 PM] Bryant Robert: please what do you do please
[11:20:55 PM] Danny: I work in medicine.
[11:22:48 PM] Bryant Robert: good my dear
[11:23:47 PM] Bryant Robert: please are you married?
[11:24:12 PM] Danny: No.
[11:24:40 PM] Bryant Robert: okay
[11:24:57 PM] Bryant Robert: please can i trust you on you?
[11:25:03 PM] Danny: Okay.
 
user3010322
You had a problem with 4 std:: vectors
 
this looks strikingly similar to a discussion I had with a chat bot
 
3:43 AM
Yeah I've had two chat bots talk to me.
 
@Rapptz Please, what did he say next?
 
He deleted me
 
I was hoping he would "out" himself and answer your question.
 
I was on the inside too.
:(
 
I'm curious too if those things actually work.
 
3:46 AM
I wonder if there are any scammers of scammers
like, people who search for scammers, and in the end scam the scammers
 
@AlexM. There are, but most just prepare when a scammer contacts them. Example.
 
I think I remember that
 
Aw.
I should have booted up a VM.
 
did it get an article on ars technica too?
> "Please, Mister aveilleux, I need you to follow my instructions exactly or else your computer could be at risk for viruses from the Internet or other malware."
 
At least those scammers I can see being believable
but not the ones I run into
 
4:00 AM
shit, I had no idea what spacedicks is
6
now I wish I hadn't found out
 
@Rapptz Why did this get 6 stars? o.o
 
I have no idea
 
Considering ECS regularly gets bashed here
 
No one bashed it
 
user3010322
@Rapptz The following now works perfectly: coliru.stacked-crooked.com/a/01d92cae003508ef
 
user3010322
4:11 AM
Now people do NOT have to keep sol::userdata around.
 
@Rapptz Not yours, but I remember cat coughing up a furball after I mentioned it
cba to find a quote
 
Cat hates everything.
 
user3010322
But everyone loves Cat. <3
 
@Borgleader ECS?
 
Entity component system
 
4:12 AM
@MarkGarcia Entity Component System
 
Oh.
 
Cat even hates his own answers
Always complaining they get upvotes
:v
@Borgleader I still don't know if anything is wrong with it.
@ThePhD Oh that's pretty good.
I don't remember set_userdata
 
user3010322
set_userdata used some gnarly shared_ptr stuff
 
user3010322
To keep things alive
 
user3010322
Or, if you used table.set_userdata directly, you had to keep userdata<T> alive yourself.
 
user3010322
4:17 AM
Now, you don't need to do any of that whatsoever! :D
 
new_userdata kept std::shared_ptr around
and I was the one who wrote that
cause of the lifetime issues
 
user3010322
I know you did, so I wanted to get rid of it so a person didn't have to use that for lifetime 'n' stuff.
 
user3010322
Is there anywhere else where we keep shared_ptr's ?
 
don't think so
 
user3010322
Even calling collectgarbage() doesn't trigger the "hidden" global table for the class to die.
 
user3010322
4:21 AM
Pretty sweet.
 
user3010322
Only dies when the VM dies.
 
user3010322
And to make it extra-hard to tamper with, I use the recycle UTF8 code for it. :D
 
So...
 
I just used a get-nth-place-digit-from-int to check if a number's hundreds place is 4. facepalm
I probably need more sleep.
 
4:33 AM
4..?
You mean 3?
 
@Rapptz I mean, if a number is 400, 401, 402...
 
Oh.
Why not divide by 100?
 
lol. i >=400 && i <= 499.
And I missed again. What's wrong with me???
 
i % 1000 / 100 == 4
 
(i / 100) == 4
 
4:36 AM
4444 / 100 == 44
 
user3010322
@Rapptz Pull request is up.~
 
Before I realized that, I even made sure to account for cases like 1400, 2003402, where the hundreds place is 4.
 
user3010322
With this.... sol is probably the best lua <-> C++ binding glue / wrapper to ever grace the face of the planet.
 
talking about which...how many times do you plan on forking Rapptz?
 
user3010322
This should be the last time.
 
4:37 AM
do you keep deleting your repo? =p
I'm keeping my eye on you!
 
@Code-Apprentice i % (decltype(n))std::log10(n) / 100 == 4 obviously.
 
user3010322
There's only one for feature I need to add/fix, and that's copy-by-default on set_function and support for lua.set_function<R(T...)>( ... ) and lua.set_function<T...>( ... )
 
user3010322
After that, sol is pretty much as feature-complete as I can imagine it being.
 
gotta multiply by some constant
too lazy to edit
 
4:39 AM
log base 10 of 123456789 casted to int is...
8.
 
need to do 10^8 :v making the log10 useless
apparently my 8 key is sticky
 
I won't ask why
bah, my test suite is waaaaaaaaaay too fragile
 
I'm tired
 
go to bed
so what is the significance of 123456789 % 8 in your example, anyway?
or did you already figure out that doesn't work?
 
4:47 AM
I already knew from the get go
 
user456814
Spam, burn with fire please:
* http://meta.stackexchange.com/questions/234736/my-real-charming-look-fast-with-supplement
* http://meta.stackexchange.com/questions/234735/you-cannot-lose-the
 
okay...no wonder I was confused
 
@Cupcake How ironic that you decide to spam chatrooms with this message.
 
5:03 AM
@Cupcake Please do not spam us with spam.
 
5:45 AM
wtb disabling Firefox's window close button
 
user456814
Ok, sorry guys, won't happen again.
 
@CatPlusPlus I actually wish Windows would provide a Window Manager API.
 
@Nican There's DWM.
 
user456814
6:11 AM
@Mysticial the funny thing is, the other "duplicate" question didn't get taken down yet. I guess whoever issued the DMCA didn't notice the other one yet.
 
@Cupcake lol yeah. I noticed too.
It doesn't look like the Streisand effect is gonna happen this time. At least not like it did to CipherCloud.
 
#define M_PI 3.14159265358979323846
 
6:56 AM
:lol: 'copyright violation' on 15 lines of useless code
 

« first day (1351 days earlier)      last day (3596 days later) »