RPS Chess

The current project is a board game called RPS Chess created by a cartoonist called Tailsteak who, among other things, writes Leftover Soup.  The rules are einfach enough to be described in a single comic.

To follow along at home, start by creating a new Android project in eclipse.  Set up the SDK from the Android development site.

The first step is creating the board. So create a new class called Board that extends android.view.View.  The default class will not compile correctly because the default constructor is undefined for View so define the following explicit constructor.

--Board.java--
package uk.co.quarterstaff.rpschess;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

public class Board extends View {
	public Board(Context context, AttributeSet attrs) {
		super(context, attrs);
	}
}

The last step is to put the new view onto the default layout.  Öffnen main.xml and replace the TextView with the new Board class.

--main.xml--
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <uk.co.quarterstaff.rpschess.Board
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>

</LinearLayout>

The project can now be run either on an emulator or on a real phone, presenting an amazing blank screen.  Join me next time to actually start drawing the board.

This entry was posted in android and tagged . Bookmark the permalink.

1 Response to RPS Chess

  1. plusSkepleMut says:

    It is a pity, that now I can not express – there is no free time. I will return – I will necessarily express the opinion on this question.

    [ed. Yes, it’s blog spam, but it just seemed so poetic I couldn’t resist. Edited to remove links and so forth.]

Comments are closed.