- Viewing Profile: Reputation: laztrezort
Community Stats
- Group Members
- Active Posts 402
- Profile Views 2,831
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
#4957036 Help with xna textures
Posted by laztrezort
on 08 July 2012 - 03:41 PM
#4956966 [help] how should I save objects?
Posted by laztrezort
on 08 July 2012 - 11:05 AM
I'd read using reflection to look through the assembly requires a bunch of extra meta-data be produces and that it can make method execution 4 times slower because of this.
is this wrong? or insignificant?
Also I intend to load the game objects on the go via chunks, so the levels can be fairly large.
Sure, reflection code is slower than non-reflection code (because it has to do a few extra steps), but I am still skeptical it would matter at all in this case, since the IO time will vastly overwhelm everything else. Reflection isn't that slow, after all.
P.S.:
Let's take a completely contrived example, with completely contrived values:
You have your reflection-based object creation system, and it is taking 20 ticks of time. You spend a bunch of time optimizing it, replacing the simple, readable & maintainable code with hackish, brittle code, and now you have a 5 tick system. Great, but the creation system is being called in an outer loading method that is taking 1000 ticks on its own (due to disk IO). Congratulations, you've just increased performance by less than 0.1%. This is why you always see people harping on and on about "profile first, then optimize", since things like "4 times slower!" can be very misleading in the big picture.
#4956831 [help] how should I save objects?
Posted by laztrezort
on 07 July 2012 - 11:32 PM
When loading I need a way to tell what a component is, so I can run that components loading constructor wherein it builds itself with the data following its identifier, then it'll go onto the next component, check what it is, run its loading constructor, etc. etc. etc.
Can't you store the typename along with the object data, then use Activator.CreateInstance to create the objects?
Whenever I look up reflection I always find something about how it brings very notable overhead and is a practice to avoid
If you are loading objects from disk inside your inner loop (60 times a second), I would think the IO would be the bottleneck, not reflection. Also, why would anyone suggest avoiding something as powerful and handy as reflection? Like all the other supposed performance killers (linq, multi-dimensional arrays, regex, polymorphism, etc.) its probably best to use what works well first before handicapping yourself with premature optimization. Especially if you are developing for PC, which I've found can handle an obscene amount of "overhead"
#4955441 procedural map generator for sidescroller
Posted by laztrezort
on 03 July 2012 - 02:22 PM
#4954574 reading data file c#
Posted by laztrezort
on 01 July 2012 - 11:04 AM
However, i have come across a problem. I am trying to create a more open ended way of creating monsters for the game by the game reading .txt files.
You could look into something like JSON, there are a couple of libraries available, such as http://json.codeplex.com/. There are also built-in libraries for XML parsing in .NET, but XML is a bit more complicated and probably overkill (IMO).
#4954109 Building a calculator in C#, stuck on doing the math stuff.
Posted by laztrezort
on 29 June 2012 - 03:49 PM
My advice: start with console applications for now, trying to learn Winforms + C# + general programming all at once is a bit much.
As Telastyn said, make a console application that takes input from the user and adds them together first.
#4953779 2D game, pursuit code Q's
Posted by laztrezort
on 28 June 2012 - 04:31 PM
I'm currently working on a rogueish/nethack text game, I'm somewhat stuck on how to implement the pursuit code (how a monster chases down your character). I somewhat took a stab at it and currently have the monster take your X,Y, and by using a series of subtractions/additions relative to it's own position, did manage to have it head towards your general direction quite consistently. But say it runs into a wall that's in it's way, should I code it somehow so that it knows it's looking at a wall and have it try to figure out how to walk around the wall to get to you? Or should I just make it cheat a little, and just record your keystrokes from the moment you start fleeing and just have the monster follow your footsteps exactly
? Thanks for any info!
There are a couple ways this can be handled, depends on how you want to model your AI. If you want "perfect" AI, then you can use pathfinding (with A* or A-star being the common one).
If you want imperfect AI (or more realistic), you can try simulating tracking by scent and/or sound. There is an article here about this: http://roguebasin.roguelikedevelopment.org/index.php/Tracking_by_Scent_and_Sound
While I'm link roguebasin, here is another that might be relavent: http://roguebasin.roguelikedevelopment.org/index.php/The_Incredible_Power_of_Dijkstra_Maps
#4953315 When it comes to C# I am at a deadend when it comes to what to do.
Posted by laztrezort
on 27 June 2012 - 06:38 AM
As you keep building projects, you will notice that you keep using the same patterns, refactoring the same set of code. Polymorphism theory and practice (for example) can be explained in a book, but until you use it, get comfortable with it, notice how it simplifies and leads to more elegant code, over and over again in 20 different projects, you will not really grasp it.
#4951406 Tile size in a 2D Map
Posted by laztrezort
on 21 June 2012 - 10:24 AM
One suggestion I can put out there, though, is to design your tile engine to support any size of tile, so that if your art direction changes (and it probably will!), you can adjust accordingly without having to re-write a bunch of code.
#4949910 Collision detection, 2d environment with C#
Posted by laztrezort
on 16 June 2012 - 04:11 PM
This is how I usually tackle these things: get out a piece of graph paper, draw out a simple test case and write down what each variable value should be, then step through the code until there is a discrepancy between the graph paper test case and the watch variables.
#4948958 [C#] Game Saving Problems, Files are too large
Posted by laztrezort
on 13 June 2012 - 04:41 PM
What kind of objects are you saving? What exactly does a single "block" consist of? How are maps being stored in memory? How exactly are you serializing?
#4948952 Newbie: Questions about 2d game development.
Posted by laztrezort
on 13 June 2012 - 04:24 PM
Is it normal that I have to do a LOT of coding before I make a game or I need a proper UI to speed up the development?
Yes, games are a LOT of work - both on the coding side, and on the asset creation side. Note that even if you go with the Unity3D route, you will still need to do some coding (just a lot less), and you will still need to make all the assets. Also, Unity is a complex piece of software with it's own learning curve - but there appears to be a lot of support through forums and tutorials. Personally, I prefer working in XNA, but that is because I enjoy the programming side of things, where Unity3D always seemed more targeted for an artist-minded developer - your mileage may vary.
If you've got the basics of XNA and C# down, you could try out FlatRedBall which, last I checked, has some support for higher level game development tools. It is basically a 2d engine built on top of XNA.
There is also something called GameMaker that can be used to quickly create basic 2D games with minimal programming, if that is what you are looking for.
Of course, as you gain experience, coding gets much quicker (less backtracking, less refactoring, less research, and reusing pieces of code you have amassed).
Is there any other 2d engine that I should use instead of XNA (something more ideal for beginners)? If yes please mention some.
Although I have never used it, there is Python + Pygame (and there are likely other libraries for Python as well). I've heard it's "good for beginners", but again I've never gotten into Python much.
My personal opinion is that unless you are getting too discouraged, try and stick with one thing until you feel like you've got a fairly good grasp of it. If it's too hard, lower your goals abit - a completed "simple" project is more motivational than a complex one that never gets done.*
* P.S. for the record, although that is my advice, it is advice that I never seem to be able to practice ;)
#4948371 Virtual Machine/Scripting/Console in XNA using C#
Posted by laztrezort
on 11 June 2012 - 08:21 PM
Object[][] args2 = new object[1][] { new object[2] { ref camera.Position, ref camera.Target.Position } }; <----doesnt work.
Whats happening is the position isnt updating to match the true position of the camera. Its staying at whatever the position is at the time of creating the widget....
It's possible I'm still misunderstanding, but here is how I see it:
You want to reference the two Position values - however, Vectors are structs, thus value types, so they are being copied into your new object (just like any other value, such as an int).
What you need to do is copy a reference type that contains and exposes those values. In the above case, "camera" is (probably) a reference, so couldn't you just have your object keep a copy of the camera reference?
In general, when you want to hold on to a reference to a value type, you need to put it inside of a reference type.
#4947951 C# stop waiting on events
Posted by laztrezort
on 10 June 2012 - 10:46 AM
It's targeted for XNA + Winforms, but should be applicable in straight Winforms applications that need animation timing as well.
#4947265 Efficient coding in C#
Posted by laztrezort
on 07 June 2012 - 09:31 PM
- Home
- » Viewing Profile: Reputation: laztrezort

Find content