Friday, 1 April 2016

MDM Theme created with Phaser Framework and Phaser Editor


MDM Theme created with Phaser Framework and Phaser Editor

I decided to try something completely different and wanted to for awhile now.
I decided to switch from java and opengl for android and try html5 instead.
After much research I decided to use phaser html5 framework.
I then wanted a IDE to code it in, after trying a few (XDK, Sublime and a few others) I decided to give the phaser editor editor a go and decided to use it over all the rest.
Main reason, I am used to eclipse and from working with libgdx it was similar for me.
Plus it has a nice texture packer and assets loader built in which saves a ton of time and it creates the json files to go with it which is easily called for in the code.

Enough of the reasons why, I always wanted to try a gaming framework as the background for mdm themes and decided to give a go.
There was always an issue with canvas and mdm so I sceptical so I threw a 5 minute sample together threw it into the login screen, logged out and crossed my fingers and hoped for the best.
Well to my surprise it worked great, the canvas loaded and ran perfect.

So why use a gaming framing for mdm?
Well it gives you tons more options to create really nice animated login screens, not just basic css animations but all out full blown animations.
Box2d, P2 physics, particles, tweens, animations etc etc etc.
Pretty much anything that can be done in a normal game animation can be done.

So I decided to come up with a quick tutorial to anyone started making them with phaser framework and the phaser editor.

To you started first get the editor here: http://phasereditor.boniatillo.com/blog/
It is free with a nag screen but fully functional, if you use it for your work please donate as it is well worth it.
Drop it into your home directly (it is a standalone version no install necessary), and open it up.
You can start a new project by following the tutorial on the phaser editor site

Use basic.

Now what I did was just use one file for the whole sample I presented here since it was a one page animation but you can make it as detailed as you wish.

I just used the Main.js file to create the whole animation.

All the files I use in this sample plus the base mdm theme files can be downloaded here
http://samriggs.deviantart.com/art/MDM-Theme-created-with-Phaser-Framework-and-Phaser-600449516

First I deleted all the sample stuff (images, other javascript files in the js folder) I kept only the Main.js and assets-pack.json which I changed later to load my atlas and background image.

If you walk through these two tutorials it will teach you how to add images to the texture packer here

and the assets load tutorial here

I don't see any need in rewriting these tutorials here as it is done great on the website tutorial.
The object of the quick tutorial is only to show you how to bring in the created animation into mdm itself.

Here is the main.js code I wrote for this sample.


window.onload = function() {
// Create your Phaser game and inject it into an auto-created canvas.
// We did it in a window.onload event, but you can do it anywhere (requireJS
// load, anonymous function, jQuery dom ready, - whatever floats your boat)
//var game = new Phaser.Game(1920, 1080, Phaser.CANVAS, '');
var game = new Phaser.Game(1920, 1080, Phaser.CANVAS, '', { init: init, preload: preload, create: create, update: update, render: render });
function init() {
game.input.maxPointers = 1;

// Setup the scale strategy
game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
//you can try resiz to see which one fits best show_all scales nicely
//but might show letterbox
//this.scale.scaleMode = Phaser.ScaleManager.RESIZE;
game.scale.pageAlignHorizontally = true;
game.scale.pageAlignVertically = true;
}
function preload() {
game.load.pack("level", "assets/assets-pack.json");
}
var meteor1;
var meteor2;
var meteor3;
var meteor4;
var meteor5;
var movex = 0;
var movey = 300;
function create() {
this.add.image(0,0,"background");
this.add.image(1060,120,"myatlas","planet");
meteor1 = this.add.sprite(movex,movey,"myatlas","rock7");
game.physics.enable(meteor1, Phaser.Physics.ARCADE);
meteor2 = this.add.sprite(movex - 100,movey + 300,"myatlas","rock8");
game.physics.enable(meteor2, Phaser.Physics.ARCADE);
meteor3 = this.add.sprite(movex + 100,movey + 200,"myatlas","rock9");
game.physics.enable(meteor3, Phaser.Physics.ARCADE);
meteor4 = this.add.sprite(movex + 400,movey + 150,"myatlas","rock5");
game.physics.enable(meteor4, Phaser.Physics.ARCADE);
meteor5 = this.add.sprite(movex + 700,movey + 100,"myatlas","rock6");
game.physics.enable(meteor5, Phaser.Physics.ARCADE);
}
function update() {
meteor1.angle += .1;
meteor1.body.velocity.x=100;
if(meteor1.x > 2500){
meteor1.x = -150;
}
meteor2.angle += .2;
meteor2.body.velocity.x=120;
if(meteor2.x > 2500){
meteor2.x = -200;
}
meteor3.angle += .3;
meteor3.body.velocity.x=140;
if(meteor3.x > 2800){
meteor3.x = -250;
}
meteor4.angle += .4;
meteor4.body.velocity.x=180;
if(meteor4.x > 2700){
meteor4.x = -200;
}
meteor5.angle += .6;
meteor5.body.velocity.x=170;
if(meteor5.x > 2900){
meteor5.x = -220;
}
}
function render() {
//you can add debug stuff here for testing
// game.debug.spriteInfo(s, 20, 32);

}
};

