Skip to content

Year: 2008

My Free Tileset, version 6

More free tiles for game developers. Now in a fantasy, medieval style.

tileset palace snes rpg style

Some detailed view. The royal throne (king was not in the room), carpet and banners.

tileset palace detail view 1

I had to place guards across the room. You know, being a king is dangerous.

tileset palace detail view 2

There’s this new kind of wall, with bricks. There’s a passage for the king bedroom.

tileset palace detail view 3

Here’s the new version of the tile set.

free tileset version 6

2nd Prize at Sun Student Reviews Contest

Project Xort won a second place prize at the MySQL and GlassFish Student Reviews Contest. A lot of guys here from Brazil were prized, congractulations guys! Very cool projects, worth to take a look.

Prize

I won a certificate (seems to be really autographed by Jonathan Schwartz *_* I want to believe) that I will frame and put in my room and a $250 dollars check that I’ll save for a trip next year. \o/

Prize

There’s always cool contests running. Let’s keep our eyes open. 😉

Parsing a XML Sandwich with JavaFX

delicious sandwich

Let sandwich.xml be a file at /tmp directory with the content above.




   
   
   
   
   

We can open it using java.io.FileInputStream and so use it on a javafx.data.pull.PullParser. A PullParser is a event oriented parser that works with XML and YAML files. Above a general and simple parser with a GUI that show the list of events during the parse process.

import java.io.FileInputStream;
import javafx.data.pull.Event;
import javafx.data.pull.PullParser;
import javafx.ext.swing.SwingList;
import javafx.ext.swing.SwingListItem;
import javafx.scene.Scene;
import javafx.stage.Stage;

var list = SwingList { width: 600 height: 300 }

var myparser = PullParser {
   documentType: PullParser.XML;
   onEvent: function (e: Event) {
      var item = SwingListItem {
         text: "event {e}"
      };
      insert item into list.items;
   }
   input: new FileInputStream("/tmp/sandwich.xml");
}
myparser.parse();

Stage {
   title: "XML Sandwich"
   scene: Scene { content: list }
}

javafx xml sandwich

The XML cheese element produce two the outputs.

type:1 typeName:START_ELEMENT level:1 qname:cheese text:” namespaces:{} attributes:{type=chedar}
type:2 typeName:END_ELEMENT level:1 qname:cheese text:” namespaces:{} attributes:{type=chedar}

Notice that white spaces like tab and escape characters like new line also produced events from type TEXT. We are not interested on them. Above a parser that looks only those events of type START_ELEMENT or END_ELEMENT, look into it’s contents, building a sandwich at runtime based on the XML file.

import java.io.FileInputStream;
import javafx.data.pull.Event;
import javafx.data.pull.PullParser;
import javafx.data.xml.QName;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.scene.Scene;
import javafx.stage.Stage;

// my sandwich starts as an empty VBox
var mysandwich = VBox {}

// give a name and returns a ImageView with a png image like the name
function ingredient(name){
   return ImageView {
      image: Image {
         url: "{__DIR__}{name}.png"
      }
   }
}

// basicaly, look the event and put a ingredient at mysandwich
var myparser = PullParser {
   documentType: PullParser.XML;
   onEvent: function (e: Event) {
      // starter xml elements
      if(e.type == PullParser.START_ELEMENT){
         // bread
         if(e.qname.name.equals("bread")){
             insert ingredient("bread_top") into mysandwich.content;
         }

         // hamburguer
         if(e.qname.name.equals("hamburguer")){
             insert ingredient("hamburguer") into mysandwich.content;
         }

         // catchup
         if(e.qname.name.equals("catchup")){
             insert ingredient("catchup") into mysandwich.content;
         }

         // maionese
         if(e.qname.name.equals("maionese")){
             insert ingredient("maionese") into mysandwich.content;
         }

         // lettuce
         if(e.qname.name.equals("lettuce")){
             insert ingredient("lettuce") into mysandwich.content;
         }

         // cheese
         if(e.qname.name.equals("cheese")){
            var type= e.getAttributeValue(QName{name:"type"});
            if(type.equals("cheedar")){
                 insert ingredient("cheedar") into mysandwich.content;
            } else {
                insert ingredient("cheese") into mysandwich.content;
            }
         }
      }

      // ending xml elements (just bread)
      if(e.type == PullParser.END_ELEMENT){
         if(e.qname.name.equals("bread")){
            insert ingredient("bread_botton") into mysandwich.content;
         }
      }
   }
   input: new FileInputStream("/tmp/sandwich.xml");
}
myparser.parse();

