Archive

Posts Tagged ‘java’

Games and What’s Going On

October 7th, 2011 1 comment

Heyall. So it has been almost three months since I last posted here? Ouch… Here’s what’s new.

Though I started the game just about a year ago, “Space Fight” development is on a bit of a break. It’s an ambitious project and for a guy like me who has never made a big ambitious project, it’s a lot of work. And since a lot of work takes a lot of time, my wife suggested maybe I should get something smaller out quicker (insert that’s what she said joke here). So in the meantime I’m learning how to develop for the Android platform with the book Beginning Android Games. My wife and I brainstormed what we think may be a fun little game for touch screens so I’ll be making a small game for Android before moving on to the bigger more ambitious projects.

Kev Glass has started to flip my world upside down now with his HTML5 version of Legends of Yore! He has written the game in Java and compiled it into Javascript using GWT and the canvas widget. How cool is that? It’s significant for me as I was going to look into HTML5 game development but it appears that now you can just code your game using Java2D and have it compiled into Javascript and runnable on all manner of platforms (iPhone, Android, WebOS, PC, etc) right away.

I suppose the best course of action may be to finish Space Fight in it’s current framework and worry about porting it over to Java2D later. But first I learn Android development!

Categories: Game Dev Tags: , , , ,

SpaceFight! Now with a Timer

December 18th, 2010 No comments

I’ve added a timer to SpaceFight! and the pawns now stop once they’ve reached their destination. In the previous build the pawns would only use the destination to figure out which direction they were headed.

Categories: Game Dev Tags: , , ,

SpaceFight! has its own page

November 1st, 2010 No comments

You can find the page and applet here or you can launch the webstart if you prefer those over applets (I know I do).

Categories: Game Dev Tags: , , , ,

Space Fight (Working Title)

August 18th, 2010 No comments

So I started something yesterday.

It’s quite early, but I find motivation in sharing my progress. The goal? A retro-style space war inspired by Blendo Games’ Flotilla.

Java String Validation and Scrubbing

December 24th, 2009 2 comments

I find myself more and more needing to validate user input, checking for illegal characters and empty Strings.

import java.util.LinkedList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
public class ScrubTest {
 
	public String scrubText(String dirty) {
		dirty = scrub("\\s+", dirty, " ");
		return scrub("^\\s?|\\s?$", dirty, "");
	}
 
	public String scrub(String pattern, String text, String replace) {
		Pattern p = Pattern.compile(pattern);
		Matcher matcher = p.matcher(text);
		return matcher.replaceAll(replace);
	}
 
	public static void main(String[] args) {
 
		ScrubTest st = new ScrubTest();
		LinkedList<String> list = new LinkedList<String>();
 
		list.add(new String("test"));
		list.add(null);
		list.add(new String(""));
		list.add(new String(" "));
		list.add(new String("\n"));
 
		for (String s : list) {
			System.out.println ("\nTesting string: \"" + s + "\"\n---------------");
			try {
				s = st.scrubText(s);
				System.out.println ("null:  " + (s == null));
				System.out.println ("empty: " + s.isEmpty());
				System.out.println ("\\n:    " + s.equalsIgnoreCase("\n"));
			}
			catch (Exception e) {
				System.out.println ("ERROR:" + e);
			}
		}
 
		String scrubbed = "\n\n\n   This   is       just a  test            \n    ";
		scrubbed = st.scrubText(scrubbed);
 
		System.out.println (scrubbed + ".");
	}
}

Produces:

Testing string: "test"
---------------
null:  false
empty: false
\n:    false

Testing string: "null"
---------------
ERROR:java.lang.NullPointerException

Testing string: ""
---------------
null:  false
empty: true
\n:    false

Testing string: " "
---------------
null:  false
empty: true
\n:    false

Testing string: "
"
---------------
null:  false
empty: true
\n:    false
This is just a test.

Switch to our mobile site