2 player battle simulator step 5: defense and defense break for the Warlock

This step is going to be similar to step 4 but it will be slightly different as it is for the Warlock as opposed to the Knight which means we will definetely alter the code.

The first step is obviously going to be coding the magic shield which is the Warlocks defense feature.

This is the sprite I chose for my magic shield

This will be the Warlocks magic shield and he will use this the same way as the knight. obviously its function is to completely repel the knights attacks so that the Warlock does not take any damage and so the Warlock can prepare for a counter attack.

The code for the shield is pretty simple,

Code for the Warlocks Magic Shield

This code will do many things first off it will hide the Magic shield and set it to the correct size as soon as the game is started. Next when the player presses x it will broadcast delete which is just used to ensure the shield does not create 2 of itself, then it will show itself for 1 second and then hide itself once again. And at the very end to ensure that it cannot be spammed I added a 0.5 second cool down. Finally if it touches the knights wind/ defense break it will immediately hide itself allowing the Knight to attack.

Now that we know the functions of the shield we can move on to the defense break. Just like the other defense break the code will be slightly harder than shield code as it serves a more advanced and complicated purpose.

The sprite for my defense break code

I figured it would be interesting to have winds for both defense breaks but I realized that I would have to make the Warlocks fire wind look unique and different from the Knights wind so I made it into fire wind. Next up we have to code this sprite.

Code for the Warlocks “Fire Wind” defense break function

Putting in to consideration that this shield break is almost identical to the Knights shield break I think it is best if we skip over the basic functions and talk about the more important aspects of the game and these functions.

All the main functions of the game are completed so now we have a couple things left before this game becomes fully functional as well as some optional/additional finishing touches.

The main things that we have left to include:

  1. Adding multiple backgrounds
  2. Adding death animations for both characters*
  3. Adding damage animations for both characters*
  4. Adding all necessary variables
  5. Adding some extra sound effects*
  6. Adding a power up*
    1. All things on the list with an * next to them are optional but I personally recommend adding them as they really help complete the game.

That is going to be it for this blog thank you for reading if you have any questions email me @shrey.agarwal.ca@gmail.com And Sub to my YT channel @Drago Gaming link below: youtube.com/channel/UCrlNUqQVBxLIbdltHQBdcYg

Sorry for some reason the link will not become a link so you will have to copy and paste it for it to work. Sorry about this inconvenience hopefully I will be able to fix it in the future.

Changing speed, starting position and adding costumes.

In my last post I explained how to program a sprite to move around in a game. Today I will be showing you how to change the speed of the sprite and how to change and add costumes let’s get started.

To change the speed of the sprite you simply have to decrease the amount that the x and y position of the sprite are changing. For example if my sprite is moving by 10 x each time the right arrow is pressed then to slow the sprite down we have to make the sprite only move 7 x each time the right arrow is clicked.

Now that I have made the x and y variable only change by 7 or negative 7 the movement of my sprite is much more controlled and fluid.

Next I will go over how to add a starting position for your sprite. To do this you have to drag out a block that says go to and has an x and a y input.

Note: it is okay if your block does not have the coordinates 0,0 because you can change that later.

Now from personal experience in making countless games I know that there are usually only 3 places that a sprite starts at. Location 1 is the bottom of the screen also known as the edge of the screen. Location 2 is the left hand side of the screen usually in the middle. And Location 3 is at 0,0 or the dead center of the screen.

To make the sprite go to one of these 3 main locations we use the go to block and we insert it into our code we had from my last post. Since I want my sprite in the middle of the screen I will have the coordinates in the go to block at 0,0.

Make sure not to put go to block in the forever loop because then your sprite will always be at 0,0. Also don’t forget to save your project.

Finally I will be showing you how to change and add costumes in your game to make it visually pleasing. To do this we will add another (if then) block to our code as well as a (key space pressed?) block and finally we will add a (next costume) block. This will change the costume of scratch cat into a wizard but we have to add a (wait 1 second) block to make the change smooth.

After we add all this code it will look like this. Once again thank’s to everybody who read this entire blog entry and please comment any tips or ideas that you want to see me post about and make sure to include your real name or your scratch name. And make sure to check back soon for my next post which will include the start of making one of my all time favorite games 2 player battler simulator

