SlideShare ist ein Scribd-Unternehmen logo
1 von 73
Downloaden Sie, um offline zu lesen
UEI Headquarters
Company Profile


Start : August 8th, 2003
HQ : Bunkyo-ku Yushima 3-1-3
Employee: 130 peoples
Legal Capital: 35,000,000 yen
Since 2011/4/17
Features

Distributed under MIT/GPL3, Open source
software

Class base programming

TRUE cross platform

Many plug-ins
Why is it open source?

Good for debugging and tuning

Learn once, use eternally

HTML5 can’t hide source codes

Open is the best way to polish the library
Why HTML5?

  Chrome                 Android




   Safari                 iPhone




                         Windows
Windows8
                         Phone7
Feature of HTML5

Cross platform (lie)

Each browser compete to improve performance

You can get whole source code under GPL(important)

HTML5, actually work as OS
HTML5 is new era of OS

              HTML5 Apps
Application   Web Browser
    OS            OS
  BIOS           BIOS
Hardware       Hardware
  Legacy OS     HTML5 era
HTML5 and JavaScript
JavaScript come from functional language “scheme”

Special and strange “prototype based” OOP.

You can manipulate elements of HTML5 thru DOM

Super powerful, but not easy to use


=> You need enchant.js
Let’s try enchant.js
Basics of object oriented game programming
First, download it

enchantjs.com
 Click Here
Extract and check it out



Open this folder
Checkout hellobear



                 Open this
Check out main.js




                    This is it!
Also you can use



     code.9leap.net

You can also code online in browser
  No need to download anything
Four foundation classes


Sprite

                             Label
               SCORE:400



Game
Scene


         That’s all! Easy!
Basics of enchant.js
    enchant();
    window.onload=function(){
        game = new Game();
        //
        // Prepare game assets here
        //
        game.onload = function(){
          //
          // Initialize game objects here
          //
        }
        game.start();
    }
Basics of enchant.js
             enchant();
             window.onload=function(){
                 game = new Game();
                 game.fps = 30;
                 game.onload = function(){
                     hello = new Label(“Hello,Bear”);
Hello,Bear
                     hello.x=10;
                     hello.y=150;
                     game.rootScene.addChild(hello);
                 }
                 game.start();
             }
Basics of enchant.js
        Sprite

                             Label
                 SCORE:400



game.rootScene



 When you addChild to game.rootScene,
        the entity turn to visible
Change position of label
             enchant();
             window.onload=function(){
                 game = new Game();
                 game.fps = 30;
                 game.onload = function(){
Hello,Bear        hello = new Label(“Hello,Bear”);
                   hello.x=10;
                   hello.y=10;                    Change this number
                   game.rootScene.addChild(hello);
                 }
                 game.start();
             }
Classes and Objects



  Hello,Bear
                   This is “hello” object
                       of Label class


Be careful! Class and object are different
Class and object
                  Class                  : Man
                  Object                 :Bill Gates

     Hello,Bear
                  ↓Name of object
                  hello = new Label(“Hello,Bear”);
                                        ↑Name of class
                  new is an operator to create object from class constructor



Every object is created by class constructor
Class and Objects

hello = new Label(“Hello,Bear”);



 Please create object named “hello”
 of Label class.
 And initialize it as “Hello,Bear”
Manipulate property
               hello
                 Hello,Bear
                 x     y   text      This is
                                    property

hello.x = 10; // X coordinate of hello
hello.y = 200; //Y coordinate of hello
hello.text = “Hello,Bear”; // text of hello
Change text of label

               enchant();
               window.onload=function(){
                 game = new Game();
                 game.onload = function(){
                   hello = new Label(“Hello,Bear”);
  Hello,Bear        hello.x=10;
                    hello.y=200;
                    hello.text=”Hello,Calpoly”;       Change text
                    game.rootScene.addChild(hello);
                 }
                 game.start();
               }



dot can access to the property of objects
Label changes to button
                enchant();
                window.onload=function(){
                  game = new Game();
                  game.onload = function(){               Add this line
                    hello = new Label(“Hello,Bear”);
                     hello.x=10;
   Hello,Bear        hello.y=200;
                     hello.addEventListener(‘touchend’,function()
                     {
                       this.text=”Hello,Calpoly”;});
                     game.rootScene.addChild(hello);
                  }
                  game.start();
                }


You can add event listener to label object
What is event?

                                Touched!!
                 hello
                   Hello,Bear

 Time elapsed!              He dragged me!




Variety of events will happen to objects.
What is event?
hello            Touched !

  Hello,Bear
                              ↓Name of event
hello.addEventListener(‘touchend‘,
 function(){
   this.text = “Hello,Calpoly”;
 }
);       ↑This is event listener
Variety of events
                touchend
hello
  Hello,Bear
                  touchstart

               enterframe

        touchmove
Variety of events
                touchend
hello
  Hello,Bear
                  touchstart

               enterframe
                               These
                               are the
        touchmove              essential
                               ones
Use enterframe event
               enchant();
               window.onload=function(){
                 game = new Game();
                 game.onload = function(){           Change like this!
                   hello = new Label(“Hello,Bear”);
                    hello.x=10;
  Hello,Bear        hello.y=200;
                    hello.addEventListener(‘enterframe’,function(){
                      this.x+=1;});
                    game.rootScene.addChild(hello);
                 }
                 game.start();
               }


What happens when using enterframe?
Congratulations!
You became a freshmen of enchant.js!
Using Sprites
Sprites are superhero of game programming
By the way,
What is “sprites”?

   That’s not a soda
What is sprites?




Sprites means fairies fly on the screen
Try summon a sprite!
enchant();                             CAUTION!
                                   preload must come
window.onload=function(){            before onload
  game = new Game();
  game.preload(‘chara1.png’);
  game.onload = function(){
    bear = new Sprite(32,32);
    bear.image = game.assets[‘chara1.png’];
    game.rootScene.addChild(bear);
  }
  game.start();
}
Sprites and enterframe
enchant();
window.onload=function(){
  game = new Game();
  game.preload(‘chara1.png’);
  game.onload = function(){
    bear = new Sprite(32,32);
    bear.image = game.assets[‘chara1.png’];
    bear.addEventListener(‘enterframe’,
     function(){
       this.x+=1;
                                      Add event listener of
     }                                 enterframe events
    );
      game.rootScene.addChild(bear);
  }
  game.start();
}
Create a sprite

bear
          ↓Name of object
          bear = new Sprite(32,32);
                               ↑Name of class
         new is an operator to create object from class constructor
Geometry of sprites

bear

                 bear = new Sprite(32,32);
            32



   32
Pass a geometry when sprites is created
Property of sprites
         bear

                    scaleX
       age          scaleY

         x y frame


Change some property of sprites!
demo
What’s a frame property?
Bear
0      1     2     3     4


5      6     7     8     9


10     11   12    13    14


The frame numbering from top-left
Hit the bear
enchant();
window.onload=function(){
  game = new Game();
  game.preload(‘chara1.png’);
  game.onload = function(){
    bear = new Sprite(32,32);
    bear.image = game.assets[‘chara1.png’];
    bear.addEventListener(‘touchend’,
      function(){
        this.frame=3;       When you touch the bear,
      }                     change frame to 3
    );
     game.rootScene.addChild(bear);
  }
  game.start();
}
Congratulations!
You became a beginner of enchant.js!
The first step of Game designing
Process of
       game development
1.Choose the theme of the game
2.Decide the minimum spec of the game

3.Make it

4.Play it

5.Consider about it, and repeat from step 2.
How to choose theme?
Easy to imagine the programming code
Don’t be afraid to become a copycat! It’s good
way to start
Code before consider, and change on code

Add new feature, and delete actual feature

Change graphics, story, and detail!

         Important thing is
   “You aren’t genius(right now)”
Nobody is a great creator,
   Just genius copycat
Do it yourself!
After you choose
    the theme



Then, draw a sketch of ideas
Tools for sketch



Moleskine
               Drawing papers for kids   Signature pens   iPad
Plane note
Example of Sketch
                    Hit
    Apple
                          Run a way



Hit the bear

                              I use ishodo
Save apples                    available in
                                AppStore
Polish your sketch
 When all apples
are eaten by bears,
 then the game is
       over



                                   Bears appear
 How many bears                    from the sides
   can you hit?


    Polish your sketch,and clarify the ideas
Polish your sketch
 When all apples
   are eaten by
      bears,
then game is over
Game over


                                      Basic behavior
Score                            Bears appear
How many bears                    from sides
  can you hit?


  Decide the 3 essentials of game designing
Check out materials
chara1.png

                                               icon0.gif




Images folder includes many royalty free images you can use
                       for enchant.js
Be careful about geometry
chara1.png(32x32)

                                      icon0.gif(16x16)




          Each image file has its own geometry.
Master of classes
This’s a secret weapon of programming ninja
Find classes from sketch


      Enemy




       Items




The characters and items will become a class
Create your own class
        Class of Bear
Bear = Class.create(Sprite,{
 initialize:function(){
   Sprite.call(this,32,32);
   this.image = game.assets[‘chara1.png’];
 }
});

   Class can inherit from actual enchant.js
   classes.Usually inherit form Sprite class
Create your own class
                                     Inherit from Sprite class

