mobileradicals | 20 September, 2007 12:33
> devkit login username password
> devkit --proxy wwwcache.lancs.ac.uk:8080 --auth user1 pass1 login user2 pass2

<?xml version="1.0" encoding="utf-8"?>Helium script (bombus.he):
<widget spec_version="2.0">
<info>
<name>Bombus</name>
<version>0.1</version>
<author>Widget Workshop</author>
<shortdescription>
A one button side scrolling arcade game
</shortdescription>
<longdescription>
Guide Bombus through the cave.
</longdescription>
<tags>
bombus game arcade side scrolling one button
</tags>
</info>
<parameters>
<parameter
type="string"
name="widgetname"
description="Name of widget"
help="This is the name of the widget"
editable="false"
visible="true">
Bombus
</parameter>
</parameters>
<resources>
<code src="bombus.he"/>
<stylesheet src="style.css"/>
<img src="mobile_radicals.png" scale="false" />
</resources>
<layout minimizedheight="3em">
<view id="viewMini">
<label class="outerFrame">Bombus</label>
</view>
<view id="viewMain">
<script id="gameView" />
</view>
</layout>
</widget>
class {
// Command IDs
const int CMD_BACK = 1;
const int CMD_NEW_GAME = 10;
const int CMD_INSTRUCTIONS = 11;
const int CMD_ABOUT = 12;
// Member vars.
Shell gameShell;
Flow gameFlow;
Canvas gameCanvas;
// Menu items (mapped to softkeys)
MenuItem BACK = new MenuItem(CMD_BACK, "Back");
MenuItem OPTIONS = new MenuItem(OPEN_MENU, "Options");
// Create options menu (using chaining)
Menu MENU = new Menu()
.add(CMD_NEW_GAME, "New game")
.add(CMD_INSTRUCTIONS, "Instructions")
.add(CMD_ABOUT, "About");
// Push shell onto screen
void showShell(Shell shell) {
int w, int h = getScreenSize();
slideIn(-w, 0, w, h, shell);
}
// Pop shell off screen
void hideShell(Shell shell) {
int w, int h = getScreenSize();
slideOut(w, 0, w, h, shell);
}
// Called for each view element
Component createElement(
String viewId, String elementId, Style s, Object o) {
if(elementId.equals("gameView")) {
gameFlow = new Flow(getStyle("outerFrame"));
gameCanvas = new Canvas(getStyle("default"));
gameCanvas.setPreferredSize(-50, -50);
gameFlow.add(gameCanvas);
return gameFlow;
}
return null;
}
// Create minimized view
void startWidget() {
setMinimizedView(createView("viewMini", null));
}
void stopWidget() {} // Stop
// Create maximized view when the widget is opened
Shell openWidget() {
gameShell = new Shell(createView("viewMain", null));
showShell(gameShell); // Show main shell
return null; // We've already push shell into view
}
// Release resources
void closeWidget() {
gameCanvas = null;
gameFlow = null;
gameShell = null;
}
// Paint the gameCanvas
void paint(Component c, Graphics g, Style s, int w, int h) {
g.setColor(0x0000FF);
g.fillRect(0, 0, w, h);
g.setColor(0xFFFFFF);
g.drawString(
"Our canvas!", w / 2, h / 2, HCENTER | TOP);
}
// Get the menu
Menu getMenu(Shell shell, Component source) {
return MENU;
}
// Softkey event handler
MenuItem getSoftKey(Shell shell, Component focused, int key) {
if(key == SOFTKEY_OK)
return OPTIONS;
else if(key == SOFTKEY_BACK)
return BACK;
return null;
}
// Key event handler
boolean keyAction(Component source, int op, int code) {
return false; // Key event not consumed
}
// Action event handler
void actionPerformed(Shell shell, Component source, int action) {
switch(action) {
case CMD_NEW_GAME:
break;
case CMD_INSTRUCTIONS:
break;
case CMD_ABOUT: // Display 'about' info.
setBubble(
getImage("mobile_radicals.png"),
"Bombusnmobileradicals.com");
break;
case CMD_BACK:
// Pop shell
hideShell(shell);
break;
}
}
}
Stylesheet (style.css):
outerFrame {
align: hcenter vcenter;
background: solid #000000;
color: #FFFFFF;
width: 100%;
}
Please note, blogs after this will not post complete source listings, but instead provide important fragments that demonstrate key game concepts.
Browsing, Games, Java |
Permalink |
Comments (2) |
Trackbacks (0)
mobileradicals | 25 August, 2007 12:56
Browsing, Entertainment, Games |
Permalink |
Add comment |
Trackbacks (0)
mobileradicals | 16 August, 2007 19:40
Enterprise, Entertainment |
Permalink |
Comments (4) |
Trackbacks (0)