I decided to use the screen size of 1920x1080 for my image size, you can make it whatever you want.
Phaser has a nice scale manager with quite a few options, I was going to use RESIZE but after testing I opted for SHOW_ALL
This resizes or sizes the screen once loaded in the window.

game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;

You can check out the scale manager for phaser here

The preloader:
function preload() {
game.load.pack("level", "assets/assets-pack.json");
}
This will load all the images in the assets loader json file that the editor created (all the texture packer json is in this also so it's all in one neat file and can be loaded from this one file.

Here is an image of the texture packer:



Here is an image of the assets loader




Alright then, once you made your creation and are satisfied with it, it is time to bring it on over the your mdm template folder.
Go into your directory where you saved the game files you created and then into the WebContent folder.
Choose all files in this folder except the index.html file, leave that one out.
Copy paste them into your mdm theme folder like below.


Now that your creation is in the folder we need to add the javascript into the head tags of the main index.html file in the mdm folder that runs the mdm files.

Go into your phaser creation in the webcontent folder again where you just copied all those files over from and open up the index.html file and copy the javascript links and paste them into the mdm index.html like below



now that that is done save your mdm index.html file and close it. 

Next change the name in the theme.info file to what you named it (it should be the same name as the folder that holds all these files) like the image below.


Save it and close it.
Now it's time to test out your creation and hopefully it works.
Load the mdm emulator, in linux mint you type in 
mdm-theme-emulator
into your terminal as in the image below


This loads the emulator click on open and find your mdm index.html file and open it, this will load your newly created mdm/phaser theme so you can check it out like below.


volia it works, you can test it here before going live. 
While your at it take a screenshot of this because you need it for your screenshot file in the mdm folder.

Bring in that screenshot into gimp or your program of choice.


Crop around the emulator and open the screenshot.jpg file into gimp also under a new file. Paste this huge image over and select the layer in gimp and under layer resize it to fit the screenshot size so it ffits the same size as below


Some cropping might occur and overwrite the file so it saves your new screenshot and close the mighty gimp.

Now you are ready to go live.

Select the folder that holds your mdm creation, right click --> compress
compress it as a tar.gz as in the image below


Now that you have that done you can go live if you like, go to settings the click on the login window as in the image below


It will ask you for your password, once it opens just drag your tar.gz into the window and install it as in the image below


Select it and next time you log in your ready to see your new mdm login screen.

I included the base mdm file you'll need in the download along with my sample.
Just add your own phaser creation and replace the files I added and your ready to roll.
If you want to learn more about phaser and learn how to make some cool effects and animations they have a ton of examples and you can also download the master file that has tons of examples in it for you to play with.
The site has tons of tutorials to teach you all you'll need to know.
You can check out the examples here

Here is a short video of it in action in the emulator




Happy coding.
Sam


Edit: thanks to MegMut over at the phaser forums http://www.html5gamedevs.com/topic/21659-phaser-tutorial-for-linux-mdm/

I am adding the random code  MegMut added if you wanted to use this mdm yourself or just to use the random part on your own.


Here it is from MegMut:

"I took a good look at your code, and I think I've been able to tweak the performance. There isn't any need to enable the physics engine, as all you're doing is moving the sprites body, also, I went and made it a little bit more dynamic. I hope you don't mind ;) Here's the code :)
create() {
 // create the meteor group
 this.meteorGroup = this.game.add.group;
 this.rocks = [5, 6, 7, 8, 9];
 this.numOfMeteors = 5

 for (var i = 0, i <= this.numOfMeteors; i++) {
  // generate random x value between -150 and the games width
  var x = this.game.rnd.integerInRange(-150, this.game.width);
  var y = this.game.rnd.integerInRange(0, this.game.height);
  // pick a random rock from the rocks array 
  var rock = this.rocks[Math.floor(Math.random()*this.rocks.length)];
  // create the sprite
  var meteor = this.game.add.sprite(x, y, "myatlas","rock8")
  // pick a random speed for the meteor to travel at
  meteor.speed = this.game.rnd.integerInRange(200, 250);
  // pick a rancom spin for the meteor
  meteor.spin = this.game.rnd.integerInRange(-3, 4);
  this.meteorGroup.add(meteor);
 }
}

update() {
 for (var i = 0; i < this.meteorGroup.children.length; i++) {
  this.meteorGroup.children[i].x += this.meteorGroup.children[i].speed;
  this.meteorGrou.children[i].angle += this.meteorGroup.children[i].spin;
  // use world wrap to allow the sprites to go off on side, and continue back on the other
  this.game.world.wrap(this.meteorGroup.children[i], this.meteorGroup.children[i].width, false, true, true);
  // alternativly, set start and x positions for the sprites individually and perform a check on every update loop
 }
}


it will allow you to create as many meteors as you want by changing one variable. It also randomsies a lot of the positional data, meaning every time you go the login screen, it will never look the same. The only thing I've not tried before, is the world.wrap function. I checked the docs and that should work fine, but if it's an issue, you can just do what the button commend of the update loop says"

Thanks MegMut :)