↓Name of your own class
Bear = Class.create(Sprite,{
 initialize:function(){
   Sprite.call(this,32,32);
   this.image = game.assets[‘chara1.png’];
 }
});      ↑Constructor of Bear class
Using custom class
enchant();
window.onload=function(){
  game = new Game();        You can create object in same style
  game.preload(‘chara1.png’);
  game.onload = function(){
    bear = new Bear();
    game.rootScene.addChild(bear);
  }
  game.start();
}

            It is very easy and useful!
Event definition of class
          Class of Bear
Bear = Class.create(Sprite,{
 initialize:function(){
    Sprite.call(this,32,32);
    this.image = game.assets[‘chara1.png’];
 },
 onenterframe:function(){
    this.x+=1;
 }              on + name of event will work as a event listener.
});             It’s easy to code any event listener defined in class
                         definition.
Mr. Bear hit and cry
Bear = Class.create(Sprite,{
 initialize:function(){
    Sprite.call(this,32,32);
    this.image = game.assets[‘chara1.png’];
 },
 onenterframe:function(){
    this.x+=1;
 },
 ontouchend:function(){
    this.frame=3;
 }
});
Live coding
Classes of sketch


Bear class




Item class




             Bears appear and then hit them
Tips: Random numbers


↓When I need 0 - 9 random number
n = Math.floor(Math.random()*10)
   When you set 10, you get 0-9↑
Tips: Remove Sprites



       game.rootScene.removeChild(bear)

The object you wants to remove from scene↑
You can download this slide
Check out our facebook page

Weitere ähnliche Inhalte

Was ist angesagt?

The Ring programming language version 1.8 book - Part 57 of 202
The Ring programming language version 1.8 book - Part 57 of 202The Ring programming language version 1.8 book - Part 57 of 202
The Ring programming language version 1.8 book - Part 57 of 202Mahmoud Samir Fayed
 
jQuery1.2.cheatsheet.v1.0
jQuery1.2.cheatsheet.v1.0jQuery1.2.cheatsheet.v1.0
jQuery1.2.cheatsheet.v1.0guest644d1d
 
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative LanguagesJavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative LanguagesStephen Chin
 
Using Templates to Achieve Awesomer Architecture
Using Templates to Achieve Awesomer ArchitectureUsing Templates to Achieve Awesomer Architecture
Using Templates to Achieve Awesomer ArchitectureGarann Means
 
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen ChinHacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chinjaxconf
 
JSON and Swift, Still A Better Love Story Than Twilight
JSON and Swift, Still A Better Love Story Than TwilightJSON and Swift, Still A Better Love Story Than Twilight
JSON and Swift, Still A Better Love Story Than TwilightDonny Wals
 
JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011Stephen Chin
 
GeeCON Prague 2014 - Metaprogramming with Groovy
GeeCON Prague 2014 - Metaprogramming with GroovyGeeCON Prague 2014 - Metaprogramming with Groovy
GeeCON Prague 2014 - Metaprogramming with GroovyIván López Martín
 
Keeping It Small with Slim
Keeping It Small with SlimKeeping It Small with Slim
Keeping It Small with SlimRaven Tools
 
Cleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQueryCleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQueryRebecca Murphey
 
Thoughts on MongoDB Analytics
Thoughts on MongoDB AnalyticsThoughts on MongoDB Analytics
Thoughts on MongoDB Analyticsrogerbodamer
 

Was ist angesagt? (12)

The Ring programming language version 1.8 book - Part 57 of 202
The Ring programming language version 1.8 book - Part 57 of 202The Ring programming language version 1.8 book - Part 57 of 202
The Ring programming language version 1.8 book - Part 57 of 202
 
jQuery1.2.cheatsheet.v1.0
jQuery1.2.cheatsheet.v1.0jQuery1.2.cheatsheet.v1.0
jQuery1.2.cheatsheet.v1.0
 
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative LanguagesJavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
 
ddd+scala
ddd+scaladdd+scala
ddd+scala
 
Using Templates to Achieve Awesomer Architecture
Using Templates to Achieve Awesomer ArchitectureUsing Templates to Achieve Awesomer Architecture
Using Templates to Achieve Awesomer Architecture
 
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen ChinHacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
 
JSON and Swift, Still A Better Love Story Than Twilight
JSON and Swift, Still A Better Love Story Than TwilightJSON and Swift, Still A Better Love Story Than Twilight
JSON and Swift, Still A Better Love Story Than Twilight
 
JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011
 
GeeCON Prague 2014 - Metaprogramming with Groovy
GeeCON Prague 2014 - Metaprogramming with GroovyGeeCON Prague 2014 - Metaprogramming with Groovy
GeeCON Prague 2014 - Metaprogramming with Groovy
 
Keeping It Small with Slim
Keeping It Small with SlimKeeping It Small with Slim
Keeping It Small with Slim
 
Cleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQueryCleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQuery
 