Stage {
   title: "XML Sandwich"
   scene: Scene {
      height: 300
      content: mysandwich
   }
}

Here’s our sandwich.

sandwich javaFX

Just changing the XML file you got a new sandwich.




   
   
   
   
   
   
   

double burguer

Bon appétit.

For more details on XML and JSON parsing see the JavaFX API.

Pizza Party!

duke pizza

A pizza party que o CEJUG ganhou por ter atingido mais de 100 usuários no OSUM em apenas dois dias é essa sexta-feira, às 18hrs no restaurante Florence L’Escale. As pizzas ficam por nossa conta e as bebidas por conta dos participantes.

Se você vai:

  • Crie uma conta no osum.sun.com e entre na comunidade do CEJUG, se você não tiver feito isso ainda.
  • Vá no site do evento dentro do OSUM e marque que você vai participar. Isso não é obrigatório mas é pra ajudar na organização do evento.

Lembre-se, é nessa sexta-feira, dia 26 de Dezembro, às 18 horas. Preencha o espaço na sua agenda entre as festas de natal e a farra de ano novo. ;D Maiores detalhes no site do evento dentro do OSUM.

JavaFX Santa’s Hat

Happy holidays in a JavaFX Style.

Try online

It’s a application to put a Santa’s hat on a picture from web. To test it obviously I used my picture with John Hall “Maddog”, the closest person I know to Santa Claus. ;D

I tried the approach from Chris Campbell’s Effect Playground application but I needed get both photo image and hat at the same time. In this application I used the Jean-Francois Screenshot Maker approach, taking a screenshot of the desired area. Maybe not the best solution, but it works very well. I also used his Screencapture.java and Util.java codes.

package santahat;

import javafx.ext.swing.SwingTextField;
import javafx.scene.CustomNode;
import javafx.scene.input.MouseEvent;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.scene.layout.HBox;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.ext.swing.SwingButton;

var imgview = ImageView {
   image: Image {
      url: "{__DIR__}help.png"
   }
}

var txtfield:SwingTextField = SwingTextField {
   columns: 45
   text: "your image url"
   editable: true
   action: function(){
      println(txtfield.text);
      imgview.image = Image {
         url: txtfield.text;
      }
   }
};

var santahat:ImageView = ImageView {
   x: 240 y: -5
   var startX = 0.0
   var startY = 0.0
   var   zoom = 1.0
   var  angle = 0.0

   scaleX: bind zoom
   scaleY: bind zoom
   rotate: bind angle

   onMousePressed: function( e: MouseEvent ):Void {
      startX = e.sceneX - santahat.translateX;
      startY = e.sceneY - santahat.translateY;
   }

   onMouseDragged: function( e: MouseEvent ):Void {
      santahat.translateX = e.sceneX - startX;
      santahat.translateY = e.sceneY - startY;
   }

   onMouseWheelMoved: function( e: MouseEvent ):Void {
      if(e.controlDown) {
         angle += 
         e.wheelRotation * 10;
      } else {
         zoom += 
         e.wheelRotation / 20;
      }
   }

   image: Image {
      url: "{__DIR__}santahat.png"
   }
}

// Based on the Jean's ScreenshotMaker
// http://javafx.com/samples/ScreenshotMaker/index.html
var stage:Stage = Stage {
   title: "Santa Hat"
   width: 510 height: 480
   scene: Scene {
      content: [
         VBox {
            content: [ txtfield, imgview,
               SwingButton {
                  text: "Save"
                  action: function() {
                     // Ugly. See the entire source at through the link in the blog post
                  }
               }]
         }, santahat]
   }
}

Downloads: