Monday, October 26, 2009

Game Maker.... pretty cool


Last Weekend, I spent Saturday Morning volunteering my time with students from my son's charter school, Mountainville Academy. I hosted a workshop on the fun and accessible multimedia project/game factory called Scratch.

We went for 3 hours in smaller instructional periods, followed by hands on time. In my opinion, it was all very successful. We covered nearly half of the scratch blocks in the time allotted, and I could begin to see some nice projects coming along.

During that time, one of the students mentioned another game making software package called 'Game Maker', hosted at YoYo Games. I downloaded it and began playing with it a little bit. It had some truly brilliant features that were definitely missing from Scratch. However, it does appear less accessible than Scratch. I.e. I think Scratch hits my 5th graders really well, producing good projects in just a few hours. GameMaker is meant for High Schoolers and beyond, it would seem.

One thing I liked though, were some of the tutorials, including this one: What is a good game. I recommend that if you are in my class, you read it. It will help guide you in your game creation so that after you spend all that time building the game, people will want to spend time playing it.

For those in my class, I want to see all of your scratch projects. I have created a scratch gallery called Mountainville Academy projects located here. Take a moment to take a look at some of the projects there, and to put your own in there as well. I'll see you all on Halloween!

Tuesday, July 7, 2009

Using GraphViz to automatically Diagram your Grails Domain Model



I'm working on a feature that automatically diagrams the Domain model stored in Grails, similar to the method prototyped by the Curious Bunny here. His example works pretty well for a simple model, but begins to break down due to a seeming Grails limitation.

In my model, I have a Party, Organization and Company class. Company extends Organization, Organization extends Party.
Party <--- Organization < --- Company Inside of my Controller that produces the Graph, I iterate through a classes subclasses like so:

domainClass.subClasses.each {subClass ->
out.println """"$domainClass.name" -> "$subClass.name" """
}

This works ok, but when this is run on Company, both Party and Organization are in the set. In a UML diagram, I don't really want both of them, I only want one of them. I.e. it produces a diagram that is more cluttered than it needs to be.

This diagram represents a simplified subset of my domain, based off the Party Pattern Archetype in the book: Enterprise Patterns and MDA: Building Better Software with Archetype Patterns and UML

Notice the redundant inheritance.

Anybody know how to only get direct subclasses, instead of recursive subclasses?

Tuesday, April 21, 2009

Blog host

So, I'm trying to figure out how to host my own blog. Steve Pavlina suggests that I host it with its own domain name, using this domain provider Pair, and ServInt VPS using wordpress. It sounds like a brilliant idea, but I'm not too familiar with PHP.

Since I'm already very familiar with Java and JSP etc, I was wondering if there exists some sort of WordPress for java. Apparently there is, or I can get a free account at WordPress itself, but then they get all of the ad revenue.

My sister-in-law has her own blog called theliteratemother.org that is hosted on wordpress as well. It seems to be pretty cool, and maybe more like what I'm looking for.

Otherwise, I'm looking at spending at least $50/month to host it where Steve Pavlina suggests. I.e. ServInt.

Seems like I should at least as Bridget where she hosts hers, I suppose.

Hibernate Caching

I've been working on getting Hibernate caching to work at work to implement a new feature from Product Management. The original requirements suggested rolling our own caching mechanism, but since our application already has hibernate, it doesn't seem to make sense to roll our own.

Early investigation lead me here:

A wonderful article about hibernate caching. Since our application uses xdoclet for defining hibernate mapping, it wasn't quite complete.

But I really like the analysis because it displays rather clearly how much faster it runs with the caching thrown in.

I'm tempted as well to perform a similar analysis. The article talks about caching the object, and the relationships to the object, which are essential for my problem as well because I have a hierarchy in my objects of Parent -> child. My object is called the Domain Object.

the hbm_xml would be this:



The xdoclet then would be (found here):
/**
* @author petersmiley
*
* @hibernate.class table="Domains" dynamic-insert="true" dynamic-update="true" optimistic-lock="version"
* @hibernate.cache usage="read-only"
* @struts.form "DomainForm"
*
* @auditable.property entity-name="audit.entity.domain"
*/
public class Domain extends BaseObject implements Auditable, Comparable {
.... and the link back to the parent:
/**
* @struts.form-field form-name="parentDomain"
* @hibernate.cache usage="read-write"
* @hibernate.many-to-one
* column="PARENT_ID"
* class="com.norkom.base.resources.model.Domain"
* not-null="false"
* unique="false"
* --cascade="none"
* --outer-join="false""
*
* @auditable.property identified-by="parent.domain"
*/
public Domain getParentDomain() {
return parentDomain;
}
public void setParentDomain(Domain parentDomain) {
this.parentDomain = parentDomain;
}

Note: if you use "read-only" then don't expect to be able to put any objects into the database. When it says read-only, it means it! (I tried it. I had to change to read-write)

Here is my unit test:
public void testCachedCrud() {
List list = domainDao.getAllDomains();
assertEquals(0, list.size());
TestTimer createDomainsTimer = new TestTimer("test Create Domains");
int size = 10;
for (int i=0;i
Domain parentDomain = createBasicDomain(PARENT_DOMAIN_NAME + i);
for(int j=0;j
Domain childDomain = createBasicDomain(CHILD_DOMAIN_DOMAIN + i + ":" + j);
childDomain.setParentDomain(parentDomain);
domainDao.saveDomain(childDomain);
}
domainDao.saveDomain(parentDomain);
}
createDomainsTimer.done();

for (int i=0;i
TestTimer timer = new TestTimer("test Get Domains" + i);
Domain parentDomain = domainDao.getDomainByName(PARENT_DOMAIN_NAME + i);
timer.done();
}
}

Results, with cacheing:
INFO [DomainDaoImplTest] -> Loading config for: /com/norkom/base/business/dao/impl/test-context.xml
EMMA: collecting runtime coverage data ...
WARN [Configurator] -> No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/work/trunk/SUBVERSION/Libs/hibernate/2.1.8/ehcache-0.9.jar!/ehcache-failsafe.xml
WARN [EhCacheProvider] -> Could not find configuration [com.norkom.base.resources.model.Domain]; using defaults.
DEBUG [TestTimer] -> test Create Domains: 140 ms
DEBUG [TestTimer] -> test Get Domains0: 0 ms
DEBUG [TestTimer] -> test Get Domains1: 0 ms
DEBUG [TestTimer] -> test Get Domains2: 0 ms
DEBUG [TestTimer] -> test Get Domains3: 0 ms
DEBUG [TestTimer] -> test Get Domains4: 0 ms
DEBUG [TestTimer] -> test Get Domains5: 0 ms
DEBUG [TestTimer] -> test Get Domains6: 0 ms
DEBUG [TestTimer] -> test Get Domains7: 0 ms
DEBUG [TestTimer] -> test Get Domains8: 0 ms

Now, lets try without caching...
DEBUG [TestTimer] -> test Get Domains9: 0 ms



Tuesday, March 24, 2009

Real Guitar Hero!

I've been wondering if there is a way to do Soft Mozart for Guitar, perhaps by reflectors on the guitar and shining an infrared light at it, using some tracking points on the guitar itself, and the WiiMote camera to track which strings are plucked, etc.

Keyboard Breakout


So, I just bought a keyboard along with some cool educational software called Soft Mozart to help teach my kids how to play music on the piano.

Since I'm such a geek, I also created a little game that uses the keyboard to play breakout.

Here is a screenshot.

You've got to have a midi keyboard plugged in to try it out. It uses JFugue for the Midi, and my old standbye, PulpCore for the game engine.

You can play it here: http://www.fishnetgames.net/games/breakout/index.html

Wednesday, December 10, 2008

How to make shiny letters with the GIMP


I made shiny letters using the GIMP for my fishnet games website. I saw a tutorial on Youtube. But it didn't have any audio (or it was in German).

Here is how I ended up doing it:
1. Create a new image and put some text with the font you like:

2. Turn the text into a selection. Right click on the text layer, scroll down, click alpha to selection, then delete the text layer itself. Select the Text layer, click on the little garbage can.


3. Select the 'blend tool', and select the color gradient you want to use. Choose your colors. I'm doing red to white. Using the blend tool, draw the line across the selection:
This produces a good start.

4. Produce the outline.
To produce the outline, expand the selection by a few pixels using the 'selection grow' tool. Find it under the menu Select/grow.

I'm using 2 pixels for this example. Create a new layer to color in the outline. Fill in the selection with your desired color using the 'bucket fill tool'. Rearrange the layers so that the fill layer is on the bottom of the text.


It should now look like this:



5. Make the Candy gloss. I think the gloss is produced by kind of simulating a reflection of an irridescent ambient object, like a lamp shade or something, on the text. To do this, select the layer of text that is on the top, then select 'alpha to selection', as we did before.
Now select the elliptical selection tool, and choose the 'subtract from current selection' option.

Make a selection that spreads across the letters like the sunrise:

Now, we are just going to draw another gradient into this selection. Create a new layer for this to occur in, select the gradient tool, go from white to somewhat pink, and try a few gradients until it looks right.Play with the layer opacity a little bit to get just the look you want.


6. A reflection

I added a reflection using the reflection script from here:

http://code.google.com/p/gimp-reflection/

Now I de-select everything, auto-crop the image, and selected Filters/decor/reflection, and choose the parameters you like:


Now you can put that on your webpage, and it looks beautiful.