java mobile phones programming

hi, i am totally new on java games programming,i will like to get assistance on where to start from creating java games for mobile phones,i will like to get source codes for creating a simple game for mobile phone .pls a reply is highly required.thanks.

I’d think creating a game for either mobile phones or PC’s should be no different. So learning basic computer game programming is a prerequisite.

If you know how to make games, then check out J2ME, it’s a micro version of java…used in mobile phones and handheld devices.

Also check out space invaders 101:
http://www.cokeandcode.com/info/tut2d.html

a good start is always to visit the developer sites (mostly free registration required) of the big
handy manufactures (nokia, motorola etc.). they have masses of (game) tutorials and its always
a good idea to get a specialized developer kit for your handy and to learn very fast the pitfalls…

keep in mind that if you want your game to run on many phones, you’ll face huge limitations, like taht there is no automatic garbage collection (you have to call System.gc()) and the lack of floating point math unit on most phones, wich forces you to stick to integer math or to use floating point emulation, wich is rather slow for most games. But once you get used to midp/cldc limitations, the results are very rewarding, many games that would be unnoticed on desktops, shine on phones.

Who told you that? The garbage collector runs automatically on all phones I’ve seen. The reason for the System.gc() call is to prevent the collector from running at an inopportune moment. Programmers used to do this sort of thing back in the Java 1.1 days, but it ended up being the exact wrong thing to do once Java added more sophisticated garbage collectors.

[quote]and the lack of floating point math unit on most phones
[/quote]
Rule of thumb: Never use floating point computations for games on a CPU without a floating point unit. Since that covers a large number of cell phones, the lack of floating point math is a good thing. Even when you do have an FPU, you have to be careful not to slow your program down with too many FLOPs. If you read just about any book from the 386/486 gaming days, one of the first things you’ll notice is that they teach you to do fixed point math. :slight_smile:

Java for mobile phones (J2ME) is very different from java on desktops (J2SE).
OK let me give you a few pointers…

Stuff you will need:
You will need to have a java environment (JVM) on your PC and download the Wireless Toolkit.(java.sun.com).
You will want to use NetBeans for your wireless development, NetBeans 5.0 Beta2 and Mobility Pack5.0 Beta2 (www.netbeans.org).

With these tools you are now able to write games for a mobile platform, but most manufactures have extensions so you might want to download the SDKs from there sites.
http://www.forum.nokia.com/main.html
http://developer.sonyericsson.com/

The NetBeans Mobility pack has some simple examples and games that can help to get started, you might also want to grab some source code from many sites (just use a search engine and you will find a game that you like to dissect).

Also there are many books about the subject, like (http://www.amazon.com/gp/product/1592001181/103-3650030-3671862?v=glance&n=283155).
Also SUN has several articles that help to understand the platform, just go to: http://developers.sun.com/techtopics/mobility/allarticles/

There are also tools that help with the device fragmentation problem, like J2ME Polish.

Good luck and if you need further help just post away,
All the Best,
-Dan

Also be aware that performance of the emulator in the WTK sucks rocks.

Unless your game is turn based with little to no animation you will probably need a real phone to do development of graphics on.

[quote=“Jeff,post:7,topic:25768”]
Last time I was mucking around with MIDP, I used the MPowerPlayer tool. It used to be just for developers, but it looks like it’s been made into a product of sorts. Should still work for development.

Note that MPowerPlayer won’t do anything to help you make sure that a particular phone is compatible. (e.g. You picked the right resolution, there are no bugs undocumented features on the phone, etc.) So you still need to use the WTK (or a real phone!) to verify that the game will operate. Since you probably don’t want to test for every possible phone on the market, you can find yourself some free beta-testers here.

Emulator performance far surpasses any device currently on the market - unless ofcourse you have a realy crappy development pc ::slight_smile:

[quote=“Anon666,post:9,topic:25768”]
You’ve obvioudly never used the Nokia emulators. These things are about as slow as you can possibly get. Two minutes to run a single test was not uncommon the last time I tried. :frowning:

To add insult to injury, the Nokia kit adds a highly annoying auto-update feature that downloads all kinds of software you don’t want when you least want it.

[quote=“jbanes,post:10,topic:25768”]

I was refering to the Sun WTK.

Though I agree, the Nokia sdk is incredibly invasive, and contain all manor of annoying flaws.
I guess we shouldn’t complain though - there are manufacturers who are far far worse in their lack of Java developer support.
Sharp, NEC, Sagem & LG to name just a few.

Infact - the only handsets I ever enjoy developing for are SonyEricssons and Motorolas.

i am new to java games mobile programming.i have downloaded the softwares you recomended to me. now pls could you send me source codes for creating a simple game for mobile phone like nokia .so i could get started in my mobile game world

Then it has totally changed its architecture from last time I worked with it.

The WTK phone emualtor at that time was doing all its graphics in software and was rediculously and unbearbly slow for any serious graphcis wo0rk.

if i never call the garbage collector, even if i only create one or two new objects each cicle, the midlet crashes on my nokia 6600 (on wtk emulator the memory graph grows to the heap limit and then pauses everything while the gc is collecting all the junk) Memory management is a problem to have in mind when designing a midp game

can you explain me why you’d want that many objects? flyweights man.

Many (perhaps even all) firmware versions of the Nokia6600 leak memory when drawing flipped/rotated images through the midp2 api.

That is one potencial cause of your problems, though the 6600 does have a host of other problems. (InputStream & Image classes (and their subclasses) both have significant bugs in their implementation.
TBH the 6600 is a pile of crap as a reference device, you’d do much better testing on a SonyEricssonK700i. (similar in capabilities, but far less device specific bugs)

@Topic:
Depends on how ‘deep’ you want to go.
If you simply want to write an app for one or two similar devices it would suffice to get the SDK for that/those devices and start.

Anything else leads down a long road full of pain in the ass ‘features’.
Every platform has its features. ATM my comp supports 60 unique devices.

@f.I.x:
Always garbagecollect where and when you can.
Like Anon said, the 6600 is a PITA!
Their are also a memory leak in forms.
We even had a MONTY_THREAD exception on one game we could not solve.

please i will like to know the softwares step by step required for mobile phone games development

  1. i will like to get source codes on a simple mobile phone game ,so i can start up from there

  2. how can i use the software downloaded? where will i start from imputing codes

Learning to use google is the best thing you can do yourself. Or the search feature on this site. :wink:

Ok once you have the software downloaded and installed - install jvm, install NB first, then mobility pack, then SDKs/emulators. NB will find the emulators on its own, if it does not then there is an option to find them.

After you have all installed you can start to see some code that comes with mobility pack, start NB go to new project (a wizard window pops up) and select samples->mobile->midp1 or midp2 ->various games there you will find the source to the most popular computer game ever (WORMS) and other puzzle games.

You can also start programming simply select new project-> mobile->mobile application. And start coding it’s that simple.

You can also look at a more complex game Marv the Miner from digiment.no example here: http://www.digiment.no/index.jsp?category=downloads&sub=2

hope this helps, if you have more specific question go ahead and ask them, this is the place to place them don’t be embarrassed, I and the rest of the forum, will do our best to help.