Click here to Skip to main content
Click here to Skip to main content

Snow Ninja

, 20 Aug 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
Snow ninja is a full fledged desktop application targeted to run on multiple devices

Please note

This article is an entry in our AppInnovation Contest. Articles in this sub-section are not required to be full articles so care should be taken when voting.



Platform : All-In-One 

Category : Games  

Coding Language :  Game maker language (GML)  

Introduction 

Snow Ninja is a simple , single player game developed with the inspiration of Fruit Ninja , the most popular game of Ninja slicing the fruits. The whole idea of game development came to my mind when my wife started playing a bubble game. So here we begin with the story on Ninja game. 

Our ninja once lost his route while he was on his way to meet his master. It was a snow time , ninja was little frustrated and completely lost his mind and started thinking of playing a game of cutting the vegetables and having some fun.   

Aim of the Game 

Implement a multi level game. Slice as many vegetables as possible without leaving one and should not cut the bomb. By chance if the ninja slices the bomb his lives will be decremented by one and the same is the case for the non sliced vegetables.
 

How are we implementing the Snow Ninja game ? 

The entire game is developed in Game Maker Studio , a tool for developing rapid game. The programming
language used is Game maker language (GML) it's a proprietary programming language from Game maker studio.
 

Creating Sprites

First we need to create sprites for our game. Sprites are nothing images which are single or multiple images
so that we can show an animated sprite image. These are created to represent the objects.Here we are creating sprites for carrot, potato, pepper, onion etc. We can easily create on or reuse existing images.

 

Creating objects required for the game. 

Objects are the building block of our game. We will be creating objects that are required for our game , say one for initializing , controlling, rendering snow , an object for showing the vegetables and we will be reusing the same object for showing other vegetables.


Events and Actions 

We will be handling various events like Create , Destroy, Step , Draw etc specific to our objects. Note – some objects are associated with sprites and some may not , it depends on the object. Also some objects have the user interaction while others are not. Say for example an object for showing the snow will be running continuously in the background which has no user interactions.

Create event happens when an instance of an objects is created. We can have our initialization code with in
this event.

Destroy events gets executed when an instance of an objects gets destroyed. We will be handling this event
for cleaning up of snow particle system etc.


Creating Rooms

Rooms are created for placing the objects, Rooms are nothing but space or levels. We will be creating room for initializing , a room which shows the game start up , when the user clicks or taps on it will move on to next room where the user can play the game. The room for running the game is a space where we will be adding objects for showing the snow in the background, drawing score , lives and the most important object that controls the whole game. 


Particle effects for snow 

Code for Create and Destroy event. In create event , we will be creating a particle system , then create a particle type and finally use emitters to render the particle. Don't worry if these things sound something new to you, I will be explaining and do a code walk through and explain the same below. 

Background

Experience in developing games using Game Maker Studio. 

Using the code

Here's how we create snow , below is the code snippet for creating a particle system , particle type and
render particles using by making use of emitters.  

// Create a particle system
global.ParticleSystem=part_system_create();
 
// Create a particle type
global.Particle1=part_type_create();
 
// Set particle type properties 
part_type_shape(global.Particle1,pt_shape_pixel) //This defines the particles shape...
part_type_size(global.Particle1,1,1,0,2) //This is for the size...
part_type_scale(global.Particle1,1,1) //This is for scaling...
part_type_color1(global.Particle1,c_white) //This sets it´s color. There are three different codes for this...
part_type_alpha1(global.Particle1,1) //This is it´s alpha. There are three different codes for this...
part_type_speed(global.Particle1,0.50,2,-0.10,0) //The particles speed...
part_type_direction(global.Particle1,0,359,0,20) //The direction...
part_type_orientation(global.Particle1,0,0,0,0,1) //This changes the rotation of the particle...
part_type_blend(global.Particle1,1) //This is the blend mode, either additive or normal...
part_type_life(global.Particle1,1,20) //this is it´s lifespan in steps...

// Define and name the emitters
global.Particle1_Emitter1=part_emitter_create(global.ParticleSystem);
global.Particle1_Emitter2=part_emitter_create(global.ParticleSystem);
 
//Set up the area that will emit particles
part_emitter_region(global.ParticleSystem, global.Particle1_Emitter1, 0, room_width, 0, room_height, ps_shape_rectangle, ps_distr_linear);
part_emitter_region(global.ParticleSystem, global.Particle1_Emitter2, mouse_x-10, mouse_x+10, mouse_y-10, mouse_y+10, ps_shape_ellipse, ps_distr_gaussian);
 
//Set the first to stream 10 particles every step
part_emitter_stream(global.ParticleSystem, global.Particle1_Emitter1, global.Particle1, 10);
 
//Set the alarm[0] event to burst the emitter2 particles...
alarm[0]=30;
 
//The second emitter has to move to the mouse position so...
part_emitter_region(global.ParticleSystem, global.Particle1_Emitter2, mouse_x-10, mouse_x+10, mouse_y-10, mouse_y+10, ps_shape_ellipse, ps_distr_gaussian);
 
//Now to burst 30 particles and reset the alarm[0]
part_emitter_burst(global.ParticleSystem, global.Particle1_Emitter2, global.Particle1, 30);
alarm[0]=30;

Destroy event

We will be cleaning up the particle type , emitter and then finally the particle system.   