Or it will have scratch cat but I wanted the wizard.

Basic Movement Scripts

Now that I have touched base on the basic scratch terminology I can show you how to start coding your sprites to move, think, and talk! When you start a new project on scratch there will only be one sprite loaded in and it will be a waving cat known as Scratch Cat.

This is scratch cat and your first sprite.

Once the project has loaded you can go to one of the three tabs on the top left of your screen labeled Code, Costumes, and Sounds. Those tabs are where the magic happens in Code you insert blocks of code and connect them to a Green flag block. In the costume tab you design costumes fro your sprites as well as your backgrounds. Finally we have the Sound tab where we can add sounds to anything a sprite does to make the game more entertaining.

These are the three tabs fro coding a sprite.

Now that you know these basics we can get started on coding some movement scripts. First of all you want to start by dragging a Flag Block from the left hand side of your screen, next you should drag out a block that says forever because without this block the code will only repeat once and the game will not function.

This picture is me dragging out my flag block and my forever block.

After which we will add 4 blocks that say “if ___ then” on them with a big hole in the middle. If I were to fill the blank with another block then I could put command blocks inside the “if___ then” block to tell the sprite how to react.

Now we are telling the sprite to recognize the new blocks we added in.

Once we added the “If___ then blocks” we will put in an” key right arrow pressed?” inside the first “If____ then block.” And for the second block we put in a “key left arrow pressed?” For the third block we put in “key down arrow pressed?” Finally in the fourth “If____ then block” we will add “key up arrow pressed?”

In this step we are telling the sprite to do something when arrow keys are pressed.

For the next step we will get a “change x by 10 block” into our “If____ then block” by simply dragging it into the correct block. “The change x by 10” goes in block number one. The change x by -10 goes in block two. The change y by -10 goes in block three. Lastly The change y by 10 goes in block 4.

Finally in this picture the sprite will move around the screen fluidly.

Now if you did all the steps correctly the game should be flowing smoothly. Thanks for sticking to the end of this blog entry and stay posted for another one in 2 weeks!!!

Game 1 : 2 Player Battle Simulator

In this blog entry I will be showing you a sneak peek at one of my latest games called 2 Player Battle Simulator. In this game you and a friend can battle it out using your choice of either a Warlock or a Knight. You can move your character, throw up a shield, shoot an attack, or destroy an enemy shield. In the end there is an awesome animation where you can watch as your enemy turns to dust at your feet and you will get glorious bragging rights.

Essential Scratch Terminology

For any new coder learning the terminology for coding on scratch is crucial. In this article, I’ll be explaining what various aspects of a game on Scratch are. These will include: Sprites, costumes, stages, and command blocks.

Allow me to start by explaining what a sprite is. A sprite is any character or object in a game that moves or does any actions whatsoever. They are important because no game can be made without sprites. Sprites can be drawn or uploaded. Scratch has a costume creator which allows you to draw your own sprites. Uploaded sprites can come from any google image (they must be downloaded to the computer and then uploaded on Scratch).

Another important aspect of Scratch are costumes. The appearance of a sprite is called a costume. Costumes give sprites their shape, form, and color. Costumes have an added benefit of making the game visually appeasing. Costumes can be anything drawn or uploaded from your computer. Lastly, costumes can be replaced and there can be multiple costumes on a single sprite.

Stages, also known as backdrops, are the background for a game. They can be customized like costumes and can be any shape, form, or color. Stages can also be drawn and uploaded from your computer just like sprites. The reason why stages are important is because they are the first thing that catches the eye of the player. Oftentimes, this first impression can determine whether or not someone will play your game. Stages can also set the mood for your game and can be made to move for a more immersing experience.

The final Scratch terminology that will be covered are command blocks. Command blocks are color coded blocks that dictate how the game plays. They control everything from a sprite’s movement, emotes, and costume changes to stage changes and game events such as win or loss cases (the requirement that must be met to win or lose a game).

With the knowledge/understanding of the main terminology behind Scratch, anyone can make an amazing game.

Welcome to the Blog!

Hello and Welcome! Thanks for visiting my coding blog! Here you will find lots of interesting and enjoyable posts on how to create games on the coding website Scratch. All of my tutorials will include pictures to help build a visually pleasing display. In addition, they will include a play by play on all the steps to code various types of games.