Monday, 28 March 2016

HTML5 Games on the way

Well time for a change. I decided to try my hand at html5 games and apps. Why the change? well I been debating lately whether or not to try making games in html5 since that is the way things seem to flowing these days. It is quicker and easier to code, although going from java down to javascript is a tiny learning curve on what will not work and what will work. Limit on artwork on android limits what can be done with java where as html5 there really is no limit except slowing things down with to much going on at the same time but it is not limited to 1.6 MB at a time or close to that. I can make it any size I want if web based and make it fullscreen or a certain size with the option to go full screen. Keeping users positions and stats in a database hosted on a site opens more doors. Sockets for multiplayer games for web based games. If so desired it can also be ported to phones and tablets as well The list can go and on and I know there can be a debate about it, which I do not wish to go into. Anyhow this is what I'll be working on for awhile and maybe permanently if all goes as expected. Will I still be making android apps? Yup probably so, this just allows me to branch out in areas I always wanted to go.
 After much research and studying I decided to use phaser (soon to be laser) framework. It just works for me so far.
You can check it out here
I tried a few IDE's including sublime and XDK but decided to choose phaser editor as main IDE for html5 games.
Main reasons It just works, it has eclipse as it's base and it is well put together to work with phaser and work much like libgdx does in some aspects so I'm comfortable with that fact.
You can check out the editor here
Also it is LINUX friendly :) here is an image of the phaser editor

 

 It should be a fun journey I'll keep you updated as games progress.

