Introduction to Blackberry Game Development - Part 1
- Posted by asifmujteba on 05.20.2011
- 3 feedbacks »
When it comes to mobile development, the most important thing for every developer is to learn game programming, how to create a game? Mobile games provide great revenue streams and make the biggest of all industries, In this tutorial series you won't learn how to make revenue from game development but you would definitely start developing games which would ultimately earn revenue for you.
Blackberry still has a large user base in a lot of countries, but lacks proper game API, thus, leaving the developers struggling. I would try my best to deliver maximum possible concepts and terms used in game development.
After this series you would have a fully functional and playable game named "Falling Fruits", though it will be simple enough just to teach you the basic concept. The basic game requirements are:
1- The First Screen is menu Screen which would only contain one Start Game button.
2- After clicking the start button the main game screen would appear, where fruits would be falling from the sky and a basket would be placed at the bottom of screen, the user may move the basket using trackball for collecting fruits, catching every fruit would increase the player's scores and that's it :)
![]() |
![]() |
| Menu Screen | Game Screen |
1- Blackberry JDE (Any jde >=4.5 would work)
2- Eclipse IDE with Blackberry JDE Plugin installed
Lets start the Project!!
Open eclipse create a new blackberry project and name it FallingFruits, set jde to 4.5 or whatever you wish (it doesn't matter) , create a new package org.mobiledev.bb.fallingFruits in that package add our main class named MainApplication.java, this class includes our main method and initiates our menu screen
MainApplication.java
Code:
package org.mobiledev.bb.fallingFruits; | |
| |
import net.rim.device.api.ui.UiApplication; | |
| |
public class MainApplication extends UiApplication { | |
| |
public MainApplication() { | |
Utility.pushScreen(new StartScreen()); | |
} | |
| |
public static void main(String argv[]) { | |
MainApplication main = new MainApplication(); | |
main.enterEventDispatcher(); | |
} | |
} |
As you can see Our menu screen is called startScreen, it would show a title of game and start button at the center of the screen and here's the code:
StartScreen.java
Code:
package org.mobiledev.bb.fallingFruits; | |
| |
import net.rim.device.api.ui.Color; | |
import net.rim.device.api.ui.DrawStyle; | |
import net.rim.device.api.ui.Graphics; | |
import net.rim.device.api.ui.Manager; | |
import net.rim.device.api.ui.component.ButtonField; | |
import net.rim.device.api.ui.container.MainScreen; | |
| |
public class StartScreen extends MainScreen { | |
| |
Manager vfm; | |
ButtonField btn_start; | |
| |
public StartScreen() { | |
super(); | |
| |
//Manager which contains start button | |
vfm = new Manager(FOCUSABLE) { | |
// align start button in screen center | |
protected void sublayout( int maxWidth, int maxHeight ) { | |
ButtonField f = (ButtonField) getField(0); | |
layoutChild(f, 100, 50); | |
setPositionChild(f, | |
(Utility.SCREEN_WIDTH - f.getWidth())/2, | |
(Utility.SCREEN_HEIGHT - f.getHeight())/2); | |
| |
setExtent(Utility.SCREEN_WIDTH, Utility.SCREEN_HEIGHT); | |
} | |
| |
public void paint(Graphics g) { | |
g.setFont(Utility.getLargeFont()); | |
g.setColor(Color.BLACK); | |
String txt = "Falling Fruits"; | |
g.drawText(txt, | |
(Utility.SCREEN_WIDTH - g.getFont().getAdvance(txt))/2, | |
10); | |
super.paint(g); | |
} | |
}; | |
| |
btn_start = new ButtonField( | |
" Start! ", | |
DrawStyle.HCENTER | DrawStyle.VCENTER); | |
vfm.add(btn_start); | |
add(vfm); | |
} | |
| |
protected boolean navigationClick(int status, int time) { | |
Utility.pushScreen(new GameScreen()); | |
return true; | |
} | |
} |
3 comments
all the beginners who want to develop game should start from here.
please keep it up.
This post has 33 feedbacks awaiting moderation...

