I'm sure there's a way to get a type (like bool or int or Vector2) using reflection.
To make this page king interesting:
[IMG]http://i54.tinypic.com/2aew7dy.png[/IMG]
A BrainFuck editor I wrote.
[QUOTE=Quark:;28222148]What'd he snip? :s[/QUOTE]
"I can't go three hours without fapping"
I don't get .NET reflection. Is it a runtime thing that allows you to know stuff about classes and variables that you wouldn't know otherwise? Is it a hacky way to not program properly?
[QUOTE=Jookia;28224598]I don't get .NET reflection. Is it a runtime thing that allows you to know stuff about classes and variables that you wouldn't know otherwise? Is it a hacky way to not program properly?[/QUOTE]
Thats how I see it. Turb see's it as the best thing ever.
[img]http://i52.tinypic.com/mt5p2f.png[/img]
[code]<?xml version="1.0" ?>
<maplist>
<map>
<name>The first XML-powered map</name>
<author>Hypershadsy</author>
<number>0</number>
<width>16</width>
<height>16</height>
<depthmap>
0000000000000000
0000000000000000
0000111111100000
0011111111111000
0011111111111000
0011122222211000
0111122332211100
1112233222211100
1122232221110000
1112233211100000
0111223222111100
0011123221111000
0001112211110000
0000111111100000
0000011111000000
0000000000000000
</depthmap>
</map>
<map>
<name>The second XML-powered map</name>
<author>Hypershadsy2</author>
<number>1</number>
<width>8</width>
<height>8</height>
<depthmap>
00000000
00011000
00122100
01233210
00122100
01122110
00111110
00000000
</depthmap>
</map>
</maplist>[/code]
Map parsing from an XML file... It may not seem like much in a thread like this, but I'm proud of it.
[QUOTE=ZenX2;28224197]I'm sure there's a way to get a type (like bool or int or Vector2) using reflection.
To make this page king interesting:
[img_thumb]http://i54.tinypic.com/2aew7dy.png[/img_thumb]
A BrainFuck editor I wrote.[/QUOTE]
You get the System.Type of an object with the extremely obscurely named object.GetType().
Using that, you have access to its methods, fields, constructors, etc. Though you'll probably have to deal with it differently if it's a primitive. But fear not, because there's also the type.IsPrimitive() method.
If you wanted to get an object's class and call the class's constructor that takes 0 types as arguments, supplying it with 0 objects, you'd do
copy = object.GetType().GetConstructor(new Type[0]).Invoke(new object[0]);
But don't use reflection if you want performance. There are several orders of magnitude difference in performance between manually deep copying a class and doing it with reflection.
I finally got my game's online game mode working efficiently and well! :D
I'll make a video tomorrow when I can actually talk loud and clear and not wake up the neighbors.
But my game now supports:
[media]
[url]http://i53.tinypic.com/35n9dtu.jpg[/url]
[url]http://i55.tinypic.com/wbqhrl.jpg[/url]
[url]http://i52.tinypic.com/mvghn4.jpg[/url]
[/media]
[list]Client Prediction[/list]
[list]Ability to quickly, and easily jump in and out of a server[/list]
[list]Server quickly changes settings for changing player counts[/list]
Sorry for flipping my shit on this, but I'm proud that I got this to work, and how well it works with no errors, or crashes ect.
I know the images look bad. It's hard to see what's going on without a video. Hopefully tomorrow I can find some people willing to play for a bit just to show game play.
[QUOTE=DevBug;28224720]Thats how I see it. Turb see's it as the best thing ever.[/QUOTE]
There are very specific uses for it that I wouldn't consider a hacky solution to bad programming... If you have a list of entities (say for a level editor), and you want that list to update whenever you add a new type of entity to the game without having to manually add an item to the list, you could just tell that list to populate itself with all the classes that inherit Entity. Saves you some time when you forget which 3 new entities you had in a total of 30+ entities. It'll just add the entities for you.
[QUOTE=robmaister12;28225755]There are very specific uses for it that I wouldn't consider a hacky solution to bad programming... If you have a list of entities (say for a level editor), and you want that list to update whenever you add a new type of entity to the game without having to manually add an item to the list, you could just tell that list to populate itself with all the classes that inherit Entity. Saves you some time when you forget which 3 new entities you had in a total of 30+ entities. It'll just add the entities for you.[/QUOTE]
Then it goes through all the entities. That would slow down the editor extremely fast.
The visual to my GA is done. The white background is the environment and the squares are the organisms. The goal is to blend with the background. I thought I was doing something wrong at first, but then I found out that it had to do with my mutation step. The top is generation 2 and the bottom is generation 150.
[media]http://i920.photobucket.com/albums/ad43/Portal2121/ga1.png[/media]
[media]http://i920.photobucket.com/albums/ad43/Portal2121/ga2.png[/media]
not if it's just grabbing the names of the entities and shoving them in a list. After you have that list, you can drag/drop it into the editor, and have it either run through a massive switch block to figure out what to create a new instance of, or do some dictionary lookup.
I'm actually considering doing something very similar to this for my level editor right now... but then again, I'm throwing all concepts of good and well thought out design because I need to have a working level editor done in a few days. I can already think of more elegant ways of handling some of the things I do... and I'm cutting a lot of corners. So the whole system I have is probably not a good example to use.
meh. I still think it can be useful in certain situations, but very often it's misused in order to avoid making a very complicated (but also very elegant) solution to a problem.
[QUOTE=ThePuska;28225150]You get the System.Type of an object with the extremely obscurely named object.GetType().
Using that, you have access to its methods, fields, constructors, etc. Though you'll probably have to deal with it differently if it's a primitive. But fear not, because there's also the type.IsPrimitive() method.
If you wanted to get an object's class and call the class's constructor that takes 0 types as arguments, supplying it with 0 objects, you'd do
copy = object.GetType().GetConstructor(new Type[0]).Invoke(new object[0]);
But don't use reflection if you want performance. There are several orders of magnitude difference in performance between manually deep copying a class and doing it with reflection.[/QUOTE]
Yes, I understand that.
What I'm wondering more is this:
Say you have a Vector2 pos.
Some method takes type arguments (<> - These thingamabobs)
I want to get Vector2 to go in between those, essentially.
How would I be able to grab that Vector2 type thingy from pos?
you mean like
[csharp]public static void doSomeStuff<T>(T element)
{
//do some stuff here, regardless of type, since you'll call the method as <Vector2>. Also "element" will have to be a Vector2.
}[/csharp]
or do you mean just calling a typed method like this?
[csharp]public static void someRandomMethod<T>(T element) { /*...*/ }
//LATER, your code...
someRandomMethod<Vector2>(myVector2)[/csharp]
Still assuming pos is a Vector2, I could put someRandomMethod<Vector2>(myVector2).
To yet again attempt to clarify; someRandomMethod<myVector2.GetType().SomethingThatWillBeTheSameAsIfIPutVector2Here>(myVector2) Is what I'm trying to figure out.
If there's nothing like that, what should I do for handling entites in my game?
[editline]22nd February 2011[/editline]
After almost a solid day of work on figuring this out, I grabbed Copyable, a free extension for easy, deep copying/cloning.
Success.
[QUOTE=Jookia;28224598]I don't get .NET reflection. Is it a runtime thing that allows you to know stuff about classes and variables that you wouldn't know otherwise? Is it a hacky way to not program properly?[/QUOTE]
Introspection of any sort is a great way to avoid repeating yourself and to have your program infer details from itself.
For example, in the Fructose compiler, I implement a subclass of AstNodeGenerator for every Ruby AST node type I wish to compile. At runtime, the compiler finds all the types in the assembly that are subclasses of AstNodeGenerator, finds out what AST node they compile by reading the attribute on that class, and adds it to a static Dictionary<NodeType,AstNodeGenerator>.
Example code:
[img]http://cl.ly/3L380w0y3J2o3g27092E/content[/img]
[img]http://cl.ly/2J1q402Q461N0I1r3s2W/content[/img]
[editline]23rd February 2011[/editline]
It's also a good way to hack around any deficiencies in a library you're using:
[img]http://cl.ly/160N3e393d0q1x34052h/content[/img]
I guess my tile/entity framework is done. Now to get to some real game development!
...
Yarr.
12:10AM and I'm reading the W3Schools XSD tutorial so that I can parse and export levels from our own XML format by tomorrow (technically today)... and I'd much rather let Visual Studio take care of the parsing with xsd.exe.
[editline]idk[/editline]
ok, so I taught myself the basics of XSD, wrote the first 89 lines of what will easily become a very large schema... I NEED MORE SLEEP :suicide:
[QUOTE=ThePuska;28225150]You get the System.Type of an object with the extremely obscurely named object.GetType().
Using that, you have access to its methods, fields, constructors, etc. Though you'll probably have to deal with it differently if it's a primitive. But fear not, because there's also the type.IsPrimitive() method.
If you wanted to get an object's class and call the class's constructor that takes 0 types as arguments, supplying it with 0 objects, you'd do
copy = object.GetType().GetConstructor(new Type[0]).Invoke(new object[0]);
But don't use reflection if you want performance. There are several orders of magnitude difference in performance between manually deep copying a class and doing it with reflection.[/QUOTE]
Dear god why.
[url=http://msdn.microsoft.com/en-us/library/0hcyx2kd.aspx]Activator.CreateInstance<T>()[/url]
[url=http://msdn.microsoft.com/en-us/library/wccyzw83.aspx]Activator.CreateInstance(Type)[/url]
If you're trying to do something using .NET, chances are the framework already has a standard way of doing it.
[editline]23rd February 2011[/editline]
As for cloning types, the best method is to physically create a new object and copy over the members if you have control of the design.
Other methods are discussed here: [url]http://stackoverflow.com/questions/1251277/net-deep-cloning-what-is-the-best-way-to-do-that[/url]
[QUOTE=robmaister12;28228181]12:10AM and I'm reading the W3Schools XSD tutorial so that I can parse and export levels from our own XML format by tomorrow (technically today)... and I'd much rather let Visual Studio take care of the parsing with xsd.exe.
[editline]idk[/editline]
ok, so I taught myself the basics of XSD, wrote the first 89 lines of what will easily become a very large schema... I NEED MORE SLEEP :suicide:[/QUOTE]
Our website's CMS uses XML to generate all the pages and the macros you can use are all based on XSLT. It's a nightmare making new ones.
Is anybody else having problems loading tinypic pictures? It will load maybe the odd one or two and the rest just don't load at all.
EDIT: A quick Google later and it seems its my ISPs DNS having problems
I've been really interested in this networking thing. I've done some researching and I was wondering if anyone could let me know if im pretty much correct
-snip-
A server is pretty much a computer or program that sends ore received data to it's clients. I'm hoping that this is correct because I figured this to be a no brainer
My big question is: how can a server run for so long? Hours and hours, maybe even days?
Is a computer really running a program 24/7 for a server to be up for so long?
[QUOTE=Sc00by22;28229578]Is anybody else having problems loading tinypic pictures? It will load maybe the odd one or two and the rest just don't load at all.[/QUOTE]
Use AnyHub. I bought a second server and I'll probably be getting a third some time soon, so it's not as unreliable as it was.
[QUOTE=Venice Queen;28229628]Use AnyHub. I bought a second server and I'll probably be getting a third some time soon, so it's not as unreliable as it was.[/QUOTE]
I use AnyHub for image hosting myself but I can't see any images that people post that are hosted on TinyPic :smile:
[QUOTE=xAustechx;28229598]
My big question is: how can a server run for so long? Hours and hours, maybe even days?
Is a computer really running a program 24/7 for a server to be up for so long?[/QUOTE]
I thought it would of been obvious but you're right, servers can stay up forever running the same program, that is pretty much [URL="http://en.wikipedia.org/wiki/Data_center"]how the internet works[/URL].
I use Reflection for the tool plugin system in my RPG engines editor mode. Basically, I've created an interface for Tools, given it methods for things like, onMouseClick, EnterToolMode, etc
I've then created a seperate class library that references my main project, you can then create classes that implement the interface.
I then use reflection to load in DLLs at runtime and dynamically create instances of each tool that is defnied in the class library.
Basically it'd let people create their own tools and load them in without having access to all the source code.
Also it means I can reload tools at runtime.
[QUOTE=Sc00by22;28229649]I use AnyHub for image hosting myself but I can't see any images that people post that are hosted on TinyPic :smile:
I thought it would of been obvious but you're right, servers can stay up forever running the same program, that is pretty much [URL="http://en.wikipedia.org/wiki/Data_center"]how the internet works[/URL].[/QUOTE]
Thanks for the info. I thought that's how it worked, but something in the back of my head was telling me thats wrong.
So Venice, for your anyhub site, you have physical computers where you live or where you can reach to, keeping anyhub up and running?
-Was still on old page-
Bandwagon !
[img]http://filesmelt.com/dl/DungeonTest_2011-02-23_13-04-43-65.gif[/img]
I actually started this before everyone started to make one !
I use 360 FoV and for generation of the rooms i acually use my own it's slow as hell but it makes really nice Caves
The gif is abit laggy because i made it smaller so people will be happy :downs:
How does it do it? Check for collision on a line between the player and each square in the circle?
[QUOTE=Jallen;28230078]How does it do it? Check for collision on a line between the player and each square in the circle?[/QUOTE]
Yes, 360 lines ran through a Cos/sin so i do not "draw" the lines, the game runs at 60 fps no problem tho the gif is only at 25 fps and the run through virtualdub so it lags alot
[QUOTE=Orki;28230135]Yes, 360 lines ran through a Cos/sin so i do not "draw" the lines, the game runs at 60 fps no problem tho the gif is only at 25 fps and the run through virtualdub so it lags alot[/QUOTE]
If the circle has an area of less than 360 squares it might be better to check for an intersection of the line between the player and each square with a wall (so line starts at player, ends at square you're checking, if the line intersects a wall, the square you're checking becomes dark)
That's the way I'd do it anyway. Your way works well though, looks good.
Sorry, you need to Log In to post a reply to this thread.