The focus of today’s lesson is to show you how to add the Knights attack function, defense function, and defense break function. I will explain all of these functions/moves as I code them.
First up we have the attack function. This function is pretty simple but you have to get your sprite. I chose a sword that looked like it could have been used by a medieval knight.
Unfortunately as the sword moves I could not get a picture of it and its normal size but I was able to get a picture of its code file that showed what it looks like. Now that you have your sprite it is time to give it all of its code. This code is definitely more complicated then previous codes in this game but it shouldn’t be a problem.
The first piece of code we have to add is the size and position of the sprite as well as how we duplicate it when we press a certain key on our keyboards.
I personally chose the k key on my keyboard to duplicate the sword however you can choose whichever key you like. I also set the size and position of the sprite based on my needs you can adjust these however you would like. Now that we have this step done when you press the green flag your sword should be on top of the knight and invisible and when you press k it should shoot out an invisible clone which we will obviously have to make visible. Also keep in mind the sound is optional but I decided to add a sound that I thought sounded like someone unsheathing a sword.
The next step is to add code to the clone because all we tell it right now aside from creating itself, is to start a sound, and wait 1.5 seconds. So to add a couple of commands specific to the clone we will need a special block that is called “when I start as a clone” and I will explain how it is used.
Once again this code may look complicated but it really is not too difficult. You probably see some new blocks such as the: point towards block , touching ? block, and the change variable block. But all these blocks will make sense as you get into the next couple of steps for this game. But now when our clone starts out it shows itself after which it glides to where the warlock is. If it hits him then it will change his health variable by -1 and it will wait 0.5 seconds then it will be deleted. But if the warlock uses his block function called the magic shield the blade will be neutralized instantly and it will not affect the Warlocks health.
Now that we have our attack function we can play the game. But it will be pretty basic as the Warlock will not even be able to attack. All he will be able to do is dodge. But we have one final step and this step is a sort of fail safe just in case our sword doesn’t delete itself which would be a problem later in our game.
This code is extremely simple but it is a fail safe in case our “delete this clone code” does not work . In this case this block automatically sends the delete message which then allows these code blocks to activate and they immediately delete the sword.
That’s going to be it for this step of the 2 player battle simulator thank you all for reading my blog and I hope it has helped you so far.
This is the second step in building your very own 2 player battle simulator. Now that we finished the movement code for the knight we now have to do it for the Warlock .Once again I will be using strategies and techniques from one of my previous blogs so if you haven’t already check out my blog post called basic scratch terminology.
So now the first thing we have to do is get a sprite that we want to use and we insert it into the game.
This is just personally I sprite I drew and I thought it looked nice and so I stuck with it. And unlike the knight he will have some other costumes. But now to start I will show you the first step to having the warlock move right.
Now this is one of the simpler commands as to get the Warlock back to its starting position you simply move him to the left and with the next command.
and the purpose of this command is obvious and that is to move leftand these commands are useful to position your character which could help you avoid attacks and it could help you dish out attacks.
The final movement command for the Warlock is the jump command which is slightly more difficult to program but not much more difficult.
The added change y by -50 at the end of the command simply makes it so that your Warlock falls back to the floor as opposed to floating in air and of course you can edit the height that the warlock jumps by changing the y values. I hope everyone liked this tutorial and feel free to email me and to comment down below if you have any questions. My email is in the about me section of my blog.
Now I know it’s a little off the topic of coding but just putting into consideration the things that are going on in the world with COVID-19. I figured it would be useful to give tips and advice for how to keep yourself safe and healthy during these difficult times. And I wanted to share new technologies out there that will help keep you in doing so.
EPAM GENTL Face Mask
One large problem people are beginning to face is that there are not enough face masks at stores to go to. Luckily EPAM has come up with an innovative solution, The GENTL mask. This product is the first of these many new technologies people are creating all over the world. And this mask is a great example of a brand new technology as it’s press release was only 1 week ago. These GENTL masks are quite interesting in their structure as they cover the entire nose and mouth whereas traditional masks don’t. And as such they do not let any bacteria enter your nose and mouth through gaps that traditional masks don’t cover.
The areas where there are red circles represent areas where bacteria can easily get through your face mask especially when you come into contact with other people. Because when you interact with others you can possibly get microscopic bacteria on your face from talking to them or interacting with them at all and these bacteria will make you sick and more susceptible to COVID-19 and these bacteria could even be COVID-19!
But instead of using these cheap masks that are mass produced just for companies to make money you could buy the GENTL mask that does not allow for any bacteria to get through. This is because it completely seals off your nose and mouth from bacteria. Also it is easy to communicate through these GENTL masks because they are breathable and they have a special screen that prevents bacteria from going or out. Where as regular masks can be annoying and uncomfortable and they have a very thin and flimsy plastic wall to keep bacteria out that is just completely ineffective.
These are the links to both the EPAM website for the GENTL mask and the youtube video for the GENTL mask
The next innovative product was developed by scientists and doctors at MIT who were hoping to greatly reduce the cost of otherwise overpriced ventilators. The reason Ventilators are needed is because Coronavirus is a respiratory disease that can compromise the lungs which will lead to suffocation and eventually to death. Which is why we have ventilators that help a patient breath using an automatically refilling airbag to give the patient oxygen. There are 2 main problems with modern ventilators, 1. They are way too expensive, the average ventilator costs around 30,000$ which is the same price as a small car. 2. They take a very long time to manufacture and on average it takes about 1-2 weeks to make a ventilator.
Thankfully the MIT Emergency Ventilator solves both of these problems. The average cost to make 1 ventilator is 500$ and the average manufacturing time is only 1-2 days and as such they are much easier to produce. This new technology is amazing and it was press released today via youtube and the website’s final prototype design was created 3 days ago on March 31, 2020.
This is a modern day ventilator similar to the ones used in hospitals
This ventilator to the right is the one scientists and doctors created at MIT.
As you can see the MIT Emergency Ventilator is much smaller than the traditional ventilator and it is much less complicated to use. You simply attach an air pipe to the air bag connector that is circled, and once you do that you simply put the breathing mask over the patients nose and mouth and you start the machine. The machine will automatically start using its arms to compress the airbag that pushes air in through the tube and into the patients nose and mouth. The airbag has a special hole that brings in air from all the space around it and then this process repeats itself.
Unfortunately this last “Technology” has not been fully tested yet so scientists are still experimenting with it as it used to be a antiviral medicine against ebola but it was never used so scientists are modifying it to fight against Corona Virus and it is currently in clinical trials in companies such as Gilead Sciences, Norvavuax, Moderna, Sanofi, GlaxoSmithKline, and Johnson and Johnson. These 6 companies are leading the frontier of developing a vaccine or antiviral drug to fight against corona virus and they are either developing Remdesvir or other drugs similar to it. These will hopefully be completed around June or July and with these drugs they hope to decrease the death rate of Corona Virus which will also hopefully settle the mass hysteria that everyone is having. This will result in a boost in economy, travel, and business.
Tips to lower the risk of getting COVID-19
Now I can’t Guarentee that these tips will prevent you from getting corona virsu but these are just some things to practice even if you are not in quarantine.
Social Distancing: This is arguably the most important thing that you can do because the less people you interact with the harder it is for the virus to spread and if you do have to interact with people than do it from a distance and make sure to wear proper protective gear when you leave your house.
Wear proper protective gear: If you don’t leave the house wearing good protective gear than you run the risk of getting corona virus and that is not a risk I would recommend taking. But here are my recommendations of what gear you should wear; face mask, gloves, and clothes you don’t mind immediately throwing in the washing machine because they will be super dirty.
Try to only have 1 person go to grocery stores or anywhere outside of the house: this is because you only want a limited amount of people exposed to the outside. And also the people you are sending should not be older than 60 or younger than 18. Because anyone younger than 18 or older than 60 has a higher risk of infection and death.
That was all my tips to fight against corona virus thanks to all of you who made it this far I hope you enjoyed this blog and I will make sure to write more blogs not just about coding but also about whats going on in the world.
We are finally at the point now where we can start making our first game using the skills and techniques I have explained in previous blogs. To start off we will add a knight I found off the internet. It is okay if your knight does not look the same or have a different size we can adjust that later.
Next we have to add the movements that our knight does we need to add a (when up arrow key pressed). To the (when up arrow key pressed) we need to add a (change y by 50) block, a (wait 0.5 seconds) block, and a (change y by -50) block.
Next we need a (when right arrow key pressed) block with a (change x by 15) block connected to it.
Finally we need a (when left arrow key pressed) block with a (change x by -15) block connected to it.
Next I will take a when (green flag clicked) block and a (switch to costume 1) and connect them. After this I will add a variable To make a variable you go to the tab labeled variables and click make a variable. Make sure that when you make the variable it is labeled health and that it is for this sprite only. Once you have finished your variable take a (set health to) block and connect it to the other 2 blocks. Make sure to set the health input to 10.
The next 2 blocks may differ slightly on the type and size of the knight you pick for your game. For my sprite I need to use a (set size to 80%) this may be a greater number or a smaller number depending how big your knight is. Finally you add a (go to) block and my coordinates are x:189 and y:-104 your coordinates might differ slightly once you connect all your blocks it should look like this.
This is the end for the first part of making my game 2 player battle simulator thanks for reading my blog and don’t forget to leave a comment and whether you like it or not.
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.
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.
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.
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
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.
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.
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.
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.
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?”
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.
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!!!
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.
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.
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.