Just to give a quick taste of the first html5 game I am working here is a screenshot.


I won't say what this game is going to be until finished but it is one of my wifes favorite style of game.
The artwork will probably take me longer then the coding but I'll add a post once finished and where to play it, this is just the first level screen (not complete obviously) So there is a longggg way to go yet.
For those curious what programs I work in for to create the art it is my two favorite, gimp and krita, krita for the more painting (blue section) gimp for the layouts and less painting areas (framing, vines etc).
I have to re-teach  myself php and mysql for backend stuff before putting it up (I haven't worked in either since my flash/php tech review days in the early 2000's) but it shouldn't take me to long to refresh my old brain and catch up on new stuff that came down the pipeline since php4.

Also I want to try and use phaser and the phaser editor to create some animated mdm themes for linux, not sure if it will work but hopefully it will, I had some issues in the past using canvas with mdm but maybe this will work.
I'll keep you updated on that experiment because if this works there is a great potential to make some amazing login screens for linux and maybe some animated screensavers as well for linux.
Sam

Monday, 10 November 2014

Pet Duck

Thought I would share this video taken in 2010
I reuploaded it as I had to rotate it, just a nice break.
This was a duck that followed me into my wifes store so we had to get him over to the park so he wouldn't get run over or any harm to him.
This little guy made me want a pet duck.


Just a little breather inbetween me making games and fond memories when I lived in B.C.
Enjoy.
Sam

Wednesday, 24 April 2013





Linux Mint now has html5 coming for the new mdm.
This got my curiosity  up since I like making things that move around a screen, so I decided to make some animated mdm themes for the Linux Mint new mdm.
You can check out all the themes I made here: http://samriggs.deviantart.com/gallery/

Now to get this working on your Linux Mint machine there is instructions and a download to install and how to get it up and running go here: http://blog.linuxmint.com/?p=2327

There is also a thread on the Linux Mint Forum to keep you updated on more themes and updates and just general new mdm stuff here: http://forums.linuxmint.com/viewtopic.php?f=25&t=126979

This is a fascinating new twist on the mdm login screen allowing us to make pretty much anything that can be created in html5 for the login screen.
Another great move for linux mint.
Sam

Sunday, 13 May 2012

Gimp 2.8 Finally



For all those waiting for this one, they finally released a stable version of gimp 2.8
Got to admit it looks good, I was a bit worried but so far so good.
Here is a screen shot I took






This is a new analog clock widget I am currently working on for the android phone.
Yes I create it from scratch.
Hopefully it will be on the market soon and I'll post a link on this site once it is up and ready for download.

This one can now be downloaded for free by clicking on the link below

Get it on Google Play

