Tuesday, December 11, 2007

Friday, October 26, 2007

Midterm


Screen shot of our fighting game so far


code below

import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;

public class ExampleGameCanvas extends GameCanvas implements Runnable {
private boolean isPlay; // Game Loop runs when isPlay is true
private long delay; // To give thread consistency
private int currentX, currentY; // To hold current position of the 'X'
private int width; // To hold screen width
private int height; // To hold screen height
private int scnX, scnY; //To hold screen starting viewpoint

// Sprites to be used
Image backgroundImage;
private Sprite playerSprite;
private Sprite backgroundSprite;

// Layer Manager
private LayerManager layerManager;

// Constructor and initialization
public ExampleGameCanvas() throws Exception {
super(true);
width = getWidth();
height = getHeight();

scnX = 200;
scnY = 10;
currentX = width / 2;
currentY = height / 2;
delay = 1;

// Load Images to Sprites

Image playerImage = Image.createImage("/transparent.png");
playerSprite = new Sprite (playerImage,64,64);


backgroundImage = Image.createImage("/background1.png");
backgroundSprite = new Sprite(backgroundImage);

layerManager = new LayerManager();
layerManager.append(playerSprite);
layerManager.append(backgroundSprite);

}

// Automatically start thread for game loop
public void start() {
isPlay = true;
Thread t = new Thread(this);
t.start();
}

public void stop() { isPlay = false; }

// Main Game Loop
public void run() {
Graphics g = getGraphics();
while (isPlay == true) {

input();
drawScreen(g);
try { Thread.sleep(delay); }
catch (InterruptedException ie) {}
}
}

// Method to Handle User Inputs
private void input() {
int keyStates = getKeyStates();

playerSprite.setFrame(0);

// Left
if ((keyStates & LEFT_PRESSED) != 0) {
//currentX = Math.max(0, currentX - 1);
playerSprite.setFrame(1);
if (scnX - 1 > 0){
scnX--;
}
}

// Right
if ((keyStates & RIGHT_PRESSED) !=0 ){
//if ( currentX + 5 < width) {
//currentX = Math.min(width, currentX + 1);
playerSprite.setFrame(3);
//}
if (scnX + 1 + 300 < backgroundImage.getWidth()){
scnX++;
}
}
// Up
if ((keyStates & UP_PRESSED) != 0) {
//currentY = Math.max(0, currentY - 1);
playerSprite.setFrame(2);
}

// Down
if ((keyStates & DOWN_PRESSED) !=0)
//if ( currentY + 10 < height) {
//currentY = Math.min(height, currentY + 1);
playerSprite.setFrame(4);
//}
}

// Method to Display Graphics
private void drawScreen(Graphics g) {

//g.setColor(0x00C000);
g.setColor(0xffffff);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0x0000ff);

// updating player sprite position
playerSprite.setPosition(currentX,currentY);

// display all layers
//layerManager.paint(g,0,0);
layerManager.setViewWindow(scnX,scnY,300,350);
//layerManager.setViewWindow(playerSprite.getX() - width/2, playerSprite.getY()/2 - height/2, 300, 350);
//backgroundSprite.setPosition(playerSprite.getX()/2 - width/2, playerSprite.getY()/2 - height/2);
layerManager.paint(g,0,0);

flushGraphics();
}

}




2.
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class ExampleLayerManagerMidlet extends MIDlet {
private Display display;

public void startApp() {
try {
display = Display.getDisplay(this);
ExampleGameCanvas gameCanvas = new ExampleGameCanvas();
gameCanvas.start();
display.setCurrent(gameCanvas);
} catch (Exception ex) {
System.out.println(ex);
}
}

public Display getDisplay() {
return display;
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
exit();
}

public void exit() {
System.gc();
destroyApp(false);
notifyDestroyed();
}
}

Tuesday, October 9, 2007

Monday, October 1, 2007

Midterm idea

Not knowing that the larger project idea was for the midterm I proposed something that might take a little more time. So for the midterm I propose something with a smaller build time. I propose a project that will capture images and then you should be able to use that image to then paint on a canvas. Something simple that can then be combined with a larger project such as the fashion project my group developed the 2nd week in class. What do you think?

Tuesday, September 25, 2007

Week 3 hw

New Project
I think a larger project that would be fun is a dating/compatibility mobile application. People are always looking for new and exciting ways to find dates. Its like internet dating meets mobile...after all wouldn't it save all the hassle of asking the same beginning questions over and over again to different people in the same room. Lets just cut to the chase and talk to the one we're compatible with.

I envision an application where a person enters their profile including information about themselves and their ideal mate. The application then uses bluetooth technology to scan the room for potential matches to their ideal mate....returning a percentage rating of the people you are most compatible with and their phone name. You can then send them via bluetooth your picture or additional information or an sms to meet up in that location if you're sooo bold, and if you both included that option; or for our shy folks they can send an anonymous message until they feel comfortable revealing their identity.

APIs:
Bluetooth

Mobile Media
Wireless Messaging

J2ME Web Services


Part 2
This is my simple idea from last week showing the sms smiley home page interface and alert after a selection is made:import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class TravelList
extends MIDlet
implements CommandListener{
private List mList;
private Command mExitCommand, mNextCommand;

public TravelList(){
String[] stringElements = {"Send New SMS", "Use Template", "Create New Smiley"};
Image[] imageElements = {loadImage("/new.PNG"), loadImage("/template.PNG"), loadImage("/smiley.PNG")};
mList = new List("SMS Smiley", List.IMPLICIT, stringElements, imageElements);
mNextCommand = new Command("Next", Command.SCREEN, 0);
mExitCommand = new Command("Exit", Command.EXIT, 0);
mList.addCommand(mNextCommand);
mList.addCommand(mExitCommand);
mList.setCommandListener(this);
}

public void startApp(){
Display.getDisplay(this).setCurrent(mList);
}

public void commandAction(Command c, Displayable s) {
if (c == mNextCommand || c == List.SELECT_COMMAND) {
int index = mList.getSelectedIndex();
Alert alert = new Alert("Your selection", "You chose " + mList.getString(index) + ".", null, AlertType.INFO);
Display.getDisplay(this).setCurrent(alert, mList);
}
else if (c == mExitCommand)
notifyDestroyed();
}

public void pauseApp() {}

public void destroyApp(boolean unconditional) {}

private Image loadImage(String name) {
Image image = null;
try {
image = Image.createImage(name);
}
catch (IOException ioe) {

System.out.println(ioe + "can't find image");
}

return image;
}
}

JAD file

Part 3

I used flashlite to extend my simple program above. Far from being done but its on its way.
See app here

Tuesday, September 18, 2007

Week 2

Simple MIDlet idea

This is an idea to use gtalks animated smiley's for sms messages. Basically you and your friends will download this application and it works with your phones sms application interface already installed. When running, if you receive a text message the simple text smiley rotates to an upright position. The user is able to create their own smilies, and use already created templates. Check out the quick sketches below.

Zombie App



Fav Mobile App

My favorite mobile application is PocketNester. PocketNester is a NES emulator. You can download ROMs which are games that can be played with your emulator. The frames per second are pretty smooth emulating full speed play. The sound quality is amazing, just like the real games from the late 80s early 90s. Works in both landscape and portrait mode.

I find that with my touchscreen game play can be a bit challenging without the actual feel of hitting a button, but thanks to the designers game controls can be changed to different keys on your phone. I use a combination of touchscreen and button pushing, using the directional hard keys for the directions and the onscreen A & B buttons for the jump and fire keys. It takes some getting used to but when you have the perfect combination game play is as I remember it. Sometimes there is a slight delay which takes time to learn but all and all this is a well executed program.

I wish I didn't have to exit the game playing mode to edit settings such as sound or controls. Since the ROMs can be created by anyone their is one more issue of similarity between the old game and the emulated ROM. Some ROMs I have downloaded have yet to be the same game I remember growing up. This change can be good and bad, where you can play a totally new adventure within a game you probably already conquered more than once. I already beat Contra on my phone while on a subway ride home from school! (even the cheats are still in some of them ^^dd<><>baba start ;)


Tuesday, September 11, 2007

Homework 1


Simple hello world app in Eclipse