Thoughts on MongoDB Analytics
Thoughts on MongoDB AnalyticsThoughts on MongoDB Analytics
Thoughts on MongoDB Analytics
 

Andere mochten auch

Train Your Brain Dr. Farhana Shaheen
Train Your Brain Dr. Farhana ShaheenTrain Your Brain Dr. Farhana Shaheen
Train Your Brain Dr. Farhana ShaheenFarhana Shaheen
 
Derivatives in graphing-dfs
Derivatives in graphing-dfsDerivatives in graphing-dfs
Derivatives in graphing-dfsFarhana Shaheen
 
Three dimensional space dfs-new
Three dimensional space  dfs-newThree dimensional space  dfs-new
Three dimensional space dfs-newFarhana Shaheen
 
221 Radcliffe Church Brochure
221 Radcliffe Church Brochure221 Radcliffe Church Brochure
221 Radcliffe Church Brochurejroedig
 
общая
общаяобщая
общаяskypegas
 
A Brain's Plea by Dr. Farhana Shaheen
A Brain's Plea by Dr. Farhana ShaheenA Brain's Plea by Dr. Farhana Shaheen
A Brain's Plea by Dr. Farhana ShaheenFarhana Shaheen
 
Tyler Butler
Tyler ButlerTyler Butler
Tyler Butleradubose
 
Семинар "Аудит сайта презентация" компания ИМТ FriendsTime
Семинар "Аудит сайта презентация" компания ИМТ FriendsTimeСеминар "Аудит сайта презентация" компания ИМТ FriendsTime
Семинар "Аудит сайта презентация" компания ИМТ FriendsTimeОлександр Мілютін
 
Amber's evaluation
Amber's evaluationAmber's evaluation
Amber's evaluationAmber_
 
Morgan Phillips
Morgan PhillipsMorgan Phillips
Morgan Phillipsadubose
 
How to sell 3 million widgets, guaranteed!
How to sell 3 million widgets, guaranteed!How to sell 3 million widgets, guaranteed!
How to sell 3 million widgets, guaranteed!Jaimes Nel
 
All analysis
All analysisAll analysis
All analysisAmber_
 
Module13 theories
Module13 theoriesModule13 theories
Module13 theoriesRay Altmann
 
Trabajo practico 12 segunda parte
Trabajo practico 12 segunda parteTrabajo practico 12 segunda parte
Trabajo practico 12 segunda parteleandro96
 
Annie Savant
Annie Savant Annie Savant
Annie Savant adubose
 
Avery Powers
Avery PowersAvery Powers
Avery Powersadubose
 
Freelance Translator 2.0
Freelance Translator 2.0Freelance Translator 2.0
Freelance Translator 2.0Mike Sekine
 
Callie Hodge
Callie HodgeCallie Hodge
Callie Hodgeadubose
 

Andere mochten auch (20)

Train Your Brain Dr. Farhana Shaheen
Train Your Brain Dr. Farhana ShaheenTrain Your Brain Dr. Farhana Shaheen
Train Your Brain Dr. Farhana Shaheen
 
Derivatives in graphing-dfs
Derivatives in graphing-dfsDerivatives in graphing-dfs
Derivatives in graphing-dfs
 
Three dimensional space dfs-new
Three dimensional space  dfs-newThree dimensional space  dfs-new
Three dimensional space dfs-new
 
Beauty of numbers
Beauty of numbersBeauty of numbers
Beauty of numbers
 
221 Radcliffe Church Brochure
221 Radcliffe Church Brochure221 Radcliffe Church Brochure
221 Radcliffe Church Brochure
 
общая
общаяобщая
общая
 
Project work
Project workProject work
Project work
 
A Brain's Plea by Dr. Farhana Shaheen
A Brain's Plea by Dr. Farhana ShaheenA Brain's Plea by Dr. Farhana Shaheen
A Brain's Plea by Dr. Farhana Shaheen
 
Tyler Butler
Tyler ButlerTyler Butler
Tyler Butler
 
Семинар "Аудит сайта презентация" компания ИМТ FriendsTime
Семинар "Аудит сайта презентация" компания ИМТ FriendsTimeСеминар "Аудит сайта презентация" компания ИМТ FriendsTime
Семинар "Аудит сайта презентация" компания ИМТ FriendsTime
 
Amber's evaluation
Amber's evaluationAmber's evaluation
Amber's evaluation
 
Morgan Phillips
Morgan PhillipsMorgan Phillips
Morgan Phillips
 
How to sell 3 million widgets, guaranteed!
How to sell 3 million widgets, guaranteed!How to sell 3 million widgets, guaranteed!
How to sell 3 million widgets, guaranteed!
 
All analysis
All analysisAll analysis
All analysis
 
