New game and app is comming …

Since last days I was working hard on my next game and first application.

Game
It is called “Chem-Quest”. I started working on this game 2 month ago, it was my first look on Android. There is no framework in this game. I combine XML layout and drawing on View’s Canvas.
I want to say that it wasn’t simple to handle graphics as using framework, but I want to try this way. Most problems is how to scale on different displays. Still game is not best on smallest devices (less than 180×160).

In this game graphics is more complex, almost beautiful I’d say 🙂 It was not created by me, but my friend.

Still I need to spend some time to test all paths. I hope it will be published tomorrow or day after tomorrow.

Application
First application, but it is almost like game. Actually it is based on other game called “Remember Me: Balls” – this game needs days to finish.

Application is called “Lotto-Blender”. It is a lottery randomiser or lottery number mixer. It is based on AndEngine and it was created in 3 days till now – yes only 3 days.

Graphics is simple but I think quite nice, all created in Gimp using some filters.

This is important application for me because I used AndEngine physics plugin for the first time. This plugin is a fast and free Android physics engine. It is based on JNI calls to Box2D engine.

The great about this engine is simple way to attach this engine to your AndEngine code.

Application is almost ready, but still I get some errors. I hope it will be published till Monday.

Future plans
In free time I was looking for good free engine for Android 3D games and I could not found any.
There is two or tree that simplified some work, but no full game engine or engine that is in final release.
Most advanced is JMonkeyEngine, but in alpha stage.
Most stable is libgdx and jpc – but without 3D physics and all configuration is on developer side.

So I decided to give up 3D games for now.

My topic for next week is more advanced physics in 2D game, with joins, maybe skeleton physics, and some more advanced graphics. And again I want to use AndEngine.

Did You heard that AndEngine creator is working now for some company called “Zynga”? It is looks that AndEngine become Zynga property, but it will stay an open source.

Happy codding!

Advertisements

Simple Radar for Space Android game

In space-shooter-like game it is nice to have Radar on the Hud.

Tere is simple way to draw radar as a Rectangle shape with dots on it. To do it I will use special Scene to manage dots movement and Rectangle as a Radar to show position of the objects.

Becouse this is only how to to create radar I will use simple graphics – rectangle with colored dots.

1)
First thing we need to define our World size fields. I will handle differend size of world and camera view. World should be bigger than camera size lets set it to 2 times bigger.

In BaseGameActivity class “MrRadar”

    public static final int CAMERA_HEIGHT = 320;
    public static final int CAMERA_WIDTH = 480;

    public static final int SPACE_HEIGHT = CAMERA_HEIGHT * 2;
    public static final int SPACE_WIDTH = CAMERA_WIDTH * 2;

2)
To manage Entities on Radar I will define interface “IRadarObject”. I will extends IEntity becouse of simple get size and position of the object.

	public interface IRadarObject extends IEntity {
		public ObjectConfig getConfig();
	}

Also I define class to hold all graphic information about dot on the radar, like color, etc.

	public class ObjectConfig {
		public int red;
		public int green;
		public int blue;
		public ObjectConfig(int red, int green, int blue) {
			this.red = red;
			this.green = green;
			this.blue = blue;
		}
	}

3)
Now lets define Radar class.

It will be Rectangle – that is simplest way.
To handle all object I should create a Map – it will be managed from our Scene (defined in p.4).

Map radarObjectsMap = new HashMap();

Dots will be draw on rectangle but first I must find a way to transform space points to radar points.
To calculate x position of the object I get it is X position in the space and devide it by space width – this is my percentage of the space where object is paced, so this is also percentage of position on radar.
It is very simple and can be done like this:

	
private Pos convertPosition(IEntity ent) {
		Pos pos = new Pos();
		pos.x = (ent.getX() / MrChain.SPACE_WIDTH) * getWidth();
		pos.y = (ent.getY() / MrChain.SPACE_HEIGHT) * getHeight();
		pos.width = this.getWidth() * SCALER;
		pos.height = this.getHeight() * SCALER;
			
		return pos;
	}

Pos is special class that contains only fields: x,y, width and height.

I must add methods to handle adding, removing and moving objects on the radar.
I will just use Map. In adding I will define size of the object, first position and color. to define position I will use my method from above. Also I will check if Map already contains this object:

	
public void addObject(IRadarObject obj) {
		if (!radarObjectsMap.containsKey(obj)) {
			Pos pos = convertPosition(obj);
			Rectangle rec = new Rectangle(pos.x, pos.y, pos.width, pos.height);
			rec.setColor(obj.getConfig().red, obj.getConfig().green, obj.getConfig().blue);
			attachChild(rec);
			radarObjectsMap.put(obj, rec);
		}
	}

