Friday, June 25, 2010

Code Drop

I thought I'd post the code that I have currently, nothing new since the last post. I am thinking if I insert the code into the next post, it would be too long.

GalacticPickle.java:
import android.app.Activity;
import android.os.Bundle;

public class GalacticPickle extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}
res/layout/main.xml:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="*"
    >
    <TableRow>
        <TextView 
            android:text="@string/app_name"
            android:paddingBottom="2dip"
            android:textSize="20dip"
            android:layout_width="wrap_content"
            android:layout_gravity="center"
            android:layout_span="2"
            />
    </TableRow>
    <TableRow>
        <TextView
            android:text="@string/uName"
            android:padding="0dip"
            android:layout_width="fill_parent"
            android:layout_span="2"
            />
    </TableRow>
    <TableRow>
        <EditText
            android:id="@+id/username"
            android:padding="0dip"
            android:layout_width="fill_parent"
            android:layout_span="2"
            />
    </TableRow>
    <TableRow>
        <TextView
            android:text="@string/pWord"
            android:padding="0dip"
            android:layout_width="fill_parent"
            android:layout_span="2"
            />
    </TableRow>
    <TableRow>
        <EditText
            android:id="@+id/password"
            android:password="true"
            android:padding="0dip"
            android:layout_width="fill_parent"
            android:layout_span="2"
            />
    </TableRow>
    <TableRow>
        <CheckBox
        android:text="@string/persistentInfo"
        android:id="@+id/permInfo"
        android:padding="0dip"
        android:layout_width="wrap_content"
        android:layout_span="2"
        />
    </TableRow>
    <TableRow>
        <Button
            android:text="@string/login"
            android:padding="0dip"
            android:layout_width="fill_parent"
            />
        <Button
            android:text="@string/cancel"
            android:padding="0dip"
            android:layout_width="fill_parent"
            />
    </TableRow>
</TableLayout>
res/values/strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="intro_note">Welcome to GalacticPickle, please login:</string>
    <string name="app_name">Galactic Pickle</string>
    <string name="uName">User Name:</string>
    <string name="pWord">Password: </string>
    <string name="login">Login</string>
    <string name="cancel">Cancel</string>
    ;<string name="persistentInfo">Remember account info.</string>
</resources>

This will be my only full code listing, from now on it will just be little snippets. Once this grows a bit I will have the code hosted on GitHub.

Login Layout

One major aspect of this application is network usage. To begin I want to make this a seamless process in the code writing, making things much easier for myself. Googling around I couldn't find much in relation to network programming and the funkiness of the Android UI, but I did find something in the documentation about expensive UI tasks and how to deal with them here.

I am starting the project creation as an Eclipse project as recommended. I also want to make sure the game will run on all Android API versions possible so I am setting the minSdkVersion to 2 and will bump as needed, if needed.


My plan for tonight is just getting the initial login window displayed and possibly have a server/client 'handshake.' Working through the layout for the initial login layout I was using a LinearLayout, but have found that the TableLayout has been much easier to work with. Below is my initial layout with a table for the login window. I am sure this will change, but it is a start. Text does not really line up well either right now (check box), not quite sure though I will have to look into the issue a bit later.




HINT: A simple little trick I found was while the application is running in the emulator, in eclipse, Run->Run just re-uploads your apk to the already running emulator. This happens to be a huge time saver. Also, learn the tool adb, it happens to be very nice as well, allowing full control of the device on a terminal level from your computer. Makes killing apps and such much easier.





Notes for next time:
    -Begin looking into socket framework design as I seemed to have not done that tonight. This will be where I start the Message Handler and Thread stuff.
    -Code Examples. I want to put some code examples up once my code becomes, well, cleaner. Right now it's basically chicken scratch.




Tonight's highlights:
    -TableLayout is easier to use than LinearLayout for layouts (unless I missed something....)
    -adb is an amazing tool and should be learned to fully appreciate Android software development.

Thursday, June 24, 2010

Introduction

Codename: Galactic Pickle is a game that a friend of mine and I are creating that will be a game similar to OGame for the Android platform. My guess and hope at this point is for the game to work on all versions of Android 1.5-current (at time of writing, 2.2). I have worked a bit on the game already, but the first go was a very bad start due to no experience with the platform previously. Still, I do not have a great grasp of the Android platform yet, but I plan to journal the experience here to help myself keep on top of the work and to hopefully help others get started on Android applications in the future.

Eventually the plan with the game is to have the code base all be in python. With ASE this will be possible, but not for a while. For the time being the server will be written in python using the Twisted networking library and the client will be written in Android's Java-like language. Planning and details for the game will be up on a wiki at game.aweenet.net though currently is being revamped as it was originally used for a different game idea. I am thoroughly excited for this project and hope this will also help others.

 WARNING: Each individual post may seem random, out of order, but the proceeding is basically my thought process as well as programming process and all is written as I work on the project. Each post will have highlights at the end though.