part_type_destroy(global.Particle1);
part_emitter_destroy(global.ParticleSystem, global.Particle1_Emitter1);
part_emitter_destroy(global.ParticleSystem, global.Particle1_Emitter2);
part_system_destroy(global.ParticleSystem);
game_restart();
Dynamic Instances of vegetables. 

Our game requires various vegetable instances to be created and throw it up with an angle so that ninja can slice them. In order to speed up the game , we need to reduce the number of instance creation that will be required to show up the vegetables to slice.    

repeat( 1+irandom(max(floor(sqrt(score/3)),1)) )
{
    p=instance_create(random(room_width),room_height+64,oVeg)
    p.vspeed=-15-random(8)
    p.hspeed=-(p.x-(room_width/2))/50
    p.hspeed*=choose(0.7,0.8,0.9,1,1.1,1.2,1.3)
    p.gravity=0.3
    p.image_angle=random(360)
 p.sprite_index=choose(sCarrot,sPotato,sPepper,sBroccoli,sSpringOnion,sOnion,sCarrot,sPotato,sPepper,sBroccoli,sSpringOnion,sOnion,sTNT)
}
Collision checking and slicing of vegetables 

We will be using a small piece of sprite image for the collision mask, this helps us to have more precise collisions. Game maker studio has built in collision checking event, we will be handling this event and do some interesting things like explosion in case the ninja slices the vegetable bomb, increment score value, Show combo , increment lives , create an instance of sliced vegetables based on the sprite index , also play sound and destroy the instances etc.

Here's the collision actions at high level. Notice that we are creating an explosion when the sprite index is equal to bomb vegetable. 

 

Points of Interest

Game development is always interesting and fun. There are lots of things that I came to know and learnt while implementing this game. It's nice to play with sprites , building a particle system and work with it is an amazing things. Apart from all these the other interesting part was handling collision. 

Snapshots



History 

Version 1.0 Initial layout of the Snow Ninja game development. 



License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Ranjan.D
Web Developer
United States United States
Profile
 
Around 10 years of professional software development experience in analysis, design, development, testing and implementation of enterprise web applications for healthcare domain with good exposure to object-oriented design, software architectures, design patterns, test-driven development and agile practices.
 
In Brief
 
Analyse and create High Level , Detailed Design documents.
Use UML Modelling and create Use Cases , Class Diagram , Component Model , Deployment Diagram, Sequence Diagram in HLD.
 
Area of Working : Dedicated to Microsoft .NET Technologies
Experience with : C# , J2EE , J2ME, Windows Phone 8, Windows Store App
Proficient in: C# , XML , XHTML, XML, HTML5, Javascript, Jquery, CSS, SQL, LINQ, EF
 
Software Development
 
Database: Microsoft SQL Server, FoxPro
Development Frameworks: Microsoft .NET 1.1, 2.0, 3.5, 4.5
UI: Windows Forms, Windows Presentation Foundation, ASP.NET Web Forms and ASP.NET MVC3, MVC4
Coding: WinForm , Web Development, Windows Phone, WinRT Programming, WCF, WebAPI
 
Healthcare Domain Experience
 
CCD, CCR, QRDA, HIE, HL7 V3, Healthcare Interoperability
 
Others:
 
TTD, BDD
 
Education
 
B.E (Computer Science)
 
CodeProject Contest So Far:
 
1. Windows Azure Developer Contest - HealthReunion - A Windows Azure based healthcare product , link - http://www.codeproject.com/Articles/582535/HealthReunion-A-Windows-Azure-based-healthcare-pro
 
2. DnB Developer Contest - DNB Business Lookup and Analytics , link - http://www.codeproject.com/Articles/618344/DNB-Business-Lookup-and-Analytics
 
3. Intel Ultrabook Contest - Journey from development, code signing to publishing my App to Intel AppUp , link - http://www.codeproject.com/Articles/517482/Journey-from-development-code-signing-to-publishin
 
4. Intel App Innovation Contest 2013 - eHealthCare - http://www.codeproject.com/Articles/635815/eHealthCare
 
5. Grand Prize Winner of CodeProject HTML5 &CSS3 Article Contest 2014
 
6. Grand Prize Winner of CodeProject Android Article Contest 2014

Comments and Discussions

 
GeneralThanks! PinstaffKevin Priddle21-Aug-13 13:25 
GeneralRe: Thanks! PinprofessionalRanjan.D21-Aug-13 14:58 
GeneralMy vote of 5 PingroupGrasshopper.iics19-Aug-13 22:46 
GeneralRe: My vote of 5 PinprofessionalRanjan.D20-Aug-13 2:17 
GeneralMy vote of 5 PinprofessionalAbhishek Nandy19-Aug-13 21:50 
GeneralRe: My vote of 5 PinprofessionalRanjan.D20-Aug-13 2:16 
GeneralRe: My vote of 5 PinprofessionalAbhishek Nandy20-Aug-13 3:17 
GeneralMy vote of 5 PinprofessionalDrABELL19-Aug-13 18:53 
GeneralRe: My vote of 5 PinprofessionalRanjan.D20-Aug-13 2:15 
GeneralRe: My vote of 5 PinprofessionalDrABELL20-Aug-13 6:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411019.1 | Last Updated 20 Aug 2013
Article Copyright 2013 by Ranjan.D
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid