Tag Archives: game

Number Guessing Game using CreateJS

I’ve created a simple “Guess the Number” game in which the objective of the player is to guess the random number selected by the computer within the least possible moves. I’ve used the CreateJS libraries to create the game.

The advantage of using the CreateJS library for game development is that it helps manage graphics on the Canvas in a way that is similar to the Adobe Flash display list. It helps maintain a cleaner work-flow and gradually introduces you to building complex games. This does not mean the other libraries are any lesser in performance or capabilities. I chose CreateJS because I’ve been working with it recently for app development.

The game has been created using CreateJS has been uploaded so that you can play it before attempting to code it. (Refresh the page incase the game doesn’t open)

The game code below primarily covers the most essential features required to learn basic game development using Canvas, HTML5 and CreateJS. This includes –

  • Drawing shapes on the canvas with a fill and outline
  • Creating text and changing the value of the text at runtime
  • Working with Mouse Events
  • Working with Containers (grouping graphics into one object).

To see the complete code including the HTML file, you can download it from this game link.

Mariam

Stop That Silly Chicken game for iPad

Stop That Silly Chicken

With the successful release of “Stop That Silly Chicken”, it is heartening to say that the game was developed using Adobe AIR for the iOS platform.

Stop That Silly Chicken is currently available on the iPad and iPhones. The game uses Milkman Games native extensions for social media and advertising. It also uses a native extension for in-app alerts.

Silly Chicken is a character owned by 9X Media, a brand providing entertainment on television through their various music and cartoon channels.

The game concept revolves around Silly Chicken who runs around a kitchen table in a quest to steal and break the eggs kept safely in a bowl. The player has to tap Silly Chicken before he reaches the table. The player can collect game coins from piggy banks and use them to make purchases from the game store that will make it easier to trap Silly Chicken. The game has 2 modes – Survival and Time mode and both are easy to understand and play. The game is completely free using an advertising model with Admob.

I’ve been reading the comments of the players since its release and glad to see it being liked. It seem that the idea of tapping Silly Chicken and seeing its reactions through different animations is funny for many.

Please download the game if you haven’t already and spread the word about it!

Mariam

The Act Game review

Playing the Act Game is like a watching a beautiful movie. It took me back to the times when I used to watch the classic Disney cartoons on TV, with the only difference being The Act on iOS has some interactivity to keep the user engaged as any game ideally should. I thought of reviewing this game simply because it has a very different gaming experience seen after a long time.

The story begins with Edgar a window washer with the City Medical Hospital spotting Sylvia the nurse through the hospital window and instantly falling in love with her. He dreams of romancing her, but is interuppted by his boss. He is forced to continue cleaning the windows with his sleepy brother Wally when all of a sudden, his brother enters the hospital room through the window and gets into an empty bed. The story then takes Edgar inside the hospital and through various situations involving Sylvia and other characters to rescue his brother from being mistaken to be a patient requiring a brain transplant.

The game animations play very smoothly. The artists have used the classical hand drawn animation style, so the quality of animations are very high. The characters are superbly designed and one can understand their emotions through their expressions.

The controls are very simple involving sliding the finger on the left or right side of the screen. All game interactivity have Edgar responding to the player swipes.  The music too is beautifully rendered and suits the game perfectly. The only issue with the game is that is has a very small game length. One can easily finish it in 30-45 mins.

I remember reading somewhere that the team working on this concept had been test marketing it since 2007 but cancelled launching it then. It has finally released in 2012 on the iOS platform published by Chillingo and is worth a play just for its uniqueness.

HTML5 Game with EaselJS and TweenJS

HTML5 has been a subject of interest and discussion for many developers. I was intrigued by the platform myself and decided to explore it with a simple game of Concentration to understand how easy or difficult it is to plan a project that requires these new web standards. I used the Canvas element with the EaselJS Library and the TweenJS Library for development.

http://mariamdholkawala.com/games/concentration/gameconc.html

Working with the Canvas
When developing games with HTML5, one of the most crucial elements is the Canvas. The Canvas is like a blank slate on which graphics can be drawn using Javascript. The Canvas element is always added to the HTML page with an id reference for use in Javascript. However a canvas can also be created dynamically using JQuery.

Once the canvas is ready for use, we can combine it with libraries such as EaselJS to draw graphics or text. EaselJS has object properties very similar to Actionscript thus offering a more familiar ground to Flash developers.

HTML (set the Canvas):
<canvas id="myCanvas" width="550" height="400"></canvas>

Javascript (loading an image on the Canvas):
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
var img=new Image();
img.src="graphics/title.png";
img.onload = function(){
ctx.drawImage(img,0,0);
}

Javascript (using EaselJS to load image on Canvas):
var canvas = document.getElementById("myCanvas");
var stage = new Stage(canvas);
var img=new Image();
img.src="graphics/title.png";
img.onload = function(e){
var title = new Bitmap(e.target);
stage.addChild(title);
stage.update();
}

<div> tag verses <img> tag verses Canvas
There was a constant decision to be made on what is the best approach for loading graphics. The choice was mostly between the <div> tag, the <img> tag and the HTML5 Image element. I personally observed that all seem efficient to use, but preferred using the HTML5 Image element for in-game graphics because they could be manipulated dynamically much easily. The <div> and <img> tags seemed suitable for the static background and other UI elements which needed design effects with CSS.

HTML (adding a div tag and loading image in the div using CSS):

<div id = "btn"></div>
<canvas id="myCanvas" width="550" height="400"></canvas>

<style>
#btn{
background:url('graphics/playbtn.jpg') no-repeat center;
}
</style>

Mouse Events
Mouse Events and Touch Events are necessary to make any game interactive. With HTML5 too, they can be applied to individual graphical elements or to the complete canvas. Some of the useful events for games are onLoad, onMouseOver, onMouseOut, onClick.

In the Concentration game, I used click events for independent HTML5 elements like button images. I also applied a click event to the complete in-game canvas. This is because, during the game-play, the card placement changes with every level. Each card has a property which is best identified by comparing the mouseclick X and Y properties with the card’s X & Y properties.

Javascript (adding a Click Event to the whole canvas):
canvas.addEventListener("mouseup", mouseUp, false);
or
canvas.onclick = mouseUp;

Javascript (adding a Click event to a graphic using EaselJS):
image.onClick = mouseUp;

Javascript (mouseUp event)
function mouseUp(e){
var mx;
var my;
if(e.layerX >= 0 || e.layerY >= 0){
mx = e.layerX;
my = e.layerY;
}else if(e.offsetX >= 0 || e.offsetY >= 0){
mx = e.offsetX;
my = e.offsetY;
}

for(i = 0; i<deck.length; i++){
var card = deck[i];
if((mx > card.xpos && mx < card.xpos + cardWidth) && (my > card.ypos && my < card.ypos + cardHeight)){
//card clicked
}}}

Working with Different Screen Sizes
Supporting different browsers and devices is touted as one of the biggest plus points of HTML5. This means we should be able to customize our content to detect different screens and render the code accordingly. However this is not as easy as it seems, especially for games. There are several challenges in supporting the game on different browsers and device screens.

I remember reading an article on Adobe Developer Connection on working with HTML5 and CSS3 with Dreamweaver but it seemed more apt for app development not suiting my purpose of fluid dynamic screens for games. I did some testing with my game code and managed to achieve a common graphic database for some in-game elements. The current game that I developed, detects the browser and resizes in-game graphics after identifying the device (although there is scope for improvement).

Using TweenJS for transitions and animations
Very good transitions and animations are easily achievable using CSS3, but the TweenJS library makes it much easier to work with animations, especially if you have used the EaselJS Library for the rest of the game. I have used the fade-in fade-out transition for the cards in the Concentration game.

The code below simply fades an image to 0 alpha within 400 milliseconds without a loop. The detailed use of the TweenJS library can be found online.

Tween.get(imageToTween,{loop:false}) .to({alpha:0},400,Ease.get(1))

There are many resources available to understand game development with HTML5. I found the development interesting and hope to discover better development techniques as I work with this code. For seasoned Flash game developers, it may feel like a little let down, but giving in to the HTML5 hype can keep the motivation up.

http://mariamdholkawala.com/games/concentration/gameconc.html

This game should load in all browsers supporting HTML5 (IE gives weird results, not tested on Safari). The game should also run on device browsers but may not give a great experience because it is not ready for devices.

I’ll share the code when it is ready.

UPDATE: The game source files can be downloaded from ConcentrationGame.zip (1.24MB)

Mariam

Flash Lite games on OVI Store

I recently uploaded 2 games on the OVI Store which have been developed using Flash Lite for the Symbian platform.

The first Green Dweller – is a gaming application which was approved for the Open Screen Project Fund.
Green Dweller aims at creating awareness about the environment and how it impacts our lives. Green Dweller encourages sociability through gaming, at the same time provides a message of saving the environment by reducing the carbon footprint. Green Dweller is developed for mobile phones using the Adobe Flash Lite technology.

The second is Gear Wager – this game was nominated by the IMGA Awards in the Best Casual Games Category when it was originally developed for Symbian S60 3rd Edition phones. With Symbian^3 devices such as the Nokia N8 now having amazing processing speed, it made the game development experience with Flash much more better, thus the decision to port the game.

Gear Wager is a casual game where you have to help a fallen star escape back into the sky before dawn. Besides a new and innovative game-play, the game has the feature of Facebook Connect to post messages on the user wall.

Please download the games and post reviews (good or otherwise 🙂 )!

Mariam