Module13 theories
Module13 theoriesModule13 theories
Module13 theories
 
Trabajo practico 12 segunda parte
Trabajo practico 12 segunda parteTrabajo practico 12 segunda parte
Trabajo practico 12 segunda parte
 
Annie Savant
Annie Savant Annie Savant
Annie Savant
 
Avery Powers
Avery PowersAvery Powers
Avery Powers
 
Freelance Translator 2.0
Freelance Translator 2.0Freelance Translator 2.0
Freelance Translator 2.0
 
Callie Hodge
Callie HodgeCallie Hodge
Callie Hodge
 

Ähnlich wie enchant js workshop on Calpoly

The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 47 of 180
The Ring programming language version 1.5.1 book - Part 47 of 180The Ring programming language version 1.5.1 book - Part 47 of 180
The Ring programming language version 1.5.1 book - Part 47 of 180Mahmoud Samir Fayed
 
C++ game development with oxygine
C++ game development with oxygineC++ game development with oxygine
C++ game development with oxyginecorehard_by
 
The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 55 of 202
The Ring programming language version 1.8 book - Part 55 of 202The Ring programming language version 1.8 book - Part 55 of 202
The Ring programming language version 1.8 book - Part 55 of 202Mahmoud Samir Fayed
 
Reactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bisReactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bisDroidConTLV
 
JavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScriptJavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScriptLaurence Svekis ✔
 
The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88Mahmoud Samir Fayed
 
Shibuya.js Lightning Talks
Shibuya.js Lightning TalksShibuya.js Lightning Talks
Shibuya.js Lightning Talksjeresig
 
The Ring programming language version 1.5.2 book - Part 48 of 181
The Ring programming language version 1.5.2 book - Part 48 of 181The Ring programming language version 1.5.2 book - Part 48 of 181
The Ring programming language version 1.5.2 book - Part 48 of 181Mahmoud Samir Fayed
 
JavaScript Advanced - Useful methods to power up your code
JavaScript Advanced - Useful methods to power up your codeJavaScript Advanced - Useful methods to power up your code
JavaScript Advanced - Useful methods to power up your codeLaurence Svekis ✔
 
I am sorry but my major does not cover programming in depth (ICT) an.pdf
I am sorry but my major does not cover programming in depth (ICT) an.pdfI am sorry but my major does not cover programming in depth (ICT) an.pdf
I am sorry but my major does not cover programming in depth (ICT) an.pdfseamusschwaabl99557
 
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup itPROIDEA
 
여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala Language여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala LanguageAshal aka JOKER
 
Famo.us: From Zero to UI
Famo.us: From Zero to UIFamo.us: From Zero to UI
Famo.us: From Zero to UItimjchin
 
The Ring programming language version 1.5.2 book - Part 14 of 181
The Ring programming language version 1.5.2 book - Part 14 of 181The Ring programming language version 1.5.2 book - Part 14 of 181
The Ring programming language version 1.5.2 book - Part 14 of 181Mahmoud Samir Fayed
 

Ähnlich wie enchant js workshop on Calpoly (20)

The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196
 
CreateJS
CreateJSCreateJS
CreateJS
 
The Ring programming language version 1.5.1 book - Part 47 of 180
The Ring programming language version 1.5.1 book - Part 47 of 180The Ring programming language version 1.5.1 book - Part 47 of 180
The Ring programming language version 1.5.1 book - Part 47 of 180
 
C++ game development with oxygine
C++ game development with oxygineC++ game development with oxygine
C++ game development with oxygine
 
Game dev 101 part 3
Game dev 101 part 3Game dev 101 part 3
Game dev 101 part 3
 
The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185
 
Game age ppt
Game age pptGame age ppt
Game age ppt
 
The Ring programming language version 1.8 book - Part 55 of 202
The Ring programming language version 1.8 book - Part 55 of 202The Ring programming language version 1.8 book - Part 55 of 202
The Ring programming language version 1.8 book - Part 55 of 202
 
Reactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bisReactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bis
 
JavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScriptJavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScript
 
JavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talkJavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talk
 
The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88
 
Shibuya.js Lightning Talks
Shibuya.js Lightning TalksShibuya.js Lightning Talks
Shibuya.js Lightning Talks
 
The Ring programming language version 1.5.2 book - Part 48 of 181
The Ring programming language version 1.5.2 book - Part 48 of 181The Ring programming language version 1.5.2 book - Part 48 of 181
The Ring programming language version 1.5.2 book - Part 48 of 181
 
JavaScript Advanced - Useful methods to power up your code
JavaScript Advanced - Useful methods to power up your codeJavaScript Advanced - Useful methods to power up your code
JavaScript Advanced - Useful methods to power up your code
 
