Mini php based one page RPG game (rp16g)

This is my submission for PHASE 2 of the Micro Game Coding Challenge.

rp16g Size:5.1 KB Planning and development time ~ 7 hours

rp16g is a small text based rougelike game based on Dragon Slayer. The player (@) must find and kill the dragon (+). The dragon is very strong for the player’s initial fitness so some monster killing is needed to strengthen the player first.

Game features:

  • Game map;
  • Fog of war;
  • Simple battle system;
  • Character stats;
  • Romantic end Grin

The source code of the game is available here:

Small Bulls and cows in PHP

There is competition going on in bbGameZone. I decided to participate with small Bulls and cows game:

Here is my submission “CowsNBulls”.

It’s a game I loved playing when I was younger.

Demo: Source code: (2013 bytes)

The code can be further optimized, but let’s leave something for Phase 2 Smiley Total planning + development + bug fixing time about 1 hour.

Resize column in postgres without recreating

A nice hack for postgres field size:

75% discount on HostGator only today

Today HostGator is offering 75% discount for hosting with code: 75OFF

Move table in postgres to different schema

To move table to different schema in PostgreSQL use:

ALTER TABLE table_name SET SCHEMA schema_name;

Playing with big files

If you’re looking for a big text file to play with, why don’t you try

We invite you to help us share the content of internet by downloading the first part of our index. It has roughly 600,000 pages and is shared in an easy to parse text file. We are making this available as a bit torrent to help conserve bandwidth. Enjoy!

Rating for Blogger (Blogspot)

If you want to add rating system for your posts in Blogger, check Outbrain ( They have fully automated script for that. I’m using it form my animated gifs blog.

Get parameters in Code Igniter

If you want to use GET parameters in Code igniter just for specific controller do use the following line in your Controller’s constructor:


Also make sure to call your script like this (even if you use mod_rewrite to get rid of index.php):

Smooth tile scrolling with Slick


This is my first attempt for smooth tile scrolling in Slick. The offx/offy coordinates are not entirely correct for hero, smaller than the tile image but it’s a good start the “smooth” part comes from shx/shy variables which offset the rendering position. The code is after the break:

Update: Check the project source code page at Google Code:

package scroller;

import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.tiled.TiledMap;

 * @author aquilax
public class Scroller2 extends BasicGame{

  private TiledMap map = null;
  private Hero hero = null;

  final static int screenw = 432;
  final static int screenh = 336;
  final static int centerx = screenw/2;
  final static int centery = screenh/2;
  final static int visx = 9;
  final static int visy = 7;
  final static float halfvisx = visx/2;
  final static float halfvisy = visy/2;

  private int tileW;
  private int tileH;
  private int mapW;
  private int mapH;
  private boolean[][] blocked;
  private int offx;
  private int offy;

  public Scroller2(){

  public void init(GameContainer container) throws SlickException {
    map = new TiledMap("data/testone.tmx");
    tileW = map.getTileWidth();
    tileH = map.getTileHeight();
    mapW = map.getWidth();
    mapH = map.getHeight();
    hero = new Hero("data/hero.png");
    hero.speed = 1;
    hero.xtile = Integer.parseInt(map.getMapProperty("herox", "16"));
    hero.ytile = Integer.parseInt(map.getMapProperty("heroy", "8"));

    hero.xpos = centerx - hero.awidth/2;
    hero.ypos = centery - hero.aheight/2;

    offx = hero.xtile*tileW;
    offy = hero.ytile*tileH;

  public void update(GameContainer container, int delta) throws SlickException {
    Input input = container.getInput();
    if (input.isKeyDown(Input.KEY_LEFT)) {
      moveChar(hero, -1, 0);
    if (input.isKeyDown(Input.KEY_RIGHT)) {
      moveChar(hero, +1, 0);
    if (input.isKeyDown(Input.KEY_UP)) {
      moveChar(hero, 0, -1);
    if (input.isKeyDown(Input.KEY_DOWN)) {
      moveChar(hero, 0, +1);

  public void render(GameContainer container, Graphics g) throws SlickException {
    int shx = (int)(offx/tileW)*tileW - offx;
    int shy = (int)(offy/tileH)*tileH - offy;
    map.render(shx, shy, (int)(offx/tileW-halfvisx), (int)(offy/tileH-halfvisy), visx+1, visy+1);
    hero.draw(hero.xpos, hero.ypos);
    g.drawString("offx "+offx, 300, 10);
    g.drawString("offy "+offy, 300, 30);

  public static void main(String[] args) throws SlickException {
    AppGameContainer app = new AppGameContainer(new Scroller2());
    app.setDisplayMode(screenw, screenh, false);

  private void fillBlocked(TiledMap map) {
    blocked = new boolean[mapW][mapH];
    for(int x = 0; x < mapW; x++){
      for (int y = 0; y < mapH; y++){
        blocked[x][y]  = "true".equals(map.getTileProperty(map.getTileId(x, y, 0), "blocked", "false"));

  private void moveChar(Hero ob, int dirx, int diry) {
    offx += (int)(dirx*ob.speed);
    offy += (int)(diry*ob.speed);

Media Wiki Bot

I needed a bot to quickly modify the pages of So I created Mutex which kind of helps do the job. It’s full of bugs with no error handling but works for me.


login('bot_user', 'bot_password');
  $mw->editPage('title', 'page_text');

You can get the source code from here.