sexta-feira, 14 de dezembro de 2012

Instalando PostgreSQL no Mountain Lion

Antes de tentar instalar o postegres eu recomendo tentar o postgresapp, rápido e fácil.


Agora se você mesmo assim quiser instalar direto na máquina


No terminal rode uma linha por vez:
- brew install postgresql
- initdb /usr/local/var/postgres -E utf8
- mkdir -p /Library/LaunchAgents
- cp /usr/local/Cellar/postgresql/%versãodopostgresql%/homebrew.mxcl.postgresql.plist /Library/LaunchAgents/ launchctl load -w /Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Obs: substitua %versãodopostgresql% pela versão utilizada, ex: 9.2.2

Se o brew cuspir um erro de syslink como por exemplo esse:
Error: Could not symlink file: /usr/local/Cellar/postgresql/9.2.2/share/doc/postgresql /usr/local/share/doc is not writable. You should change its permissions.
Abra a pasta em questão e dê permissão ao seu usuário de escrita e leitura e depois execute:
brew link postgresql

Existe um fix necessário com relação ao socket para pg, execute os seguintes passos: - mkdir /var/pgsql_socket
- sudo chown $USER /var/pgsql_socket
- Abra /usr/local/var/postgres/postgresql.conf num editor de texto e descomente unix_socket_directory editando para unix_socket_directory = '/var/pgsql_socket'

Use o comando abaixo para rodar o server:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
E esse outro para parar o server:
pg_ctl -D /usr/local/var/postgres stop -s -m fast

Se o server não conseguir desligar, descarregue o autolaunch e tente novamente: launchctl unload -w /Library/LaunchAgents/org.postgresql.postgres.plist

Se o psql --version for uma versão diferente da instalada então o Mac está usando o command line pré instalado do psql. Exporte o PATH no bash_profile para fazer com que o OS use o correto.
- Execute no terminal: open /.bash_profile
- Adicione a linha e salve: export PATH="/usr/local/bin:/usr/local/sbin:/bin:$PATH"
- Reinicie o terminal para que as configs estejam corretas

Pronto você já deve conseguir conectar no host com:
psql -h localhost -d "nomedobanco" (rodando psql -l é mostrado o nome do banco)

Quando conectado você pode executar comandos sql suportados pelo postgre e use \q para sair do console.

Baseado em Install Postgresql on Mountain Lion

segunda-feira, 29 de outubro de 2012

Using multi touch in CoronaSDK

Multi-touch is a very useful feature for games and mobile apps and comes frees of charge in native applications, but how do you use it in CoronaSDK?

Its simpler than one can imagine.

On your main.lua add the following activation codeline

With this your "touch" listener will have more than one touch in its event variable, an id property is available to identify each different touch.

Ok but it would not be me posting if I let you guys with only that ummm lets say dumb tip.

To try it out create a blank project with a new main.lua and our multitouch activation.

Let us place two round buttons to control a ball that will move it horizontally and vertically when these buttons are pressed. Also add a name variable with a differente identifier for each button, we will use it to know when each one has been touched.

You're probably seeing something similar to this

Now to the moving part.

Create a function for listening the touch actions and add it to both buttons.

When you execute it in the CoronaSDK Simulator one thing will come to mind: "How the hell I test it if I can only use single touches?"

Yes my friend that is an annoying problem, you will have to build your application and test it directly into your device. If you don't have one I suggest you to check if corona ultimote or luaglider (cider) have anything useful on this case.

Happy touching.

quarta-feira, 11 de julho de 2012

Using sprite sheets in CoronaSDK

A thing that is very common and useful in game development is the application of sprite sheets. Most of us make of this a day-to-day tool, but some don't know what it is or how to use it depending on the platform or because of any other problem.

So before we start I'm going to give quick defs.
- Sprite - its the assets representing an image in your game. Like an 1up mushroom from SMB.

- Sprite Sheet - its a group of sprites in a single file, can represent various animations or simply a group of static images used in the game. Like the zero sprite sheet bellow.

For the first demo we're going to use a classic character the jelly!

The jelly sprite sheet is equally divided, that way we don't need to care about specifying each frame individual settings.

Start importing the sprite classes from CoronaSDK, they are required to our code.

Each jelly sprite has 37x47 and we have 16 frames on our sheet so Corona needs to be informed of this, for that purpose we use a simple lua table.

Now we can call the graphics.newImageSheet using the sprite sheet filename and our table.

So we have our sheet with a few lines, now we need to specify the frames we want to display and create the image onscreen.

