Go to MakeCode Arcade (https://arcade.makecode.com/) and create a new project. Name this project 'Monster Battle Arena'.
Create a new Arcade project using the makecode.com website.
First, we are going to create our player's sprite. Add the following code to create your player and control it with the buttons:
This will create a new sprite for your player using the image you design or the sprite you select from the gallery.
Click on the gray box in the sprite block to open the Editor. You can choose a sprite from the Gallery or you can paint your own sprite using the Editor.
Now, let's create an AI monster for our player to fight against. Add the following code:
This will create a new sprite for the AI-controlled monster with the image you design.
In this step, we will make our monster move around the screen in a way that appears random and intelligent. This is a simple form of Artificial Intelligence (AI) behavior. Remember, this isn't true AI, but it's a great way to make the monster seem like it's thinking and moving on its own.
Let's add the following code:
This code will change the monster's velocity in random directions every 1,000 milliseconds, making it move around the screen. The code generates a random number between -100 and 100, which is then set as the monster's velocity in the x (horizontal) and y (vertical) directions. This makes the monster move in a different, random direction every half a second, giving the illusion of intelligent movement.
The way that the Health System will work in the game is that both the player and monster will start off with a health value of 10. Then they will lose health points in the combat (in the next steps).
Create the following 2 new variables:
Add the new code in at the bottom of the 'on start' to set the health values to 10 at the start of the game:
Also add the following code so that the player's and monster's health is displayed during the game.