mShell Blog

22
Oct

Little Lives

by Dan
Little Lives is a very simple side-scrolling game written for mShell 3.0. It takes advantage of m's new object-oriented programming support, such as classes and inheritance. It is designed to show the power and speed of mShell on Symbian mobile devices, and furthermore the creative results a small m script can produce.
 
The game is built up around the Object class which contains two methods process() and paint(). The process() method is responsible for processing the objects logics, such as movement and simple AI. The paint() method is responsible for drawing the object on screen, including it's rotation and viewport offset. For each frame in the game, every living (active) object is processed and painted once.
 
The arrow keys on the mobile device control an on-screen cursor. The object .tadpole will always follow this cursor. Furthermore, moving the cursor off the edge of the screen will scroll the viewport. If available, the cursor may also be controlled using the phone's accelerometer.
 
The following objects have been implemented: DebugObject, Cursor, Ripple, Beam, Energy, WaterPlant, Food, Letter, WaterAnimal, Tadpole, AITadpole, RadioWave, EnergyBar and Fish.
 
Please feel free to modify this script to your wishes and needs. Feedback is always appreciated: dan.kruesi@airbit.ch.
 
 
Downloads 

LittleLives.m (38.85 kb)

LittleLivesS603rd.sis (321.31 kb)

 
Update: Current version supports phones without accelerometer module. 
 
Screenshots
 
 
 
 
 
More about the Objects
 
View - used by most objects during thier paint() method for thier on-screen offset. This class does not offer any functionality (yet).

Map - contains all the objects within the game. objects is the superset of backgroundObjects, gameObjects and guiObjects. The objects are organized in such a way for easy and quick layering.

Object - the core class of the game. Every entity must extend this class. The two methods process() and paint() must be implemented by these subclasses. These methods are called on all living objects on every frame.

Cursor Object - displays a cross-hair cursor on screen. Used for influencing the .tadpole movement as well as controlling the viewport position.

Ripple Object - mimicks a single ripple moving through the water. Eventually fades away when reaching maxSize.

Beam Object - A horizontal and vertical beam flashes and dissappears slowly at the given x and y coordinates...

Energy Object - visual representation of energy consumption. Displayed when a tadpole eats some food and gains energy.

Water Plant Object - a simple floating water plant. This object drifts slowly in the water and is designed to be in a cluster.

Food Object - a randomly drifting piece of food which can be eaten by tadpoles. When a food is eaten, the tadpole gains in energy and size...

Letter Objects - represents a single character floating randomly onscreen. Use the function addLetterText(x,y,text) to display a series of these letters onscreen.

Water Animal - super class for any moving water animal. This class provides the functionality for moving through the water, wiggling tails and/or fins, navigating to a specific point, and accelerating/decelerating...

Tadpole Water Animal - represents a small tadpole. Tadpole is a WaterAnimal, thus it automatically knows how to move through the water and wiggle it's tail.

AI Tadpole Water Animal - a tadpole which can move by itself. This object either moves to a random location, to our own tadpole, or to a targetted random piece of food.

Fish Water Animal - a large fish water animal which can move through the water by itself. This object moves to either a random location or towards our own tadpole.

Energy Bar Object - A thin horizontal bar at the screen bottom which displays our tadpoles current energy. The bar dissappears after a short moment in order to enable a fuller gaming experience.

Radio Wave Object - a set of small radio waves which are dispersed at the given angle from the origin. 

Currently rated 4.4 by 5 people

  • Currently 4.4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

m Programming | mShell

Powered by BlogEngine.NET 1.3.0.0


Calendar
<<  October 2008  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar
Archive
Authors
Tags
Categories

Sign in