If you run now the simulator now the jelly will appear correctly in the screen but won't animate. Try to add sprite:play() after the scaling code line and watch our jelly flick like craze in the screen.

Lets improve our sample and change our animationData table to the following

Now our jelly feels more "natural". Why is that?

That happened when we added a time for our "walking_down" animation, if you play with it you can speed it up/down, don't forget that the time is given in miliseconds.

 Still we can't switch between animations.

For that purpose we need to improve our code with a couple of lines. Begin changing the animationData to

And to see the changes add some touch logic after the sprite:play() call (in fact you can even replace it)

When you touch left or right of our jelly sprite you'll see it change bettwen walking_left and walking_right animations. That was achieved using sprite:setSequence("animation_name") method.
After calling setSequence on a sprite is necessary to call play() if you want it to run the animation otherwise it will switch to the first frame (start parameter for example) and stay still.

Now it feels better uh, but wait! What if we move our jelly while animating?

Insert a transition call after onTouch sprite:play() line like that:

With these basic steps you added a sprite from a sprite sheet in the screen and made it move left and right.

Hey but it isn´t over yet! When the sprite sheet is like zero sample (from megaman, remeber?) we have to use more complex info on sheetSettings variable and also when we have non sequential animation we need to be more specific on our animationData variable.

Using short samples our animationData could have it walking_left animation re-written to

What we did here is jump through frames 5,2,7 and 3 always in that order for 800ms 2 times.

And to keep things simple, instead of given a gigantic sheet lets imagine sheetSettings can be re-written with every frame of our green jelly that we already know.

Even though this is useless in this case, we can use it for more complex sprite sheet images.

Last question before letting you code for yourself: How the hell am I supposed to build these sheets?

Well you can use some useful tools, let me give 2 hints:
- Texture Packer
- Zwoptex

Leave your questions and thoughts and happy coding!!

quarta-feira, 28 de março de 2012

Lessons learned - Get in the Games Industry

*Procurando pela versão em português? Acesse o NextLevel *

Hi everybody!

Back there when I was watching some GDC sessions I met Lindsey from 38 studios on her talk about dos & dont's on breaking into games industry.
It was such a good talk that I couldn't let that get away without helping the rest of my fellow companions that are also trying to work with their passion (GAMES YEAH!)

She was very kind to me and gave me all the session info edited in a nice pdf.

Enough with the chat lets go to the goodies.
* Most of these ideas belongs to 38Studios and should not be used without their permission, also this is not exactly their text, I mixed some of my ideas too*

Top 5 - Good ways to network

# 5 - Apply directly
- Try for info on companies in your area
- Try jobportals. I'd personally recommend: gamasutra, Edge jobs and Games Industry Jobs
- Try submitting resume in events (GDC for instance)
- Try job fairs

- On interviewing be prepared to make tests, specific tests, tough tests!
- Prepare a list of questions that you want to make. That way is easy to talk with the interviewer.
- Always, I said always ask for feedback, that shows you're concerned about improving yours skills and also commitment.
- Don't be afraid of picking jobs that aren't initially on your area of specialty. You can start as a QA and try to build up your way to the top, being in the industry is the best way to get a job in the industry (I know it sound strange but is true).

#4 - Social Networking
- Prepare your linked in/stackoverflow account. Don't have one? Stop right now and go signup! (kidding just continue reading ok?). Put everything that matters on your account, don't use it for friends stuff, this is pros place. Events, games, prototypes, recommendations, school, jobs, everything goes here!
- Twitter. You have two options here go pro with your personal account and add companies, team members and job accounts OR Make a professional account where you follow and post only job related stuff.
- Facebook and Google+. I don't really like this option since basically they are personal social networks, but if you want to try them look for apps that target business contacts like BranchOut on FB or build business circles on G+. And please keep embarrassing stuff out of the internet.
- Look for other networking sites, there is lots of stuff happening out there on the web.
- Try placing your demos, prototypes and other related videos on youtube. That will make your name a little more findable on the web and also will show off some of your talent.
- Have a blog! This way you can express yourself about everything you have learned so far, show a portfolio, share experiences. Just remember this is public so be careful on what you write on it ok?
- Playing Games...what? Yes most of the people in game industry play something, so you have a chance of meeting someone online.

