Getting Started with PhaserJs and TypeScript

Curious about building 2D games with web skills? In this post, we’ll explore tools and patterns to use PhaserJs and JavaScript to make engaging 2D games. We’ll cover tools to make experiences with our favorite language: TypeScript.

Reference links

Related links

Happy New Years: Excitement for 2022!

Happy New Year friends! On this beautiful New Year’s day, I wanted to reflect upon some lessons from 2021 and learning opportunities for 2022. In 2022, we will continue to focus on ideas that help students love learning through exploration, making, and tinkering. As parents, we dream about helping our kids become the best version of themselves. It’s been fun to see how “maker education” and project based learning at home has encouraged growth in families.

Lessons from 2021 and learning at home

At this point, I would like to give a huge shout out to our teachers and professors who have served through this pandemic. We are so very thankful for the ways that you’ve invested in our kids and helped them to grow. They have helped our family adapt to learning from home for a significant portion of the year. Our kids did return to a traditional public school setting in the fall. We’re thankful for all the efforts of the staff and teachers to mitigate the concerns of COVID while fostering a positive learning environment.

At the Rosario home, I have tried to pay attention to hot spots of motivation and curiosity. If the kids start tinkering on the piano trying to figure out the Avenger’s theme, I’ve tried to make myself more available to encourage their musical exploration. My kids still enjoy creating their own music with Bandlab. We’ve also encouraged a good amount of traditional art with the kids. With the kid’s interest in Pokemon and Anime, they’ve become curious about drawing in this style. It’s been amazing to see the lessons they’ve learned through various drawing teachers on YouTube. Given that dad works as a software developer, it’s wonderful to see the kids engage in coding and building software. In future blog posts, we look forward to unpacking some of our more fruitful Scratch and Unity 3d tools. If your middle schooler or teen shows interest in video game development, the team at Unity 3D have continued to evolve their learning platform to be relevant to student creators. As a big kid myself, I’m still glad that our family enjoys Lego building together.

Related Posts

Trends to watch for 2022?

  • Space and wonder: I personally believe our SpaceX and NASA programs give our kids a sense of vision and potential. Over the Christmas break, the kids and I took in documentaries from NOVA on the Mars Perseverance rover and related missions. It’s so amazing the progress of our space programs in the past year. I do feel that the exploration of our universe and space travel helps keep a sense of awe and wonder about our world. It’s good the meditate upon how wonderfully complex and beautiful creation is.

  • Virtual Reality & Augmented Reality: In 2022, I look forward to exploring apps, trends, and tools that empower students to create XR experiences. I still continue to love the XR platform used for teaching and learning. It’s been fun to see the kids explore the International Space station in VR. In yet another experience, the Obama family unpacks the history of the white house in VR. I love that platforms like CoSpaces have started to empower young makers to build VR experiences with block coding. ( cospaces.io/edu/ )

  • Robots: My oldest son has expressed tons of interest in deep sea exploration. I have a feeling I’m going to start learning about playful games and simulation experiences to help him explore this. He’s found a very cool game called Subnautica that explores some of these ideas. In Subnautica, you are trying to survive an alien deep sea world using your resourcefulness and exploration skills. I do think that sea exploration using robots is really interesting. We look forward to explore trends and tools related to DIY IoT and robotics.

We are very thankful for our readers. Please know we pray for the very best for you and your family in 2022! If you have some cool projects that you’re doing with your kids, please drop us a line. We’d love to hear from you.

Make Unity 3D Games To Amaze Your Friends!

Hello makers! Like many in the computer industry, I had the dream of learning how to build video games. When the math class seemed difficult, I found inspiration to move forward since I had strong motivation to learn how to build video games someday! Unity 3D and their amazing community of game creators have created powerful opportunities for curious makers to build games that amaze your friends. From my first encounters with Unity 3D, I felt that they have done a good job of educating their users. In the past few years, I greatly admire the new strategies they have created to engage learners in their tools.

The idea of “modding” has engaged generations of gamers. (Thank you Minecraft and Roblox!). We’ve become used to the idea that games setup a robust environment where you can build big and crazy things. In lots of games, you’re placed into a position of saving the world. (i.e. you’ve been given a motivation to do something bigger than yourself that’s fun). The Unity 3D “microgame” tutorials provide students with the basic shell of well crafted game experiences. In this context, the Unity 3D team have created tutorial experience to gently guide learners through the Unity 3D environment, programming concepts, and their system for building Unity “lego” blocks. In this experience, you get to select your adventure. Do you want to build your own Lego game? Do you want to make your own version of Super Mario brothers? You can challenge yourself by building a cool kart racing game. In the videos below, I wanted to give a shout out to the Lego action “game jam” and the Kart Racing tutorials.

I always enjoy learning new Unity tricks from other developers. It has been fun to pick apart aspects of these games. In the newest Kart racing tutorials, you can also learn about the newer machine learning capabilities of Unity 3D. ( ML Agents ) It kind of blows my mind that these ideas can now appear in tutorials for early stage coders. As I’ve tested these experiences with my kids, they have enjoyed creating novel kart racing experiences and environments. My older son has enjoyed customizing his own shooter game.

Make sure to check out Unity 3D’s Learning index here: https://learn.unity.com/

If you make something cool, please share a link below in the comments!

Your First Game Jam: LEGO Ideas Edition

In this edition, you will discover how to build a quest in your LEGO® Microgame using the newly released “Speak” and “Counter” LEGO® Behaviour Bricks. Learn step-by-step with a special guest from the LEGO® Games division and our Unity team to create your own unique, shareable game.

Build Your Own Karting Microgame

It’s never been easier to start creating with Unity. From download to Microgame selection, to modding, playing, and sharing your first playable game, this video shows you what you can accomplish in as little as 30 minutes!

For detailed step-by-step Unity tutorials, check out

The Official Guide to Your First Day in Unity playlist.

Related Posts

Our Experiments To Improve Our Home Schooling Culture

Hello, friends. As our family tries to adapt to the new normal and the COVID pandemic, I wanted to start reflecting on how our family plans to promote a learning culture. Over the years, InspiredToEducate.NET has taken on the mission of helping students love learning through making, tinkering, and engineering. As working professionals, Sarah and I want to make sure we’re still providing the best learning environment for our kids. Like many other families, we have decided to home school/virtual school our kids due to health risks. To serve other parents struggling with these transitions, I wanted to share some the ideas we’ve researched. Make sure to check out the blog posts at the end of this article.

PRO’s of virtual school + home school approach

  • Personalized learning: In general, Sarah and I find the concept of personalized learning attractive. Every student has different strengths and weaknesses. The asynchronous nature of online learning can provide the student to learn at their own pace. In many cases, lectures will be assigned in recorded in video format. If you don’t understand something, you can always hit the pause button and rewind. Does your student need more context on a topic? Students can jump on YouTube and find a Khan academy video that probably complements the class material.

  • Gaining key career skills: It’s interesting to consider the 21st century career skills our kids will explore with online virtual school. In the spring, I greatly enjoyed seeing my son prepare a pretty awesome history presentation that he shared with his class. He was very intentional about the visual look of the slides. I also admired how he practiced his presentation for clarity. I know he aspires to run his own YouTube channel some day. So, he’s getting some pretty cool practice through this online learning experience. It’s important to reflect upon the long term benefits of the “online” learning modality.

  • Exploring game based learning, simulations and project based learning: Some online teachers have started leaning into the benefits of a flipped classroom model. Under this model, students take in videos/lectures as homework assignments. When the student and teacher have “face to face” time, they can leverage their interactions to clarify knowledge and explore. Some teachers have exploited learning games or hands-on learning projects to deepen knowledge.

Our honest pain points with home schooling/virtual schooling

As our family has moved to online learning out of necessity, I have gained a great respect for families who have decided to home school their kids outside the scope of the pandemic. The self discipline and habits required to make a great learning environment at home do not come naturally. It takes a lot of work.

In our family in the Spring, if we didn’t create a good plan for the week, we could easily miss assignments or support time for our kids. Like many families, Sarah and I both work full time jobs with busy calendars. It’s not trivial to keep a mode of “focused” work in a professional context while supporting our kids. I do want to thank my niece Rosemary for helping us in the Spring. While living with us during the virus outbreak, she has been very helpful supporting our kids in school work and helping them stay focused and organized. Our appreciation for her can not be understated.

As we reflect on our Spring adventures with home schooling/online learning, Sarah and I know we have to up our game plan for the fall. Here’s our plan in progress.

Themes of our learning culture plan

  • Becoming a better Peacher(Parent/Teacher/Project manager): As we think through the fall, I know that Sarah and I will need to schedule regular time to answer questions and times for regular teacher communication. In some of our previous explorations of maker mindset in teaching, we found many good themes that will become helpful. Teaching isn’t always about being the fountain of knowledge and sharing it. Teaching sometimes looks a bit more like project management where we’re teaching students how to break big problems into small problems. We teach students how to ask better questions. We connect students with the key search tools they need to discover their own knowledge. We meet students where they’re at.

  • Family weekly planning: From looking at blogs on virtual schools, it’s common for these schools to provide assignment tracking and organization tools. I think it will be important to find these tools and organize them into a system. I hope that we can take this a step forward though. At my work, we chunk our work into two week cycles or plans. We start each cycle with a meeting called “sprint planning.” This enables us to find the most valuable and easy work we can be doing to help the project move forward and meet deadlines. I think Sarah and I will come up with a family version of this meeting us. We’ll probably use some tools like MindMeister, Google Documents, or Trello to help us stay organized and monitor work.

Here’s a cool video exploring the idea of family weekly planning using Agile ideas …

If you need an agenda for this kind of meeting, check out our post here.

  • Inspect and adapt: We know that we will not make a perfect plan. With that in mind, we plan to have a meeting weekly to see how we’re doing as a family. What’s working well? What are common road blocks? How can we get better? What resources can we leverage outside our family to promote a peaceful, prayerful, healthy and a happy family?

  • Creating zones of focus: Sarah and I have a good degree of schedule flexibility. We’re very fortunate to have this situation. We’re thinking through how we can rigorously leverage our calendars to weave school support into lives while meeting the requirements of our jobs. In brutal honesty, this will be crazy hard.

  • Elements of a good weekly schedule

    • Schedule prayer time
    • Schedule breaks and play time
    • Try to keep a normal work schedule
    • Schedule time for music practice
    • Keep a good backlog of projects/hobby projects
    • Schedule time for socially distance sports or outdoor time
    • Schedule time-box for reading
  • Seek out index of good support/course videos: We already love resources like Khan academy, Coursera, prodigygame.com, and Tynker.com. What other open courseware tools are available to families at low cost? Check out https://www.lifehack.org/articles/money/25-killer-sites-for-free-online-education.html

  • Experiment with time management patterns: Adding Pomodoro to my day: I’m thinking about trying out Pomodoro in my professional work. ( https://en.wikipedia.org/wiki/Pomodoro_Technique ) In this work pattern, you try to enter a zone of focused work for 25 minutes. After the 25 minutes, you take a break for 5 minutes. In those 5 minutes, it may be possible to do a check-in on kids. We’ll let you know if this works or not.

Interested in project based learning for families? Interested in sharing ideas for helping your kids love learning by making cool stuff? We want to welcome you to our new InspiredToEducate.NET facebook group. In this community, we hope learn and support each other as we promote learning cultures in our families.

Join our community on Creative Learning Projects on Facebook!

Related Posts

References

  • https://www.baystateparent.com/news/20200416/homeschooling-101-tips-for-parents-adjusting-virtual-learning-with-kids
  • https://www.greatschools.org/gk/articles/virtual-schools/
  • https://www.connectionsacademy.com/support/resources/article/virtual-school-and-working-parents-ways-to-make-it-work

3D Modeling for Minecraft using TinkerCad – Online Meetup June 20th

As adult learners or students, we’re all looking for new fruitful activities that we can share with our friends and family. In this hands-on workshop, we’re partnering with Google Developer Group of Central Florida to learn how you can build 3D stuff for a 3D printer, a Unity game, and Minecraft!

  • WHO: Families, developers, tinkerers
  • WHERE: Online Google Meet
  • WHEN: June 20th at 1pm

In this workshop, we’ll build amazing stuff in Minecraft that will WOW your friends! You’ll learn the basics of 3D modeling using TinkerCAD, a free tool for modeling! You’ll have fun constructing 3D worlds and playing them in Minecraft. Using TinkerCAD, we’ll convert your 3D worlds into Minecraft schematics that can be imported using WorldEdit.

For families, we hope that you consider bringing your kids with you and learning together.

For developers, we’ll cover a few API’s to build 3D models using JavaScript too.

You’ll need to register for a free account on TinkerCad. You’ll also need to obtain the Minecraft Java Edition. You may want to install WorldEdit ahead of time too: Setup WorldEdit on Minecraft

To join the video meeting, click this link: Meeting Link on Google Meet

I hope that you can join us!

Related posts:

7 Creative DIY Project Ideas For Family Fun

Like many parents, my wife and I seek out activities that have a fun factor while we learn small lessons about math, science, art, or crafting. It’s fun to find activities that help avoid the default desire for screen time. I started putting together a plan for our kids over the next few weeks. Like many makers, I enjoy checking out new projects ideas on Instructables.com. If you haven’t checked out Instructables, I am certain that you can find a project for you there! I thought I’d share seven projects that looked cool.

pvc tent
PVC Tent:

In our house, the kids really enjoy building forts. I really like the idea of using PVC to frame the structure of the fort. It looks like a pretty cheap build. Honestly, building forts with cardboard works just fine too. Big box forts can keep our kids playing for hours!

lego cross bow
Lego Crossbow:
Sometimes, kids enjoy being little warriors. This looked like a fun build for fans of Lego technics. The build reminds me of the activities from the book “Weapons of Mini-Destruction.”

lego chess
Lego chess:
In general, I think we might start exploring the idea of building board games using Legos. I got this concept after seeing this simple chess set. It has been fun starting to teach chess to the kids too.

lamp
DIY Cardboard Lamp:
This just looks very cool. It might be fun to do a 3D printing twist on twist on this project too!

board game
DIY Board Game:
Speaking of board games again, I really appreciated this post on building board games that teach. Besides that, the author had very practical tips to prototype board game layouts with common objects and simple computer tools like power point. Thanks YourClassRoomHelper.com for the awesome ideas.

bird house
Duct Tape Bird House:
With the family staying in the house more, we have started enjoying bird watching more. This hack with boxes and Duct tape got the attention of one of my little ones.

cardboard dome
Card board project dome
This just looked cool!

Got other cool project ideas? Please share a link with us and our readers! We love to hear from you.

Build a Space Shooter with Phaser3 and JavaScript(Tutorial3)

In this blog post series, I want to unpack building a 2D shooter game using Phaser3.js. Phaser3 provides a robust and fast game framework for early-stage JavaScript developers. In this tutorial, we will work to add aliens to the scene, give them some basic movement, and blowing them up. Sound like a plan? Here’s what we will build.

Please make sure to check out Tutorial 1 to get started with this project. You’ll need to build upon the code and ideas from the previous blog posts. (post 1, post 2)

To see the code in a completed state, feel free to visit this link. Let’s start by making some modifications to the scene class to preload an enemy sprite graphic. The PNG file will represent how the alien should be drawn to screen. We associate the name ‘enemy1’ with our PNG file.

class Scene1 extends Phaser.Scene {

    preload() {
        this.load.image('ship', 'assets/SpaceShooterRedux/PNG/playerShip1_orange.png');
        this.load.image('laser', 'assets/SpaceShooterRedux/PNG/Lasers/laserBlue01.png');
        this.load.image('enemy1', 'assets/SpaceShooterRedux/PNG/Enemies/enemyBlack3.png');
    }

    ...

In the Phaser game framework, we associate moving game entities with sprites. To define a sprite, we build out an enemy class. When we put a sprite into our scene(as the class is constructed), a special function will be called the constructor. We’ve designed the constructor so that we can set the enemy location at a point (x,y) coordinate and connect it to the scene.

In the constructor, we accomplish the following work. We set the texture of the sprite to ‘enemy1’ and set it the position. Next, we connect this sprite to the physics engine of the scene. We’ll use the physics engine to detect when the enemy gets hit by lasers. We also initialize the deltaX factor to 3. It’s not super exciting, but the aliens will shiver from side to side randomly. This, however, is good enough for a simple lesson. After to complete this tutorial, I encourage you to go crazy with making the aliens move any way you want!

    class Enemy1 extends Phaser.GameObjects.Sprite {

    constructor(scene, x, y) {
        super(scene, x, y);
        this.setTexture('enemy1');
        this.setPosition(x, y);
        scene.physics.world.enable(this);

        this.gameObject = this;
        this.deltaX = 3;
    }

    ...

Adding movement to aliens

So, we’re ready to start moving some aliens. Let’s do this! We’re going to write three simple methods on the Enemy1 class. Following the pattern of all Photon sprites, the update method will be called every game tick. It’s your job to tell the sprite how to move. Keep in mind, we’re going to do a simple “side to side” behavior randomly. In the update method, we start by picking a number between 0 and 3. If k is 2, we make the sprite move left using the “this.moveLeft()” function. Otherwise, we make it move to the right using “this.moveRight()”

    update() {
        let k = Math.random() * 4;
        k = Math.round(k);

        if (k == 2) {
            this.moveLeft();
        }
        else if (k == 3) {
            this.moveRight();
        }
    }

    moveLeft() {
        if (this.x > 0) {
            this.x -= this.deltaX;
        }
    }

    moveRight() {
        if (this.x < SCREEN_WIDTH) {
            this.x += this.deltaX;
        }
    }

Make lots of aliens

At this point, you want to see lots of moving aliens. Let’s add the code to the scene class to construct the aliens. In the scene class, the “create” method will be used to construct all objects. This includes our ship and the aliens. Firstly, we create a special collection object called enemies. We’ll use this collection to track the enemies with the physics system. (this.enemies = this.physics.add.group()) On the next line, we create an Array so that we have a simple way to track our enemies that need updating. In the loop, we’re creating 21 aliens, placing them in random locations, and adding them to our collections. (enemies and enemies2)

class Scene1 extends Phaser.Scene {

    ...

    create() {
        this.cursors = this.input.keyboard.createCursorKeys();
        this.myShip = new Ship(this, 400, 500);
        this.add.existing(this.myShip);

        // ======= adding enemies ============
        this.enemies = this.physics.add.group();
        this.enemies2 = new Array();

        let k = 0;
        for (k = 0; k < 21; k++) {
            let x = Math.random() * 800;
            let y = Math.random() * 400;

            this.enemy = new Enemy1(this, x, y);
            this.add.existing(this.enemy);
            this.enemies.add(this.enemy);
            this.enemies2.push(this.enemy);
        }
    }

In order to invoke our update code for all enemies, we need to make one more edit to the scene class. In the “update” method, we need to add a loop to call “update” on all enemies

    update() {
        // there's more code related to the ship here 

        let j = 0;
        for (j = 0; j < this.enemies2.length; j++) {
            let enemy = this.enemies2[j];
            enemy.update();
        }
    }

At this point, we should see our aliens wiggling on the screen. And there’s much rejoicing!

Aliens go boom! Let’s do collision detection

In the laser class that we built in the last post, we need to make a few edits. Check out the code below. In the constructor of the ShipLaser, we set the texture, position, speed, and store the parent scene in “this.scene.” We connect the laser instance to the physics engine using “scene.physics.world.enable.” In the next line, we tell the game framework to check for collisions between this laser and the enemies. When a collision happens, we handle the hit using the “handleHit” function.

    class ShipLaser extends Phaser.GameObjects.Sprite {

    constructor(scene, x, y) {
        super(scene, x, y);
        this.setTexture('laser');
        this.setPosition(x, y);
        this.speed = 10;
        this.scene = scene;

        // check out new code below ...
        scene.physics.world.enable(this);
        scene.physics.add.collider(this, scene.enemies, this.handleHit, null, this);
    }

In the handle hit function, you’ll notice that the laserSprite and enemySprite have been passed as parameters to the method. In Phaser, you can receive these references so that we can define behaviors associated with both sprites. In this case, we’re just going to destroy the objects.

    handleHit(laserSprite, enemySprite) {
        enemySprite.destroy(true);
        laserSprite.destroy(true);
    }

Hope this has been helpful. Please let me know if you have any questions.

Space shooter graphic

Build a Space Shooter with Phaser3 and JavaScript(Tutorial1)

Like many computer enthusiasts, I grew up playing video games on the classic Nintendo entertainment system. Some of my favorite games included Super Mario brothers, Legend of Zelda, Tetris, and Star Force. It’s been fun to share these game classics with my kids. They still find them fun. In this blog post series, I want to unpack building a 2D shooter game using Phaser3.js. Phaser3 provides a robust and fast game framework for early stage JavaScript developers.

From exploring the options in 2D game creation using Javascript, Phaser has grown an impressive community of game makers. Here are a few game samples that you would want to explore.

Space shooter assets from www.kenney.nl

In this post series, I wanted to collect a few resources, tools, and links to help you get started building a space shooter game with Phaser 3. We’ll be drawing from the inspiration of classic games like Space Invaders.

In terms of JavaScript writing style, we’re going to keep the code samples as simple as possible to express core concepts. If you need to get started with JavaScript, I recommend checking out the free sources at CodeAcademy to start exploring the language. We’ll be drawing inspiration from classic games like Galaga and Star Force. Even though I’m trying to unpack these ideas for early stage JavaScript coders, I also want to provide examples that leverage ES6 coding structures. The Phaser3 documentation does not focus on this style of code organization. In general, I want to explore programming concepts that provide nice encapsulation and readability. We also want to make sure we can extend these coding patterns well.

The game we’re building may feel similar to this work here:
http://users.aber.ac.uk/eds/CS252_games/mwg2/JSGame/

In this tutorial, we want to encourage you to setup your work environment with Visual Studio code. You can also inspect the tutorial code in the following glitch sample.

https://glitch.com/edit/#!/awg-tutorial?path=shooter.js:1:0

Setting up Visual Studio Code

In this series, I recommend setting up Visual Studio Code on your computer. It’s a robust tool for web development and works well for JavaScript projects. You can find instructions to install VS Code using this link. I also recommend using the Visual Studio Code Live server extension to make it easier to hot re-load your code changes. Please refer to the following video for details.

Downloading some boilerplate code

To save some time, I have organized a ZIP file with a collection of code and graphics that you can leverage in building your own shooter game. You’re encouraged to play and build with these assets, sounds, and code samples to elaborate on your own game. For this first exercise, we just want to get a ship displayed to the screen and move it around using arrow keys.

  • Download the boilerplate code from here.
  • Extract the ZIP file to a location on your computer. We’ll call this your working directory. For me, I might store my files in “c:\alienWarGame-tutorial1.”

Let’s explore the contents of this boilerplate code

  • shooter.js: This JavaScript file will contain our game objects and behavior code.
  • shooter.html: This HTML file provides a home for our JavaScript game code. (see the code below) Please note that we’re downloading phaser.js (version 3.11) from a content delivery network. In the body of the HTML file, we import our shooter.js. Remember to install “Live server” extension for Visual Studio. You will be able to right click on the code HTML file and select “open with Live server.” This will load the file on a small HTTP server on your computer. All phaser games need to be hosted on a web server.



    
    Space Shooter Tutorial 1
        
    


        

Breaking Down Shooter.js

All Phaser games start with a little bit of configuration. In this “config” object below, we establish a screen size of 800 pixels by 600 pixels. This will be our drawing surface for the game. To help detect if objects bump into each other, we will be leveraging the ‘arcade’ physics engine included in Phaser3.

var SCREEN_WIDTH = 800;
var SCREEN_HEIGHT = 600;
var config = {
    type: Phaser.AUTO,
    width: SCREEN_WIDTH,
    height: SCREEN_HEIGHT,
    physics: {
        default: 'arcade'
    }
};

Ok. Let’s build our Space ship player object. In Phaser 3, they have been working to improve the framework to leverage modern JavaScript features like Es6 classes. The class will help us store the properties of the ship. Properties will include stuff like the location of the ship on the screen, object state, and texture. The class will also include several methods for moving the ship around. In the constructor method, we accept a scene object and location on the screen. (x,y). The call to “super” and “setPosition” helps associate the sprite with the parent scene and location. We call “setTexture” using the parameter of ‘ship’ to associate the ship graphic with the sprite. Finally, we set some variables(deltaX, deltaY) to configure how much the ship will move when we press keys.

class Ship extends Phaser.GameObjects.Sprite  {

    constructor(scene, x , y) {
        super(scene, x, y);
        this.setTexture('ship');
        this.setPosition(x, y);
        this.deltaX = 5;
        this.deltaY = 5;
    }

    moveLeft() {
        if (this.x > 0) {
            this.x -= this.deltaX;
        }
    }

    moveRight() {
        if (this.x < SCREEN_WIDTH) {
            this.x += this.deltaX;
        }
    }

    moveUp() {
        if (this.y > 0) {
            this.y -= this.deltaY;
        }
    }

    moveDown() {

        if (this.y < SCREEN_HEIGHT) {
            this.y += this.deltaY;
        }
    }

    preUpdate(time, delta) {
        super.preUpdate(time, delta);
    }
}

In the following method called ‘moveLeft’, we implement the math to move the sprite to the left. Since we’re moving left, we subtract 5 pixels from the current x position. We only execute this code if x is greater than zero. Most of the other movement methods operate in a similar manner.

    moveLeft() {
        if (this.x > 0) {
            this.x -= this.deltaX;
        }
    }

Let’s make a scene!

In the following class, we have to establish a Phaser scene object. It has a few simple tasks. In the “preload” method, need we load the ship sprite graphic from our assets folder.

class Scene1 extends Phaser.Scene {

    constructor(config) {
        super(config);
    }

    preload() {
        this.load.image('ship', 'assets/SpaceShooterRedux/PNG/playerShip1_orange.png');
    }

    create() {
        this.cursors = this.input.keyboard.createCursorKeys();
        this.myShip = new Ship(this, 400, 500);
        this.add.existing(this.myShip);
    }

    update() {
        if (this.cursors.left.isDown) {
            this.myShip.moveLeft();
        }

        if (this.cursors.right.isDown) {
            this.myShip.moveRight();
        }

        if (this.cursors.up.isDown) {
            this.myShip.moveUp();
        }

        if (this.cursors.down.isDown) {
            this.myShip.moveDown();
        }

        if (this.cursors.space.isDown) {
            // shooting guns goes here
        }
    }
}

The create method has does additional setup for our scene. We establish a property called cursors that will be used for detecting keyboard input like the arrow keys. We also create a ship instance at (400,500) and add it to the scene.

    create() {
        this.cursors = this.input.keyboard.createCursorKeys();
        this.myShip = new Ship(this, 400, 500);
        this.add.existing(this.myShip);
    }

We now can start moving the ship around using the update method. The if statements in update help us detect the various arrow keys. We call the appropriate method on the ship. In other words, if we press the LEFT button, we should call this.myShip.moveLeft().

    update() {
        if (this.cursors.left.isDown) {
            this.myShip.moveLeft();
        }

        if (this.cursors.right.isDown) {
            this.myShip.moveRight();
        }

        if (this.cursors.up.isDown) {
            this.myShip.moveUp();
        }

        if (this.cursors.down.isDown) {
            this.myShip.moveDown();
        }

        if (this.cursors.space.isDown) {
            // shooting guns goes here
        }
    }

Here’s the final step, we associate our game configuration information to a new game. We then add our scene.

var game = new Phaser.Game(config);
game.scene.add('scene1', Scene1, true, { x: 400, y: 300 });

If you're really excited to learn more, I have found the learning from the examples very helpful.

Phaser Labs Examples

Play Time With Angular 15 and PhaserJS

Curious about building 2D games with web skills? In this online meetup, we'll explore tools and patterns to use PhaserJs and JavaScript to make engaging 2D games. We'll cover tools to make experiences with our favorite language: TypeScript. We'll also cover some cool updates from the latest release of Angular. Come join us to learn about the latest innovations from our Angular community. Look forward to connecting with like-minded Orlando developers and designers. Hope you can join us! Make sure to bring a friend too!

6 Resources To Build Cool Minecraft Mods with Python

Looking for a fun way to explore learning to code with your students or children? Consider exploring writing Minecraft mods using Python. In our house, we continue to enjoy building(destroying) together as a family in shared Minecraft worlds. I appreciate that Minecraft helps the kids exercise their thinking about working in 3D. The python language favoring concise expression, fast feedback and quick iteration will keep students engaged.

 

As a parent, I have been searching for ways to make learning math more attractive for one of my kids. In this particular case, he loves to read and often enjoys finding ways to avoid doing tasks related to math. I’m so thankful that he has developed a joy in reading. I don’t think I had that motivation at his age. During a trip to a bookstore, he expressed interest in the book “Learn to Program Minecraft” by Craig Richardson. As an experiment, we picked up the book to explore his engagement level. In one week, he got to chapter 4 and started requesting that we practice coding Minecraft together after school. I felt something like this.

Seymour Papert, a key influence in the learning theory of constructionism, aspired to create a math world where children would play with math as a learning tool. I believe that he would be proud of the various open source projects that connect Minecraft to computational thinking.

To help you get started with coding Minecraft mods with Python, I wanted to share a few tools to help you get started.

1. Raspberry Pi: The Raspberry Pi is a great $40 computer build to engage students in playing with physical computing and computer science. If you run the raspbian operating system on your Raspberry Pi, you already have a copy of Minecraft installed and related python tools.

2. Setup for Windows and Mac: If you run Minecraft(java edition) on a Windows or Mac OS, you will find the following tutorial from instructables helpful. The tutorial walks you through the process of setting up your Minecraft server, setting up the python api, and configuring your Minecraft environment.

http://www.instructables.com/id/Python-coding-for-Minecraft/

3. Getting Started with Minecraft Pi: This resource from the Raspberry Pi foundation provides a concise set of steps to get started. Make sure to check out the link on playing with TNT. (The kids enjoy that one!)

https://projects.raspberrypi.org/en/projects/getting-started-with-minecraft-pi/

4. MagPi Magazine issue on Minecraft coding: I’m a big supporter of the MagPi Magazine. I often give this magazine as a gift to my geek friends. They recently published an issue on Minecraft coding that you’d enjoy.

https://www.raspberrypi.org/magpi-issues/Essentials_Minecraft_v1.pdf

5. Minecraft Python API cheat sheet: For experienced programmers who need a quick reference guide to the Minecraft Python API, I found the following link helpful.

http://www.stuffaboutcode.com/p/minecraft-api-reference.html?m=1

6. www.codecademy.com: This interactive tutorial provides a fun way to get started with python programming and many other languages. People learn best when you see a new idea and immediately apply it. Code academy was designed with this learning pattern in mind. You are coached to immediately apply every new programming concept in an online code editor.

Related Blog Posts

 

Import 3D Scenes Into Minecraft using MCEdit2 #makered #minecraft #minecraftedu

In our classes for young makers, we discuss how digital fabrication technology will be a game-changer.   In future work, more jobs will involve converting digital content into physical things through technologies like 3D printing, CNC, and other similar technologies.   Students love playing video games and enjoy the opportunity to learn how to make their own game worlds.   At the Museum of Aviation in Warner Robins, GA, I had the opportunity to teach a workshop on building amazing game worlds in Minecraft using TinkerCAD.com.   It’s so much fun to share these lessons with students!  After guiding the students through some of the basic operations of TinkerCAD.com, we encourage the students to play and build projects that they care about.   It was cool to see their finished work in Minecraft.   While the students think about “playing and building,” they are actually exposed to many engineering and math skills too.   The students learned how to displace objects in 3D space, rotate objects, scale objects, perform measurement, and many other mathematical ideas.

Some of the students attempted to build a Minecraft roller coaster structure.   In a secondary step, we added Minecraft train tracks and red stone power rails to power our Minecarts.  It turned out great!

Minecraft Roller coaster

One of our students decided to build a huge Minecraft creeper!  A friend of mine from Ampersand Arts in MaconMacon, helped build the huge snow man shown below.

Creeper, snowman, and friends

You can see a car, tie fighter, and rockets built by the students.

Car, Tie Fighter, Rockets

Very proud of the focus and work of our students.  I’m also thankful to my friend Jake who helped coach the class with me.

To support parents, students, and teachers, I wanted to share a few tips to enable you to build stuff like this in Minecraft.

What’s a schematic file?

A schematic file contains 3D model data to transfer content into Minecraft.    You can find schematic data files on web sites like http://www.minecraft-schematics.com/ .   You can also create 3D models and convert them to schematic files using TinkerCAD.com .

How do you import schematic files into Minecraft? 

I wanted to share a quick tutorial video on using MCEdit to import schematic content into Minecraft. Before doing the steps mentioned in this video, make sure to install Minecraft on your computer and create at least one world.

Steps:
1. Open your web browser and navigate to http://www.mcedit.net/ .
2. Click the “Download” menu option at the top.
3. You will want to download the latest version appropriate for your operating system. In this tutorial, we will download version 2 beta 6 for Windows. (64 bit version)
4. After the install program has been downloaded, execute the program and specify a location to store “mcedit.” For this demo, we will store MCEdit in “c:\games\mcedit.”  Using our file explorer, we will navigate to the MCEdit folder.
5. Open the “mcedit2-win64-2.0.0-beta6” folder.
6. Run MCEdit
7. In the panel on the left, MCEdit lists the minecraft game worlds saved by your current user account. For this demo, we’ll open the world called “demo.”
8. Select “demo”.
9. Click the button “edit.”
10. You can move around this gameworld using “WASD” navigation style.
11. You can change the direction the player is looking by holding the “right” mouse button and dragging the mouse.
12. To import a schematic file, click the “Import/Export > Import”
13. The system will open a file box enabling you to select a schematic. For this demo, we’ll select a small car created by one my students.
14. The XYZ numbers here enable you to adjust the location of the schematic content. In my case, I’ll edit the “y” coordinate to make sure to car connects to the ground.
15. Click the “confirm” button to accept the schematic content into the world.
16. Keep in mind, you’re not done yet. You need to save the session by clicking the “MCEdit” menu followed by “save world.”
17. You’re all done. Close MCEdit.
18. Open up Minecraft to test that your schematic file shows up correctly in your world!

 

We want to say thank you to the Museum of Aviation of Warner Robins, GA for enabling us to share this workshop.   Make sure to check out their fantastic STEM education workshops here.  We also want to give a shout out to the folks at TinkerCAD.com and MCEdit.NET.   Without their care and craft, we wouldn’t be able to inspire these students as makers of the future.  I really appreciate their work.

Make sure to check out our next workshop!!

Robotics: Building upon the programming skills introduced early in the program, students will have the opportunity to build robots from scratch using the mBot kit.   Students will love customizing their mBot using puzzle based programming and the easy to assemble construction experience.   Students take home their mbot to continue the tinkering fun at home.

Student registration includes a complete mBot robotics kit from Makeblock.cc.

http://www.makeblock.cc/mbot/

  • Workshop length: 3 hours
  • Cost: $20 + $75(cost of mBot kit)
  • Register for the workshop today!
  • Dates – Dec 3rd from 1pm to 4pm
  • Location – SparkMacon Makerspace – 557 Cherry St, Macon, GA (parking/directions)
  • All ages and experience levels are welcome and the workshops are a great activity for the entire family. Parents and kids can also both attend under the same registration fee!

 

Top Stories