I am sorry but my major does not cover programming in depth (ICT) an.pdf
I am sorry but my major does not cover programming in depth (ICT) an.pdfI am sorry but my major does not cover programming in depth (ICT) an.pdf
I am sorry but my major does not cover programming in depth (ICT) an.pdf
 
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it
 
여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala Language여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala Language
 
Famo.us: From Zero to UI
Famo.us: From Zero to UIFamo.us: From Zero to UI
Famo.us: From Zero to UI
 
The Ring programming language version 1.5.2 book - Part 14 of 181
The Ring programming language version 1.5.2 book - Part 14 of 181The Ring programming language version 1.5.2 book - Part 14 of 181
The Ring programming language version 1.5.2 book - Part 14 of 181
 

Mehr von Ryo Shimizu

Chaienr meetup#2 UEI Deep Station ; A GUI for Deep learning
Chaienr meetup#2 UEI Deep Station ; A GUI for Deep learningChaienr meetup#2 UEI Deep Station ; A GUI for Deep learning
Chaienr meetup#2 UEI Deep Station ; A GUI for Deep learningRyo Shimizu
 
Introduction to DEEPstation the GUI Deep learning environment for chainer
Introduction to DEEPstation the GUI Deep learning environment for chainerIntroduction to DEEPstation the GUI Deep learning environment for chainer
Introduction to DEEPstation the GUI Deep learning environment for chainerRyo Shimizu
 
enchantMOON presentation @ Mobile IT Asia & ABC 2013 Spring
enchantMOON presentation @ Mobile IT Asia & ABC 2013 SpringenchantMOON presentation @ Mobile IT Asia & ABC 2013 Spring
enchantMOON presentation @ Mobile IT Asia & ABC 2013 SpringRyo Shimizu
 
Beginning gl.enchant
Beginning gl.enchantBeginning gl.enchant
Beginning gl.enchantRyo Shimizu
 
enchant.js meetup Tokyo vol.2 Roadmap of enchant.js
enchant.js meetup Tokyo vol.2 Roadmap of enchant.jsenchant.js meetup Tokyo vol.2 Roadmap of enchant.js
enchant.js meetup Tokyo vol.2 Roadmap of enchant.jsRyo Shimizu
 
enchant.js meetup Tokyo vol.2 Tutorial
enchant.js meetup Tokyo vol.2 Tutorialenchant.js meetup Tokyo vol.2 Tutorial
enchant.js meetup Tokyo vol.2 TutorialRyo Shimizu
 
9leap Game Programming Camp @Tokyo
9leap Game Programming Camp @Tokyo9leap Game Programming Camp @Tokyo
9leap Game Programming Camp @TokyoRyo Shimizu
 

Mehr von Ryo Shimizu (7)

Chaienr meetup#2 UEI Deep Station ; A GUI for Deep learning
Chaienr meetup#2 UEI Deep Station ; A GUI for Deep learningChaienr meetup#2 UEI Deep Station ; A GUI for Deep learning
Chaienr meetup#2 UEI Deep Station ; A GUI for Deep learning
 
Introduction to DEEPstation the GUI Deep learning environment for chainer
Introduction to DEEPstation the GUI Deep learning environment for chainerIntroduction to DEEPstation the GUI Deep learning environment for chainer
Introduction to DEEPstation the GUI Deep learning environment for chainer
 
enchantMOON presentation @ Mobile IT Asia & ABC 2013 Spring
enchantMOON presentation @ Mobile IT Asia & ABC 2013 SpringenchantMOON presentation @ Mobile IT Asia & ABC 2013 Spring
enchantMOON presentation @ Mobile IT Asia & ABC 2013 Spring
 
Beginning gl.enchant
Beginning gl.enchantBeginning gl.enchant
Beginning gl.enchant
 
enchant.js meetup Tokyo vol.2 Roadmap of enchant.js
enchant.js meetup Tokyo vol.2 Roadmap of enchant.jsenchant.js meetup Tokyo vol.2 Roadmap of enchant.js
enchant.js meetup Tokyo vol.2 Roadmap of enchant.js
 
enchant.js meetup Tokyo vol.2 Tutorial
enchant.js meetup Tokyo vol.2 Tutorialenchant.js meetup Tokyo vol.2 Tutorial
enchant.js meetup Tokyo vol.2 Tutorial
 
9leap Game Programming Camp @Tokyo
9leap Game Programming Camp @Tokyo9leap Game Programming Camp @Tokyo
9leap Game Programming Camp @Tokyo
 