Notice the docks are all one now :) about time, but you also have the choice of the old docks you can control docking or non docking windows by going under windows > single window mode, check it to have it all one window or uncheck it to get it back to the old way (three separate windows), I deleted the plug in registry then after it was installed I went in and reinstalled it (for those who were wondering if they would disappear).
The most joyous new addition to me is two things.
Doing your text right on the canvas finally with lots of options we never had before.
About time for this one.
What does this mean?  you can do more then one size color etc for one line instead of making them all separate and then lining them up afterwards.
Then there is the one I have been waiting for a long long time.
The cage transform tool.
Oh ya I forgot to mention one of the greatest things gimpers added was the layer folders, now anyone that works with the gimpers and creates tons of layers know the importance of this add on, as you can see in the picture above, this was a piece of art I am currently working on and have not had the chance yet to create the folders, as you can see there is a heck of a lot of layers there for one image, just one part, like a number on the clock can take up to five to ten layers all on it's own to get the effects I want, as you can see by the scrollbar, there are a heck of aa lot of layers for what I have done so far, and that even has some layers merged already that I know I won't be changing later down the road.
So this is why layer folders are so important and should of been added right from the get go, anyone who creates extremely detailed artwork knows they can get lost in layers very easily, with folders you can categorise your layers and shove them all in a folder, let's say I have a folder named numbers (for the numbers on the clock face) I would then shove all my clock number layers into one folder, nice and neat :) 
Then so on with each area, this gives me the ability to find a layer quickly and I don't have to go searching up and down constantly with hundreds of layers, I just go to the folder and close the rest of them and work in one folder at a time.
Nice and convenient and a heck of a lot quicker and more organised.
For someone who only works in a few layers, the old way is just fine but for hundreds of layers, it can quickly get out of control and confusing, especially if you don't name each layer properly, like new layer 1,  new layer 1#1  lol try figuring out that one later after a 50 to a 100 layers lol or more.
So yuppers layer folders a great addition that was needed for any serious gimpers artist long long ago, adobe had it long ago and as any serious gimpers will tell you, gimpers have a lot more to offer and for me anyhow has been a better program long long ago, I stopped working in photoshop literally years ago, and that is even on jobs for a company, the first thing I do is install my gimpers when I worked for companies.
and inkscape, but as for most companies caught up in the adobe pay through the nose software, illustrator is still hard to get away from in companies, gimpers though :) not so hard once shown what it can do.
Anyhow check it all out at gimp.org there is to many things to go into and just repeat what gimpers already said themselves.
Check the release notes, that's where it has screen shots and information and how to download it and install it and how to install it while having gimp 2.6 in the same system if you want that also.
For those who use xubuntu or ubuntu 12.04 there is a quick way of installing it.
at ubuntugeek they say this, this also works for Linux Mint 13 (I use Linux Mint 13 xfce so I personally know it works on this and on xubuntu which I used for a bit).
In case anyone was wondering it should work on all Linux Mint 13 versions.

Open the terminal and run the following commands

make sure you get rid of the old plugin registry this does not show that in this site.
What I did was delete gimp and the registry first then did a install like below.
You can install the registry either through the terminal or through the software center after 2.8 is installed, as far I now it, this has to be done because the old registry is not compatable but the new one is. I gave instructions below to install the registry below this.

I deleted the gimp registry by using
sudo apt-get remove gimp-plugin-registry
Then did the one below
sudo apt-add-repository ppa:otto-kesselgulasch/gimp
sudo apt-get update
sudo apt-get install gimp

here is the link: http://www.ubuntugeek.com/how-to-install-gimp-2-8-in-ubuntu-using-ppa.html  this one does not say what version of ubuntu so I am thinking this might be for everyone.
Now the problem with the above is it does not remove the plugin registry first, this will cause issues, if you have done this then you will have to do a cleaning house abit.
Here is what http://askubuntu.com/questions/132114/problem-on-12-04-with-gimp-2-8 says:
Firstly remove the gimp 2.8 repo by running these commands
sudo apt-get install ppa-purge
sudo ppa-purge ppa:otto-kesselgulasch/gimp

And then run
sudo apt-get update

now remove the plugin-regitery as it is not supported on 2.8
sudo apt-get remove gimp-plugin-registry

Once thats done you can install Gimp 2.8
sudo add-apt-repository ppa:otto-kesselgulasch/gimp
sudo apt-get update
sudo apt-get install gimp


Once it is install you can install the registry plugins again I did mine through the software center by just clicking on the gimpers and clicking the added changes.
Nice and easy :) and it worked for me I tested it.
The other way for all you terminal (just got to do it that way) people which I am 90% of the time.
Here ya go (remember this is after you removed the old gimp 2.6 then the old registry plugins then installed gimp 2.8 then install the registry.

it can be found here: http://www.webupd8.org/2012/05/install-gimp-plugin-registry-for-gimp.html

sudo add-apt-repository ppa:otto-kesselgulasch/gimp
sudo apt-get update
sudo apt-get install gimp-plugin-registry


Hope this helps
Sam