Block it Game (under 10 events)

2

Attached Files

The following files have been attached to this tutorial:

.capx

Stats

2,445 visits, 3,239 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 23 Nov, 2016. Last updated 19 Feb, 2019

Hi, wanted to show for those who dont know C2 very well yet, how they can make a Block It Type of game under 10 events.

What we will need :

1 sprite object for the ball;

2 local variables on the sprite object (score,hiscore)

2 tiled background objects;

Touch plugin;

LocalStorage;

And 1 text or 2 depends how much info you want to display, i used 2 sprite fonts in my example. (we will use 2 sprite fonts, for score and hiscore indication)

Let's begin:

First we create a new Landscape, or Portrait project, i choose'd a Portrait one since the game is minimalist by itself and doesn't require to much graphics or info on sides.

The we add the sprite object create a frame that represents a circle or a dot around the size of 32 x 32 px choose any color, myself i choose'd to design the game in a monochrome pallet (B&W).

Then we add the 2 tiled backgrounds, and set their frame or image to 32x32 and what color you want.

Lets explain why 2 tiled backgrounds: 1st one will use it as walls, the 2nd one will use it as the show/hide ball deflector as i like to call it.

Once we placed them in the screen editor like in the following image:

We add the behavior solid to the Tiled Backgrounds, and for the ball sprite object, we add the behavior bullet and set the bullet option bounce out of solids to Yes.

We also make the Deflector invisible by default from the bottom settings page in left side, and Disable the Solid Behavior, so its not going to glitch on start of layout.

Lets move to the event sheet:

Ok so lets explain things a bit, on start of layout we give the ball a push, the push itself since the ball has the bullet behavior, it automatically moves towards the angle direction the ball has, so we change that to a random(230,320) that will push on start of layout the ball towards the angle left 45 degress upwards to 45 degrees right upwards.

now we call the localstorage i know its a bit confusing but bare with me all will be explain, so at beginning of layout the localstorage calls the value of hiscore and sets the value to the ball.hiscore if the ball.hiscore is equal to 0 or less then 0.

as we see next line when the ball hits the deflector, ads 1 to score and sets the 1st spritefont the big one in the middle, and then we compare if score is greater then hiscore, then hiscore is set to the value of score.

once the hiscore is saved in the ball.hiscore variable, we save that info into the localstorage then we added the wait 0 to make sure that localstorage made that action. once that happened we call the get item hiscore and set it to the spritefont from the top which is the hiscore indicator.

Kinda that is it... and its only in 6 events... and you have another 94 events to customize it as you like, if your using the C2 free edition.

You can find the final capx in the attachments. Feel free to ask a tutorial and comment/rate/share this tutorial. Hope you found it helpful and fun.

You can also play the gamehere. For some reasons the Scirra Arcade doesn't read the localstorage value for hiscore, maybe is because i used spritefont. But all works well on localhost:preview.

.CAPX
  • 0 Comments

Want to leave a comment? Login or Register an account!