Mobile Phones, Space Aliens and Dinosaurs

Many will agree that it's more motivating to learn a new programming language by either implementing something immediately useful (like Ramon Ramos' modules) — or something immediately funny. So during JavaOne I bought this nice book J2ME Games with MIDP2 by Carol Hamer. (J2ME is now renamed to Java ME by the way.) Have a look at the amazon.com reviews, and I think you will totally agree with the comments stating that Java ME games are one of the last areas where you still can write a complete game on your own without a team of designers and storyboard specialists.

Some words about the book: It assumes you already know Java and just shows the differences and mentions best practices. The content itself is solid and useful, even if it's often annoying to read dozens of pages of source code with only a few jotted-down comments between the lines.
Speaking of which, you can download the source code and the sample projects can be imported into NetBeans IDE with the Mobility Pack installed. When you create a new project, select Mobile > Import Wireless Toolkit Project, and there you are. The first game (Maze) works right away, the tumbleweed game however has a fixed screensize and does not run on the emulator because the emulator's screen is too big... Go figure. I can't just comment out the screen size test to make it run, and I have not yet found out if I can change the emulators screensize (anybody know?), and I don't want to rewrite the whole thing to make one little sample file fit. I'd rather spend the time on writing my own game.

So on Sunday I just took the maze game as a skeleton and started playing with the javax.microedition.lcdui libraries. One of the big differences between Java SE and ME is: On Mobiles, you don't use swing libraries. The alternative, LCDUI, is very limited, but well, it's not called microedition for nothing. When you use New > Visual MIDlet to create a MIDlet, you'll get to see the Mobility Pack's famous visual designer. If you drop a PNG image file into the the same directory with the MIDlet, you can select and display it, e.g. on a splashscreen. There's still a lot to find out for me.

My game-to-be can already draw some pretty fancy lines and colored rectangles to their correct positions on the screen, and I already have a class that contains the randomized game map in an int[][] array. (I needed to use some crazy g.drawString(Integer.toString(myMaze.getTileFromMaze(i,j)),20+i\*17,30+j\*17,g.TOP|g.LEFT); line just to print the array to the screen and test whether it was correctly generated. Is there no easier way to do System.out.println()? Need to investigate.) Map generation probably still needs some optimizing (it runs in zero time on the emulator. On a 1.6 Ghz CPU... But how many Ghz does my mobile phone have? You see what I mean.) I also found out that there is no filled polygon routine in javax.microedition.lcdui.Graphics, but you can replace that by drawing lines, and filling the space in between with several fillTriangle()s.
Now nothing can stop me, Muahahahaha! 8-) The greatest mobile card game ever! Including first-person 3D racing! And space aliens! And dinosaurs!! All at the same time! Or maybe not. ;-) Let's see what I come up with. :-P

Comments:

The best is to develop exactly on the right SDK/emulator, You can download the emulators from vendors - http://www.netbeans.org/kb/50/midpemulators.html

more information how to customize the screen size

Posted by Lukas on June 18, 2006 at 04:47 PM CEST #

Post a Comment:
Comments are closed for this entry.
About

NetBeans IDE, Java SE and ME, 3D Games, Linux, Mac, Cocoa, Prague, Linguistics.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
News

No bookmarks in folder

Blogroll