enchant js workshop on Calpoly

  • 1.
  • 3. Company Profile Start : August 8th, 2003 HQ : Bunkyo-ku Yushima 3-1-3 Employee: 130 peoples Legal Capital: 35,000,000 yen
  • 4.
  • 5.
  • 6.
  • 7.
  • 9. Features Distributed under MIT/GPL3, Open source software Class base programming TRUE cross platform Many plug-ins
  • 10. Why is it open source? Good for debugging and tuning Learn once, use eternally HTML5 can’t hide source codes Open is the best way to polish the library
  • 11. Why HTML5? Chrome Android Safari iPhone Windows Windows8 Phone7
  • 12. Feature of HTML5 Cross platform (lie) Each browser compete to improve performance You can get whole source code under GPL(important) HTML5, actually work as OS
  • 13. HTML5 is new era of OS HTML5 Apps Application Web Browser OS OS BIOS BIOS Hardware Hardware Legacy OS HTML5 era
  • 14. HTML5 and JavaScript JavaScript come from functional language “scheme” Special and strange “prototype based” OOP. You can manipulate elements of HTML5 thru DOM Super powerful, but not easy to use => You need enchant.js
  • 15. Let’s try enchant.js Basics of object oriented game programming
  • 17. Extract and check it out Open this folder
  • 18. Checkout hellobear Open this
  • 19. Check out main.js This is it!
  • 20. Also you can use code.9leap.net You can also code online in browser No need to download anything
  • 21. Four foundation classes Sprite Label SCORE:400 Game Scene That’s all! Easy!
  • 22. Basics of enchant.js enchant(); window.onload=function(){ game = new Game(); // // Prepare game assets here // game.onload = function(){ // // Initialize game objects here // } game.start(); }
  • 23. Basics of enchant.js enchant(); window.onload=function(){ game = new Game(); game.fps = 30; game.onload = function(){ hello = new Label(“Hello,Bear”); Hello,Bear hello.x=10; hello.y=150; game.rootScene.addChild(hello); } game.start(); }
  • 24. Basics of enchant.js Sprite Label SCORE:400 game.rootScene When you addChild to game.rootScene, the entity turn to visible
  • 25. Change position of label enchant(); window.onload=function(){ game = new Game(); game.fps = 30; game.onload = function(){ Hello,Bear hello = new Label(“Hello,Bear”); hello.x=10; hello.y=10; Change this number game.rootScene.addChild(hello); } game.start(); }
  • 26. Classes and Objects Hello,Bear This is “hello” object of Label class Be careful! Class and object are different
  • 27. Class and object Class : Man Object :Bill Gates Hello,Bear ↓Name of object hello = new Label(“Hello,Bear”); ↑Name of class new is an operator to create object from class constructor Every object is created by class constructor
  • 28. Class and Objects hello = new Label(“Hello,Bear”); Please create object named “hello” of Label class. And initialize it as “Hello,Bear”
  • 29. Manipulate property hello Hello,Bear x y text This is property hello.x = 10; // X coordinate of hello hello.y = 200; //Y coordinate of hello hello.text = “Hello,Bear”; // text of hello
  • 30. Change text of label enchant(); window.onload=function(){ game = new Game(); game.onload = function(){ hello = new Label(“Hello,Bear”); Hello,Bear hello.x=10; hello.y=200; hello.text=”Hello,Calpoly”; Change text game.rootScene.addChild(hello); } game.start(); } dot can access to the property of objects
  • 31. Label changes to button enchant(); window.onload=function(){ game = new Game(); game.onload = function(){ Add this line hello = new Label(“Hello,Bear”); hello.x=10; Hello,Bear hello.y=200; hello.addEventListener(‘touchend’,function() { this.text=”Hello,Calpoly”;}); game.rootScene.addChild(hello); } game.start(); } You can add event listener to label object
  • 32. What is event? Touched!! hello Hello,Bear Time elapsed! He dragged me! Variety of events will happen to objects.
  • 33. What is event? hello Touched ! Hello,Bear ↓Name of event hello.addEventListener(‘touchend‘, function(){ this.text = “Hello,Calpoly”; } ); ↑This is event listener
  • 34. Variety of events touchend hello Hello,Bear touchstart enterframe touchmove
  • 35. Variety of events touchend hello Hello,Bear touchstart enterframe These are the touchmove essential ones
  • 36. Use enterframe event enchant(); window.onload=function(){ game = new Game(); game.onload = function(){ Change like this! hello = new Label(“Hello,Bear”); hello.x=10; Hello,Bear hello.y=200; hello.addEventListener(‘enterframe’,function(){ this.x+=1;}); game.rootScene.addChild(hello); } game.start(); } What happens when using enterframe?
  • 37. Congratulations! You became a freshmen of enchant.js!
  • 38. Using Sprites Sprites are superhero of game programming
  • 39. By the way, What is “sprites”? That’s not a soda
  • 40. What is sprites? Sprites means fairies fly on the screen
  • 41. Try summon a sprite! enchant(); CAUTION! preload must come window.onload=function(){ before onload game = new Game(); game.preload(‘chara1.png’); game.onload = function(){ bear = new Sprite(32,32); bear.image = game.assets[‘chara1.png’]; game.rootScene.addChild(bear); } game.start(); }
  • 42. Sprites and enterframe enchant(); window.onload=function(){ game = new Game(); game.preload(‘chara1.png’); game.onload = function(){ bear = new Sprite(32,32); bear.image = game.assets[‘chara1.png’]; bear.addEventListener(‘enterframe’, function(){ this.x+=1; Add event listener of } enterframe events ); game.rootScene.addChild(bear); } game.start(); }
  • 43. Create a sprite bear ↓Name of object bear = new Sprite(32,32); ↑Name of class new is an operator to create object from class constructor
  • 44. Geometry of sprites bear bear = new Sprite(32,32); 32 32 Pass a geometry when sprites is created
  • 45. Property of sprites bear scaleX age scaleY x y frame Change some property of sprites!
  • 46. demo
  • 47. What’s a frame property? Bear 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 The frame numbering from top-left
  • 48. Hit the bear enchant(); window.onload=function(){ game = new Game(); game.preload(‘chara1.png’); game.onload = function(){ bear = new Sprite(32,32); bear.image = game.assets[‘chara1.png’]; bear.addEventListener(‘touchend’, function(){ this.frame=3; When you touch the bear, } change frame to 3 ); game.rootScene.addChild(bear); } game.start(); }
  • 49. Congratulations! You became a beginner of enchant.js!
  • 50. The first step of Game designing
  • 51. Process of game development 1.Choose the theme of the game 2.Decide the minimum spec of the game 3.Make it 4.Play it 5.Consider about it, and repeat from step 2.
  • 52. How to choose theme? Easy to imagine the programming code Don’t be afraid to become a copycat! It’s good way to start Code before consider, and change on code Add new feature, and delete actual feature Change graphics, story, and detail! Important thing is “You aren’t genius(right now)”
  • 53. Nobody is a great creator, Just genius copycat
  • 55. After you choose the theme Then, draw a sketch of ideas
  • 56. Tools for sketch Moleskine Drawing papers for kids Signature pens iPad Plane note
  • 57. Example of Sketch Hit Apple Run a way Hit the bear I use ishodo Save apples available in AppStore
  • 58. Polish your sketch When all apples are eaten by bears, then the game is over Bears appear How many bears from the sides can you hit? Polish your sketch,and clarify the ideas
  • 59. Polish your sketch When all apples are eaten by bears, then game is over Game over Basic behavior Score Bears appear How many bears from sides can you hit? Decide the 3 essentials of game designing
  • 60. Check out materials chara1.png icon0.gif Images folder includes many royalty free images you can use for enchant.js
  • 61. Be careful about geometry chara1.png(32x32) icon0.gif(16x16) Each image file has its own geometry.
  • 62. Master of classes This’s a secret weapon of programming ninja
  • 63. Find classes from sketch Enemy Items The characters and items will become a class
  • 64. Create your own class Class of Bear Bear = Class.create(Sprite,{ initialize:function(){ Sprite.call(this,32,32); this.image = game.assets[‘chara1.png’]; } }); Class can inherit from actual enchant.js classes.Usually inherit form Sprite class
  • 65. Create your own class Inherit from Sprite class ↓Name of your own class Bear = Class.create(Sprite,{ initialize:function(){ Sprite.call(this,32,32); this.image = game.assets[‘chara1.png’]; } }); ↑Constructor of Bear class
  • 66. Using custom class enchant(); window.onload=function(){ game = new Game(); You can create object in same style game.preload(‘chara1.png’); game.onload = function(){ bear = new Bear(); game.rootScene.addChild(bear); } game.start(); } It is very easy and useful!
  • 67. Event definition of class Class of Bear Bear = Class.create(Sprite,{ initialize:function(){ Sprite.call(this,32,32); this.image = game.assets[‘chara1.png’]; }, onenterframe:function(){ this.x+=1; } on + name of event will work as a event listener. }); It’s easy to code any event listener defined in class definition.
  • 68. Mr. Bear hit and cry Bear = Class.create(Sprite,{ initialize:function(){ Sprite.call(this,32,32); this.image = game.assets[‘chara1.png’]; }, onenterframe:function(){ this.x+=1; }, ontouchend:function(){ this.frame=3; } });
  • 70. Classes of sketch Bear class Item class Bears appear and then hit them
  • 71. Tips: Random numbers ↓When I need 0 - 9 random number n = Math.floor(Math.random()*10) When you set 10, you get 0-9↑
  • 72. Tips: Remove Sprites game.rootScene.removeChild(bear) The object you wants to remove from scene↑
  • 73. You can download this slide Check out our facebook page