In similar way I remove objects and update its size, color and position.

Radar class looks like this:

public class Radar extends Rectangle {
	private static final float SCALER = 0.05f;
	
	Map radarObjectsMap = new HashMap();

	public Radar(float pX, float pY, float pWidth, float pHeight) {
		super(pX, pY, pWidth, pHeight);
		setAlpha(0.3f);
	}

	public void addObject(IRadarObject obj) {
		if (!radarObjectsMap.containsKey(obj)) {
			Pos pos = convertPosition(obj);
			Rectangle rec = new Rectangle(pos.x, pos.y, pos.width, pos.height);
			rec.setColor(obj.getConfig().red, obj.getConfig().green, obj.getConfig().blue);
			attachChild(rec);
			radarObjectsMap.put(obj, rec);
		}
	}
	
	public void removeObject(IRadarObject obj) {
		if (radarObjectsMap.containsKey(obj)) {
			Rectangle rec = radarObjectsMap.remove(obj);
			detachChild(rec);
		}
	}
	
	public void removeAllObjects() {
		radarObjectsMap.clear();
		this.detachChildren();
	}
	
	public void updateObject(IRadarObject obj) {
		Rectangle rec = radarObjectsMap.get(obj);
		if (rec != null) {
			Pos pos = convertPosition(obj);
			rec.setPosition(pos.x, pos.y);
			rec.setHeight(pos.height);
			rec.setWidth(pos.width);
		}
	}
	
	private Pos convertPosition(IEntity ent) {
		Pos pos = new Pos();
		pos.x = (ent.getX() / MrChain.SPACE_WIDTH) * getWidth();
		pos.y = (ent.getY() / MrChain.SPACE_HEIGHT) * getHeight();
		pos.width = this.getWidth() * SCALER;
		pos.height = this.getHeight() * SCALER;
			
		return pos;
	}
	private class Pos {
		float x;
		float y;
		float width;
		float height;
	}
}

4)
To define scene I will extends Scene from AndEngie API and in each attachChild and removeChild I will call Radar methods to add and remove objects. Finally I define UpdateHandler to manage object movement.

public class SceneWithRadar extends Scene {
	Radar radar;
	IUpdateHandler radarHandler = new IUpdateHandler() {
		@Override
		public void onUpdate(float pSecondsElapsed) {
			for (IEntity child : SceneWithRadar.this.mChildren) {
				if (child instanceof IRadarObject) {
					radar.updateObject((IRadarObject) child);
				}
			}
		}
		@Override
		public void reset() {
		}
	};
	public SceneWithRadar(float radarPosX, float radarPosY, float radarWidth, float radarHeight) {
		radar = new Radar(radarPosX, radarPosY, radarWidth, radarHeight);
		registerUpdateHandler(radarHandler);
	}
	@Override
	public void attachChild(IEntity pEntity) throws IllegalStateException {
		if (pEntity instanceof IRadarObject) {
			radar.addObject((IRadarObject) pEntity);
		}
		super.attachChild(pEntity);
	}
	
	@Override
	public boolean detachChild(IEntity pEntity) {
		if (pEntity instanceof IRadarObject) {
			radar.removeObject((IRadarObject) pEntity);
		}
		return super.detachChild(pEntity);
	}
	
	@Override
	public void detachChildren() {
		radar.removeAllObjects();
		super.detachChildren();
	}
}

First Android game “Remember Me : Characters”

Finally after 2 weeks of learning Android and AndEngine my game is posted to GetJar.com.

Memory like game with minimal graphics and simple game play.

I’m Java Developer specialized in Web Application and for me AndEngine was easy to learn. It is best for simple 2D games because most of work is done – manage sprites, scaling, base Activity. Of course most of you already know that it is free Engine.

About the game

“Remember Me: Characters” is “clone” of Memory game. Player must remember shape of letter and draw it on blank canvas.

Game in version 1.0 contains Greek, Cyrillic, Chinese, Armenian, Hebrew, Arabic, Syriac, Thaana, Thai characters so there is no chance to get bored.

For trainings you can choose 90% of character to be shown, after some training next levels are ready to play for most experienced players there is 0% of hints level.

So if you are interested check it out on GetJar

http://www.getjar.com/remember-me-characters/