Cloning Objects in C#

After trying to manually clone some classes, but making a sort of copy constructor I was always ending up with lot’s of code and worse, if I add another variable to my class I would sometimes forgot to also clone it. Luckily and after a search I discovered that C# has a cool thing, Reflection. So you can do something like this: using System.Reflection; class MyClass { public int a; public float x; MyClass() { // default constructor } MyClass (MyClass my) { FieldInfo[] fields = typeof(MyClass).GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach(FieldInfo f in fields) { f.SetValue(this,f.GetValue(oth)); } } } MyClass obj1 = new MyClass(); obj1.a = 1; obj1.x = 2.0f; MyClass obj2 = new MyClass(obj1); // Obj2 will have same values as obj1 and you // can now use them independently. I hope this is helpful. Let me know if you know a better way ...

October 12, 2009 · 1 min · 146 words · David Amador

Programmers are tiny gods

I’ve found this picture on the internet and also an interesting and funny article regarding Programmers/Designers relation on work. I’ve already talked about designers and how their critique training makes them impossible to work with. Luckily the designer I work with knows me well and knows how to make me want to fix that, but not pointing the obvious, issuing orders… This doesn’t work. Fix it. A good tactic is to have parameters, request help ...

October 10, 2009 · 1 min · 181 words · David Amador

The amazing lands of C++

I’m sure every programmer will like this

October 5, 2009 · 1 min · 7 words · David Amador

Basalt gains a media player

So I’ve been working on a sort of media player in order to play movies on my 2d engine Basalt made on top of XNA. By extending my class Object2d I manage to get this pretty cool result. You can even apply shaders to it. Since I extended the class from Object2d I can rotate, scale and set a position to the video besides regular options like play/pause, fullscreen etc. For those who don’t know the video playing is a chunk of the series Naruto Shippuuden ...

October 4, 2009 · 1 min · 86 words · David Amador

Master Web Developer

I decided to take a course on Master Web Developer. It’s a 6 months course covering PHP, actionscrip, HTML, JavaScript, Ajax and more. Hopefully I’m going to fill all my gaps on web development and possibly get more and better works in this area. Also this way I can give better credibility to Different Pixel.

September 25, 2009 · 1 min · 55 words · David Amador

Game Competition

Some time ago I decided to launch a new website with a 48h Game Competition. We are now 2 days away from the Compo#1. This is for every indie game developer wannabe =) [Edit] The first competition is now over. Check the results here One of the games made in the competition.

September 17, 2009 · 1 min · 52 words · David Amador

Stargate

Ok so I got addicted to Stargate Atlantis as well. After watching all 10 seasons from SG-1 I decided to give it a try to Atlantis. I was not convinced that it would be a good show, but the it’s awesome. Atlantis starts around season 8 of SG-1 when Daniel Jackson figures the location of the lost city of Atlantis. Atlantis follows the adventures of a team that goes to Atlantis and being on another galaxy they only have power for one trip so it’s a one way trip only. The characters are great, and the show is very funny, mostly because of Rodney McKay. The new main enemy are the Wraith and the show is years ahead of SG-1 in special effects. I’m already on season 4 so I’m almost finishing. I recomend both show to everyone who gets a chance of viewing them. Since both have been canceled there’s a good chance your find packs containg the whole series. I found SG-1 complete on amazon last weekend. ...

September 15, 2009 · 1 min · 169 words · David Amador

28 Weeks later

I watched a really nice movie today, 28 Weeks Later. I didn’t know anything about the movie so I got rather disappointed with the first 5-10 minutes. When the zombies showed up I thought to myself “not another zombie movie, are this guys out of ideas?” I sticked to see where it the plot was heading, and got a really nice surprise. After the initial outbreak in great Britain, the infected start to starve and they die eventually, so the movie starts 28 weeks later, when the general population starts returning to a safe zone called District One. The infection is still out there and the army is burning bodies around the safe zone. After a survivor is found, they discover that she is immune, however she can still contaminate others. The plot is simple but delivers, the acting is good and some familiar faces are there, such as Robert Carlyle, Harold Perrineau (Michael from Lost) and Jeremy Renner (The Hurt Locker). ...

August 27, 2009 · 1 min · 162 words · David Amador

XNA Sprite Sheet

I decided to take the morning to make a small sprite sheet editor for our Xna engine. This way the artist can easily define the sprite areas and their origin saving in a file that can later on be loaded on the engine. Not very fancy yet but it gets the job done. Next step will be making an animator editor.

August 23, 2009 · 1 min · 61 words · David Amador

Xna 2d Engine

Lately whenever I’m off work and I have the time I’ve been working on a 2d Engine in XNA. We named it Basalt. Cool hum? lol I have almost everything done, since sprites, to sprite animations, scenes, layers, resolution independent engine, game state and a lot of other cool things. On a recent post I’ve showed a 4 split screen prototype, that was made in Basalt. Also I’ve been working, even though on a slower pace on Shappire, the editor and a sprite sheet editor, for the animations etc. ...

August 14, 2009 · 1 min · 98 words · David Amador