#3 - Groups and Communities
- game dev clubs & competitions. Pay attention to game jams they are extremely crucial for getting attention and improving yourself, also is a good way of knowing new people or forming a group of friends. Compohub have mapped some game jams.
- modding communities. This is a good way of starting, here apply the same tip as the previous one.
- if you're an artist check  digital art communities & competition, like CGSociety, CGHub, and Ani-Boom.
- Be part of game development groups like IGDA, WIGI and others.
- This falls on some other tips: volunteering - community management, events, or beta testing. Playing, modding and making games are some effective ways of breaking in.
- Depending on which forums & fansites you post into you can use it on your behalf. Just remember to build constructive and valuable posts, that way even if you're not saying that something is good try to be adding a point of view and a suggestion of improvement (be nice devs/artists have feelings too).

#2 - Conferences and Events
- GDC, GDC Online, a bunch of others.
- Consumer Shows (PAX, E3, etc)
- University-hosted events
- Networking events/parties and meeting
-  Developer open houses/portfolio review

- It's not easy to go into these places and probably that would require some money (often more than you could afford), but if you can be prepared with cards and firm handshakes.
- Take into account each event situation, consumer show isn't hiring centered but GDC has its career pavillion.
- Don't be shy and make them remember you (in a good way)

#1 - Friends
- This may sound silly but having friends that work in industry can help you to be a step ahead. If you made all your previous lessons and have enough good background your friends will talk about you when the time come.
- A huge tip: there is no point of having a friend on Blizzard (pick any company here) if you're not even trying to be an awesome developer/artist/your role here. If you're good at something your friend will talk about you, don't insist from five to five trough sms asking him "Can you talk to your boss about me?" or  "Hey a need a job can you lend me a hand", just let him know once what you're doing. After all you're already friends right?

Top 5 Worst Ways to Network
#5 Inquire through inappropriate means
- Follow the procedures and instructions on job pages, they are there for good reason. If someone asked you not to call don't call.
- Avoid spamming developers, if they don't answer you probably they are to busy to do so, give them time. Also never stop by a studio and hassle people, that is ugly (bad bad professional no donuts for you). There are good ways of meeting people, Lindsey provide some in her document.

#4 Have someone else do all the leg work for you
- Basically don't cheat, meet the people and maintain relationship by yourself. It is your job to get hired not yours girlfriend/friend/parents.

#3 Don't make promises that you can't keep
- If you send an email to someone and that person don't answer you then you get sad with him right? So why would you do the same? If you going to promise something remind of actually doing it, give back what others have given to you, isn't that hard.

#2 Lie
- Again, don't cheat, the industry is small when bad things happen (truth rides a turtle and lie rides a fast airplane). Try to make yourself clear on what you're saying and is better not to get a job than be on a negative situation because of a lie in your resume.

#1 Point fingers or take it personal
- This is the best way to not get a job and even curse yourself. I'll quote Lindsey exact words "This industry WANTS you to succeed. Recruiters want to hire you, Developers want to know more about you, people want to interact with what you create. But there’s a time and place for everything, and even rejections are a part of the process. Keep in mind that it’s rarely about you."
- What she says is a fact if you destroy you own roads instead of building them to new cities how you think you going to get where you want?

There are more must read tips and goog examples on Lindsey`s pdf, so please read it all and you won't regret it I promise.
Get it here

Again a special thanks to Lindsey and 38studios, thank you!!

If you want to know more or just talk about it I'll be glad to do so, just send me an email vitor.navarro87 at

sábado, 25 de fevereiro de 2012

Quick Tip - Lua and Mac OSX

This more fast than a bullet tip can seem misplaced but as I`m closer to Lua, in result of my development on CoronaSDK, somethings I started to try on this new frontier script language (she is quite nice).

So what if you get in love with lua and say ok I`m having fun but I want to get further using it for development in Mac and Windows and Linux WOW.

I going to show you the easiest way possible for Mac (that I`m aware of), follow the steps:

Step One

We are going to use brew to install Lua, this link has more info about brew
Open your terminal (command+space and type terminal then enter)
Now type: /usr/bin/ruby -e "$(curl -fsSL"
Wait it to finish but don`t close the terminal yet

*UPDATE*: The ruby script has moved from to

Step Two

In terminal type: brew install lua
Now wait to the magic to finish...

Step Three

There is no step three, really you only have to use it.
To use it from terminal type Lua. You should see something like this:

bla:bla user$ lua
Lua 5.1.4 Copyright (C) 1994-2008, PUC-Rio
> _

Try typing print("yay it works!")

Bonus Tip

Hey this is nice, fun and I want some extra sweet chocolate on it. This time the chocolate is love2d, a cross-plataform game development framework tat uses Lua as programming language. 

Try to download it and use by yourself.
But I promise that love2d will come back in another post.... soon enough.... I hope.