sábado, 12 de março de 2011

Lua engines for games development

Today I just started my post graduation (please tell me which is the correct term in english for a specialists after the graduation course that is not a master degree =D) and I saw one really good 3D engine with lua: Shiva from StoneTrip Oh the free version has lots of features almost all of the pay features are in the free version too, for lone wolves or small start up teams seems to be a good option. Then I remembered Love, another engine but a 2D, a good one =D also written in Lua. I know that this turn I'm not posting how to use them but at least is a start to know what is out there in the world for programming good games =D. Oh and just to a small note Lua is a brazilian programming language and I'm happy to say that is better than some crappy things we see out there =D

domingo, 20 de fevereiro de 2011

XNA Adventures: Building a Sprite Class

Hi everybody!
After some time playing with XNA I decided to start spreading what I know so others don't need to suffer in some problems and can enjoy as much or even more than I'm enjoying play with it.
In this first tutorial I'll show you something very basic that is a simple base Sprite class that you can expand or use in any project (I'll use it in my next tutorial to show 2D animation).

Requirements:
Visual Studio 2010 or 2008; (I'm using VS2010)
XNA 4.0 or 3.x; (I'm using 4.0 so somethings might need changes, just ask me if you got any problems ok?)
Start by creating a new windows game project in visual studio then create a new class named Sprite. This class will be the base for any sprite (i.e. char sprite, life sprite, background and so on) that you create so don't add any specific logic here.

A sprite needs a texture (the image), a position, a size, a scale and his asset name. Let's add them as attributes

The properties are now in their place but we don't set any of them, we're going to do this using two methods: Rescale and LoadContent
-Rescale: This method will verify if the texture exists and then will rescale the image trough Size property; -LoadContent: This method will load our texture and rescale the image properly calling Rescale.

Ok almost there, we just need to draw our sprite and update it so it'll be prepared to future movement input.
To achieve that we will add two drawing methods and one update method.
-Draw: Use a SpriteBatch.Draw method to draw our texture in the screen;
-Update: Change position using sprite speed and direction and the game time.
The drawing method should be like this

Basically the parameters we're passing to SpriteBatch.Draw are:
-Texture: _spriteTexture;
-Position: Position;
-SourceRectangle: sourceRectangle; This represents the area of your image that actually will be draw to the screen, everything that is not inside this rectangle will be ignored.
-Color: Color.White; This is the a color to tint your sprite. Use white if you don't want to add any color layer to your image.
-Rotation: 0.0f;
-Origin:Your sprite origin, in this case it will be upper-left corner (0,0).
-Scale:Scale;
-SpriteEffects: flip your image here or use none;
-LayerDepth: xna draw textures in layers, use 0 so xna organize the layers or specify a number to set your texture layer;
To finish our Sprite class we only need an update method

From here you can change and adapt it as you desire.
If you just want to test it go on and change your Game class with the following code

That's it guys!

sábado, 5 de fevereiro de 2011

Before starting to code for Android

So many people asked me "what is needed to start creating apps for Android?" that I decided to make a small guide here to help you in this awesome quest. First of all download the following:
Now start by installing JDK package, if you already have be sure that it's updated to version 5 or 6.
Then extract the sdk zip file in an easy to find folder. Do the same for eclipse but in another folder.
Now I'll try to make this easy so follow the image:
  • Click in Install New Software on Help;


  • Wait for it to update and select Developer Tools. Now you see the installation list, read the license agreements (accept it otherwise you can't install anything :P);
  • Reestart Eclipse. 

In the future when you need to update your SDK, simply repeat the steps above, just skip the Software Site adding.

To complete the SDK installation  we need a few final steps.

  • Open Eclipse, if isn't already opened, click on Window > Android SDK and AVD Manager. The manager gives you the capability of controlling your virtual devices (like iphone simulator), your installed packages and install the availables packages. 

  • After that your gonna select available packages > select all of android packages (if you want to select the third party packages is ok but will take longer to download). 

  • Click in install selected and go drink some juice. 

The installation is completed but we're not there yet, there's still the AVD to configure.
Access the Android SDK and AVD Manager again, once there click on Virtual Devices > New, the window bellow should appear. Fill the information and click  in Create AVD.

Name -> A name for your virtual device;
Target -> Which version of the Android OS the device will simulate;
SD Card -> If you need it fill the size or use a file (a .iso file);
Snapshot -> Check this if you want to save state. The same as vmware/sun virtualbox snapshot;
Skin -> Specify the resolution, I often use built-in;
Hardware -> Set your hardware needs. Like GPS and Track ball for example.

Good to go guys!!! Have fun... Any problems, doubts, sugestions plz let me know. Oh almost forgot the reference: Android Development Site

Troubleshoot


If anything goes wrong check if the SDK folder is set in preferences. Access Preferences on Window and you should see the image bellow. Select Android and then browse the SDK location




quinta-feira, 13 de janeiro de 2011

Coding what? Coding Dojo!!!

Since I started to participate in py dojo people I invited have been asking me what is a coding dojo? In the beginning I didn't have the right awnser  to this question but as I went trough the dojos this awnser became more clear in my mind.

The awnser to the question: What is a Coding Dojo?

Basically a coding dojo is a meeting of developers group where they solve problems together in an specific language. Is good to remember that the type of dojo I'm describing here is non-competitive and fun where any level of skill is permitted, as far as I know there are other type of dojos with different focus.

The objectives are: of course have fun; improve your skills in the language used, your team work and your brainskills to solve problems (normally they are quite challenging).

Ok then, but what is needed for a coding dojo? The minimum requirements are an PC or Laptop, a local for the meeting, a projector and a minimum of one developer with great knowledge for being the guru.

The master is the guy that guides the dojo and guides the group in moments of doubt about the language.

How the dojo is organized

Now we already know what it is and what is needed. The next step is the execution, it happens more or less like this:
  • 20 min for choosing the problem and the initial approach.
  • a quick lunch, like 10 min or less (is easier to think after you eat).
  • First part with a real action, 1st hour coding.
  • another quick lunch, more 10 min or less (just to take a breath, sometimes the group solved the first challenge at this point).
  • Second part with more real action, 40 min or so coding.
  • After finishing we do a quick retrospective about the session with the good and bad things. The tip here is to use a board and put post-its with + and - signs, people tend to feel more confortable writting than talking.

How to the code the code

The meeting is organized but how we're supposed to code is not. If my memories are ok at the dojo I'm participating we use Randori Kata which is a way of saying how things happen.
  • The problem is solved in pairs, like extreme programming, a driver and a copilot.
  • Everyone is invited to help on the right time (I'm going to get the list of rules and update here).
  • Each pair has a timebox to advance, 7 min works for us.
  • Use TDD and BabySteps, is hard I know but you'll have to give your best.
  • Every time a timebox ends the driver gives his place to the copilot and another person takes place as the new copilot.
Things that worked for us

Add a white board and post-its as requirements. The white board is used to solve the problem, remember the problem, to place the rules of the dojo and for the retrospective time when we place the posts-its with good and bad things.

Try to change where the meeting occurs, like three weeks in one company, other three in an university and so on. This is good for seeing new places and new people.

Also try to change the days of the week it occurs, one week on monday the other on wednesday and so on. This helps newcomers and members being more constant.

My vision

All this explanation and I didn't mention a single word about what I think. For me the dojo exercise/teach us some important points:
  • Problems are not always only a matter of language.
  • Playing as a team is important, but think as one is a learning process.
  • TDD, boy this skills is fun and good but hell is dificult to get used to.
  • You're not alone in the world, the exchange of knowledge is a must have, exercise it! (is good to meet new people)
  • Attention, if you don't pay attention you'll loose yourself in the process.
  • Oh and I can't forget the fact that we are increasing our skills in the choosen language.
  • Having fun!!!
These are just a few reasons for participating of a coding dojo, pick one and happy coding.
 
To end I must thanks Rodolpho and Chester for leading such a great group of python coding dojo at São Paulo, Brazil.