Results 1 to 3 of 3
- 12-13-2010, 02:44 PM #1
Member
- Join Date
- May 2010
- Posts
- 14
- Rep Power
- 0
Generic question on implementing bluetooth/net code
Hi folks - as a learning exercise, I'm trying to write a very simple J2ME game project (pong) playable via bluetooth, however hopefully my problem is high level enough that it can be answered by non-J2ME'ers too. :)
What I have up to now is 2 'sub' projects, the pong game and also a skeleton bluetooth client/server. Both of which are fairly straightforward and are working, in their own separate right.
Now however I want to 'plug' the bluetooth Client code (I'll keep Server as a separate class for now) into the game code, but I'm a bit stumped how & more specifically where to do it.
Up to now, for instance, my game Midlet looks like this...
And then in pongCanvas is the game thread :Java Code:public class Pong extends MIDlet { public Pong() { pongCanvas = new PongCanvas(); } public void startApp() { Display display =Display.getDisplay(this); pongCanvas.start(); display.setCurrent(pongCanvas); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } private static PongCanvas pongCanvas; }
My assumption is I need to add an output.write() (or similar) call in the game loop, to write out whatever info I want sending as part of the game.Java Code:public void run() { while(true) { updateScreen(getGraphics()); try { Thread.sleep(sleepTime); } catch (Exception e) { } } } public void start() { initSprites(); Thread runner = new Thread(this); runner.start(); }
What I don't know, or am failing miserably to grasp, is how to get the Client up and running alongside the game, and how to then access the client methods from within my game class.
Do I need to start the Client in the Midlet class code, or should I just add the Client methods to my game class, and make one big game/client hybrid class?
I'm confused on the structure really, how & where do you generally plug network code into your game. I'm struggling to 'visualise' how the final Midlet/Game/Client classes should look, if that makes any sense.
thanks in advance for any tips. :)Last edited by SM2010; 12-13-2010 at 02:47 PM.
- 12-13-2010, 05:50 PM #2
Member
- Join Date
- May 2010
- Posts
- 14
- Rep Power
- 0
anyone help? before this sinks down to page 2... :)
- 12-14-2010, 04:10 PM #3
Member
- Join Date
- May 2010
- Posts
- 14
- Rep Power
- 0
Similar Threads
-
Java Generic Container Question - please help!!!
By zhoujackji in forum New To JavaReplies: 3Last Post: 11-13-2010, 11:12 AM -
generic code
By mac in forum New To JavaReplies: 4Last Post: 05-27-2010, 05:06 PM -
java code for bluetooth.
By rainfan in forum Java AppletsReplies: 4Last Post: 01-13-2010, 05:11 AM -
Transfering files over Bluetooth (with javax.bluetooth)
By weber10 in forum CLDC and MIDPReplies: 0Last Post: 02-26-2009, 08:14 PM -
Trouble implementing part of code into GUI
By Flaresplitz in forum New To JavaReplies: 1Last Post: 12-21-2008, 07:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks