Gringo: my first Android game

Install Gringo

Install Gringo

Yesterday, my first Android application was finally published on Google Play. Gringo is a simple shooter game that I developed for Android devices in my spare time. I realized this project using AndEngine framework.

In this game you must shoot to the bandits by touching the screen and avoid to hit the ladies. The game speed increases with the passing of time and you will need to improve your reflexes, next you can submit your highscores.

All the graphics was created by Sy Marchio (www.picsy.it)

Thanks to

Working with branches in Git

You normally need to work on develop or feature branch

Create a new repository

mkdir myproject
cd myproject
git init
touch README.md
git add -A
git commit -m "First commit"

Create develop branch

git branch develop
Create new branch named develop

git branch
Show current branches

develop
* master

You are currently working with master branch
git checkout develop
You are currently working with develop branch
git push --all

Push new branch to remote repository

git push origin develop

First develop commit

git add -A
git commit -m "First commit"
git push

Create a release version from develop

When develop branch becomes stable, you need to merge develop modifications with master branch.
git checkout master
git pull
git merge --no-ff develop

merge develop modifications to master branch. The –no-ff options avoid fast forward commit method
git tag -a 1.0
add new tag called 1.0
git push --tags
push tags to the remote branch
git push
git checkout develop

Hotfix

The hotfix branch is used to fix bugs on master branch. Modifications needs to be merged into master and develop branches.
git checkout -b hotfix-1.0.1 master
Create a new branch and switch into.

Add your changes.

git add -A
git commit -m "Fixed some bugs"
git checkout master
git pull
git merge --no-ff hotfix-1.0.1

Merge with master

git tag -a 1.0.1
Add a tag

git checkout develop
git pull origin develop
git merge --no-ff hotfix-1.0.1

Merge with develop/em>

git branch -d hotfix-1.0.1
Delete hotfix branch

git push –tags
git push
Push tags and modifications

Create a feature branch

git checkout -b myfeature develop
git push origin myfeature

Write the code of the new feature
git checkout develop
git pull origin develop
git merge --no-ff myfeature
git push
git branch -d myfeature
git push origin :myfeature

Pull remote branch
git branch -a
Show all branches

git checkout -b develop origin/develop
Create a local branch from origin/develop

Links
http://nvie.com/posts/a-successful-git-branching-model/
http://book.git-scm.com/3_basic_branching_and_merging.html
http://help.github.com/git-cheat-sheets/
http://gitguru.com/2009/02/18/branching-strategies-overview/

How to configure Xdebug on Ubuntu with Zend Server

I assume you have properly installed and configured Zend Server CE from the repository.

First of all you need to install automake:

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install automake

Install Xdebug with PECL as root:

# pecl install xdebug

Note: if you don’t have PECL in your path you can prepend the absolute path before the command

# /usr/local/zend/bin/pecl install xdebug

Now you must edit php.ini file.

sudo nano /usr/local/zend/etc/php.ini

Add these lines at the end of file:

; Xdebug
zend_extension = /usr/local/zend/lib/php_extensions/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000

Note: Xdebug is incompatible with theZend Debugger extension. To disable this component you can log into Zend Server control page at https://localhost:10082 and navigate to tab Server Setup > Components then turn off Zend Debugger. Remember to click the Restart PHP button to apply the changes.

Links:

Install KDE 4.6 on Kubuntu

Kde 4.6 was released on January 26, 2011. If you want to try this new version you can follow this simple steps.

Add backports repository

sudo add-apt-repository ppa:kubuntu-ppa/backports

Update and upgrade the system

sudo apt-get update && sudo apt-get upgrade

Then

sudo apt-get dist-upgrade

After reboot you can see Kde 4.6 in action.

Set up a simple VNC server

Using built in VNC server for KDE or Gnome I ran into several problems, like screen freeze or lost connection.

If you need a VNC server for your current desktop session in (K)Ubuntu you can use x11vnc.

1. install packages

sudo apt-get install x11vnc

2. set a password

x11vnc -storepasswd

3. start the server

x11vnc -forever -noxdamage -usepw

If you want to access your desktop via browser using a java applet you have to installa vnc-java package and use this commans:

sudo apt-get install vnc-java
x11vnc -forever -noxdamage -usepw -httpdir /usr/share/vnc-java/ -httpport 5800

Call-time pass-by-reference has been deprecated

If you recently upgraded PHP to version 5.3.0 or higher, you have probably encountered a message like this:

Deprecated: Call-time pass-by-reference has been deprecated in filename.php

Use & when you call a function foo(&$var) generates the warning message.

Remember that in 5.3 version of PHP only Call-time pass by reference is deprecated but not Passing by reference.

See the example below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// normal passing by reference
function functionA(&$var) {
    $var++;
}
 
// call-time passing by reference
function functionB($var)
{
    $var++;
}
 
// correct call
functionA($var);
 
// deprecated
functionB(&$var);

If you can’t edit existing code, for example, third-party software, you can use these work-arounds:

  1. Turn off error messages: is always a good idea hide any type of error message in a production site. You can use error_reporting(0) function or if you want you can use the @ symbol before any statement. This is not a good solution of this problem.
  2. Allow call-time pass-by-reference in your php.ini file: in your php.ini file you can set allow_call_time_pass_reference = on but this is a temporary solution only until the next version.

Resources:

UTF-8 problem with Spreadsheet Excel Writer

Spreadsheet Excel Writer is a PEAR package that allows you to generate Excel documents.

When we try to generate an new Excel document using UTF-8 string we ran into a display error.

There is a simple way to fix this problem. See the example below:

$workbook = new Spreadsheet_Excel_Writer();
$workbook->send("file.xls");
 
// add this row
$workbook->setVersion(8);
 
$worksheet =& $workbook->addWorksheet("My worksheet");
 
// add this row
$worksheet->setInputEncoding("UTF-8");
 
$workbook->close();

Create a PHP data structure accessible like an array and an object simultaneously

Often we need to operate with objects that sometimes we have to use as an array.
For example we can get an attribute from an object:

$attr = $myObject->attr;

or by array access from the same object

$attr = $myObject['attr'];

We can set data simply like an array or directly.