Pages

Sunday, November 23, 2014

Grails and XAMPP MySQL database configuration or any external DB

Not much happening lately. End of the year, have to study a little bit not to get kicked out.

SUBJ: as usually, couldnt find an easy tutorial, so im making one.


  1.  Install XAMPP, launch it. 
  2.  Check the mysql config > my.ini. Remember the user, password and port.
  3. In your grails BuildConfig.groovy add this line:

    dependencies {

    ...

    runtime 'mysql:mysql-connector-java:5.1.34'

    ...

    }

    ...
  4. In your DataSource.groovy comment the defaule values and add your own:
    pooled = true
    driverClassName = "com.mysql.jdbc.Driver"
    username = "username from the config file"
    password = "password from the config file"
  5. There are the environment specific settings. The dbCreate = 'create' means that a new DB is created each time you run the app. Change it to 'update' and the DB will be persisted and updated each time.

         url = "jdbc:mysql://localhost:PORT_FROM_CONFIG_FILE_HERE/dev_db"

    Change the url to the DB schema. Not that you have to create it first in your DB. (I used MySQL workbench to connect to a running XAMPP DB, and created a schema)
  6. Basically that is it, now your app in development mode (or the mode you edited in the environment settings) will use the database you specified. Just remember that you must start the Apache too in XAMPP. 
  7. Oh, and you possibly need to grant permission for the user you defined, it is done through XAMPP mysql admin button.

Monday, November 3, 2014

Finally released my first game!



Much learned during development. If i would start now i would do so much things differently. Firstly - i would plan everything more thoroughly. The most important thing to plan would be the classes and relations, the architecture.

Also during development i played much similar games to mine, and now i would concentrate on a simplier control scheme. Some people have trouble getting the current controls. Which are: tap left part of screen for a small jump, tap right part of the screen for a bigger jump, and tap in jump for a double jump. Still some people prefer smashing their palm on the screen.

A disappointment was that my country isnt supported by google merchant, so i cant sell my app or offer in app purchases. So i turned to ads and a cool survey system that offers double jumps for completing short surveys - Pollfish.

Also one thing learned that game development consists of drawing graphics, that i dont like to do. I just want to code, code, code.

Pollfish integration with Libgdx and reward system.

So, to make pollfish showing in your app is very easy. Even with libgdx, you just make some changes to your androidlauncher.java , like that below.

Recently there was an official guide for libgdx posted, be sure to check it first -> https://github.com/libgdx/libgdx/wiki/Pollfish-in-libgdx

First of all, follow the official guide -> https://www.pollfish.com/android

1)Register  and get your developer id key.

2)Add the pollfish sdk as instructed in the guide

3)Add pollfish init method to the onResume method of androidlauncher:

  protected void onResume() {
super.onResume();
PollFish.init(this, "your id here", Position.TOP_RIGHT, 5);
}

4)Make your AndroidLauncher class implement PollfishSurveyCompletedListener

and add such a method:

@Override
public void onPollfishSurveyCompleted(boolean arg0, int arg1) {
main.surveyCompleted();
}

My libgdx main class has a method surveyCompleted that adds 15 double jumps and saves preferences.

Change the main class initialiation in onCreate, so that you can use main reference in other methods


main = new Main();

initialize(main, config);

Now your app will show pollfish icon when a survey is available, and a surveyCompleted() method will be executed when user completes a survey.

I also tried to make the pollfish icon hide during gameplay using PollFish.hide() method, but seems to me that there are some problems with libgdx, as it steals focus from the Android activity, my hide method call didnt hide the icon. If you implemented successfully the hide method in your libgdx game, post in comments!