Scratch Oyun Yapımı __HOT__





Download Filehttps://urlgoal.com/2uSHwd



How to Make a Platform Game with Scratch

Hello, this is Bing. I understand that you want to learn how to create games with Scratch. Scratch is a free programming language and online community where you can create your own interactive stories, games, and animations. Scratch is designed for children aged 8 to 16, but anyone can use it to learn the basics of coding and express their creativity. In this article, I will show you how to use Scratch to make a simple platform game. A platform game is a type of video game where the player controls a character that can jump, run, and avoid obstacles on different levels or platforms.

In this article, you will learn how to:

  • Create a new project and choose a backdrop
  • Add a sprite and make it move
  • Make the sprite jump and fall
  • Add platforms and make them scroll
  • Add enemies and obstacles

By the end of this article, you will have created your own platform game that looks something like this:

A screenshot of a platform game made with Scratch

Step 1: Create a new project and choose a backdrop

The first step is to access the Scratch website and start a new project. To do that, follow these steps:

  1. Go to https://scratch.mit.edu/ in your web browser.
  2. Click on Create in the top menu bar.
  3. You will see a blank project with a white cat sprite on a white stage.

The next step is to choose a backdrop for your game. A backdrop is an image that fills the entire stage. You can choose a backdrop from the library or draw your own. To choose a backdrop from the library, follow these steps:

  1. Click on the Choose a Backdrop button in the bottom right corner of the stage.
  2. You will see a window with different categories of backdrops. You can browse through them by clicking on the arrows or using the search bar.
  3. When you find a backdrop that you like, click on it and then click on OK.
  4. The backdrop will appear on the stage and replace the white background.

To draw your own backdrop, follow these steps:

  1. Click on the Paint button in the bottom right corner of the stage.
  2. You will see a window with different tools for drawing. You can use the brush, eraser, fill, shapes, text, and color picker to create your own image.
  3. When you are done, click on OK.
  4. The backdrop will appear on the stage and replace the white background.

For this article, I will choose a backdrop from the library called Night Sky. It is under the Nature category. It looks like this:

A night sky backdrop

Step 2: Add a sprite and make it move

The next step is to add a sprite for your game. A sprite is an image that can move and interact on the stage. You can choose a sprite from the library or draw your own. To choose a sprite from the library, follow these steps:

  1. Click on the Choose a Sprite button in the bottom right corner of the stage.
  2. You will see a window with different categories of sprites. You can browse through them by clicking on the arrows or using the search bar.
  3. When you find a sprite that you like, click on it and then click on OK.
  4. The sprite will appear on the stage and replace the white cat.

To draw your own sprite, follow these steps:

  1. Click on the Paint button in the bottom right corner of the stage.
  2. You will see a window with different tools for drawing. You can use the same tools as for drawing a backdrop.
  3. When you are done, click on OK.
  4. The sprite will appear on the stage and replace the white cat.

To edit an existing sprite, follow these steps:

  1. Click on the sprite that you want to edit on the stage or in the sprite list below the stage.
  2. You will see a window with different tabs for editing. You can use the Costumes tab to change or add costumes for your sprite. A costume is an image that represents how your sprite looks. You can use the Sounds tab to add or record sounds for your sprite. A sound is an audio clip that plays when your sprite does something. You can use the Code tab to add or change code for your sprite. Code is a set of instructions that tells your sprite what to do.
  3. When you are done, click on X.
  4. The changes will be applied to your sprite.

For this article, I will choose a sprite from the library called Giga. It is under the Fantasy category. It looks like this:

A sprite of Giga

The next step is to make the sprite move left and right with the arrow keys. To do that, we need to use the motion blocks. These are the blue blocks that control how your sprite moves on the stage. You can find them in the Code tab under the Motion category. To make the sprite move left and right with the arrow keys, follow these steps:

  1. Drag a when [space v] key pressed block from the Events category and snap it to the code area.
  2. Click on the drop-down menu and choose right arrow.
  3. Drag a change x by (10) block from the Motion category and snap it below the previous block.
  4. This means that when the right arrow key is pressed, the sprite will move 10 steps to the right.
  5. Repeat steps 1 to 4, but choose left arrow and -10 instead.
  6. This means that when the left arrow key is pressed, the sprite will move 10 steps to the left.
  7. Your code should look like this:
A screenshot of the code for moving left and right

The next step is to make the sprite change its costume when it faces different directions. A costume is an image that represents how your sprite looks. You can find them in the Costumes tab under the Giga sprite. The Giga sprite has two costumes: one facing right and one facing left. To make the sprite change its costume when it faces different directions, follow these steps:

  1. Drag an if then block from the Control category and snap it below the change x by (10) block inside the when right arrow key pressed block.
  2. This means that if a condition is true, then some actions will happen.
  3. Drag a ( ) block from the Operators category and snap it inside the hexagonal space of the if then block.
  4. This means that if a comparison is true, then some actions will happen.
  5. Drag an x position block from the Motion category and snap it inside the first round space of the ( ) block.
  6. This means that if the x position of the sprite is less than or greater than a certain value, then some actions will happen.
  7. Type in -240 in the second round space of the ( ) block.
  8. This means that if the x position of the sprite is less than -240, then some actions will happen. -240 is the left edge of the stage. You can see the x position of the sprite by hovering over it on the stage.
  9. Drag a switch costume to [costume1 v] block from the Looks category and snap it inside the if then block.
  10. Click on the drop-down menu and choose Giga-a.
  11. This means that if the x position of the sprite is less than -240, then the sprite will switch to the costume called Giga-a, which is facing left.
  12. Repeat steps 1 to 8, but snap the if then block below the change x by (-10) block inside the when left arrow key pressed block, and type in 240 instead of -240, and choose Giga-b instead of Giga-a.
  13. This means that if the x position of the sprite is greater than 240, then the sprite will switch to the costume called Giga-b, which is facing right.
  14. Your code should look like this:
A screenshot of the code for changing costumes

Now you can test your code by clicking on the green flag and pressing the arrow keys. You should see your sprite move left and right on the stage and change its costume when it reaches the edges.

Step 3: Make the sprite jump and fall

The next step is to make the sprite jump and fall with the space key. To do that, we need to use the variables blocks. These are the orange blocks that store and change values that you can use in your code. You can find them in the Code tab under the Variables category. To make the sprite jump and fall with the space key, follow these steps:

  1. Click on the Make a Variable button in the Variables category.
  2. Type in gravity as the name of your variable and click on OK.
  3. You will see a new block called set gravity to (0) and a monitor that shows the value of your variable on the stage.
  4. You can drag and drop the monitor anywhere on the stage or hide it by unchecking the box next to your variable name.
  5. Type in -0.5 in the round space of the set gravity to (0) block.
  6. This means that you are setting gravity to a negative value, which will make your sprite fall down when it is not touching anything.
  7. Snap this block below the when green flag clicked block.
  8. This means that you are setting gravity to -0.5 when the game starts.
  9. Drag a when [space v] key pressed block from the Events category and snap it to the code area.
  10. Drag a change y by (10) block from the Motion category and snap it below the previous block.
  11. This means that when the space key is pressed, the sprite will move 10 steps up.
  12. Drag a repeat until block from the Control category and snap it below the previous block.
  13. This means that some actions will repeat until a condition is true.
  14. Drag a touching [mouse-pointer v]? block from the Sensing category and snap it inside the diamond space of the repeat until block.
  15. Click on the drop-down menu and choose [color v].
  16. This means that some actions will repeat until the sprite is touching a certain color.
  17. Click on the color box and use the color picker to select the same color as your backdrop. In my case, it is black.
  18. This means that some actions will repeat until the sprite is touching black, which is the color of the sky in my backdrop.
  19. Drag a change y by (10) block from the Motion category and snap it inside the repeat until block.
  20. This means that the sprite will move 10 steps up until it touches black.
  21. Your code should look like this:
A screenshot of the code for jumping

The next step is to make the sprite fall when it is not touching anything. To do that, we need to use the operators blocks. These are the green blocks that perform mathematical operations or comparisons. You can find them in the Code tab under the Operators category. To make the sprite fall when it is not touching anything, follow these steps:

  1. Drag a forever block from the Control category and snap it below the when green flag clicked block.
  2. This means that some actions will repeat forever when the game starts.
  3. Drag a change y by ( ) block from the Motion category and snap it inside the forever block.
  4. Drag a gravity block from the Variables category and snap it inside the round space of the change y by ( ) block.
  5. This means that the sprite will change its y position by the value of gravity forever.
  6. Your code should look like this:
A screenshot of the code for falling

Now you can test your code by clicking on the green flag and pressing the space key. You should see your sprite jump and fall on the stage.

Step 4: Add platforms and make them scroll

The next step is to add platforms for your game. Platforms are sprites that act as solid ground for your sprite to land on. You can choose platforms from the library or draw your own. To choose platforms from the library, follow these steps:

  1. Click on the Choose a Sprite button in the bottom right corner of the stage.
  2. You will see a window with different categories of sprites. You can browse through them by clicking on the arrows or using the search bar.
  3. When you find a platform that you like, click on it and then click on OK.
  4. The platform will appear on the stage.

To draw your own platform, follow these steps:

  1. Click on the Paint button in the bottom right corner of the stage.
  2. You will see a window with different tools for drawing. You can use the same tools as for drawing a backdrop or a sprite.
  3. When you are done, click on OK.
  4. The platform will appear on the stage.

To edit an existing platform, follow these steps:

  1. Click on the platform that you want to edit on the stage or in the sprite list below the stage.
  2. You will see a window with different tabs for editing. You can use the same tabs as for editing a sprite.
  3. When you are done, click on X.
  4. The changes will be applied to your platform.

To add more platforms, you can duplicate an existing platform by right-clicking on it and choosing Duplicate. You can then drag and drop the duplicated platform anywhere on the stage or change its size, position, or costume. For this article, I will choose a platform from the library called Grass. It is under the Things category. It looks like this:

A sprite of Grass

The next step is to make the platforms scroll when the sprite moves. This will create the illusion of movement and make the game more interesting. To do that, we need to use the data blocks. These are the red blocks that store and manipulate data that you can use in your code. You can find them in the Code tab under the Data category. To make the platforms scroll when the sprite moves, follow these steps:

  1. Click on the Make a List button in the Data category.
  2. Type in x-positions as the name of your list and click on OK.
  3. You will see a new block called add [thing] to [list v] and a monitor that shows the items of your list on the stage.
  4. You can drag and drop the monitor anywhere on the stage or hide it by unchecking the box next to your list name.
  5. Select all the platforms that you have added on the stage or in the sprite list below the stage by holding down the Shift key and clicking on them.
  6. You will see a window with different tabs for editing. Click on the Code tab.
  7. Drag a when green flag clicked block from the Events category and snap it to the code area.
  8. This means that some actions will happen when the game starts.
  9. Drag an add [thing] to [list v] block from the Data category and snap it below the previous block.
  10. This means that you are adding something to your list when the game starts.
  11. Drag an x position block from the Motion category and snap it inside the round space of the add [thing] to [list v] block.
  12. Click on the drop-down menu and choose x-positions.
  13. This means that you are adding the x position of each platform to the list called x-positions when the game starts.
  14. Your code should look like this:
A screenshot of the code for adding x-positions

The next step is to make the platforms move according to the x-positions list. To do that, we need to use the sensing blocks. These are the purple blocks that detect different things on the stage or in the code. You can find them in the Code tab under the Sensing category. To make the platforms move according to the x-positions list, follow these steps:

  1. Drag a forever block from the Control category and snap it below the add [thing] to [list v] block.
  2. This means that some actions will repeat forever when the game starts.
  3. Drag a go to x: ( ) y: ( ) block from the Motion category and snap it inside the forever block.
  4. This means that the platforms will go to a certain x and y position forever.
  5. Type in -240 in the first round space of the go to x: ( ) y: ( ) block.
  6. This means that the platforms will go to -240 on the x-axis, which is the left edge of the stage.
  7. Type in -180 in the second round space of the go to x: ( ) y: ( ) block.
  8. This means that the platforms will go to -180 on the y-axis, which is a little above the library or draw your own. To choose enemies and obstacles from the library, follow the same steps as for choosing platforms. To draw your own enemies and obstacles, follow the same steps as for drawing platforms. To edit an existing enemy or obstacle, follow the same steps as for editing a platform. For this article, I will choose an enemy from the library called Ghost. It is under the Fantasy category. It looks like this:

    A sprite of Ghost

    The next step is to make the enemy move or animate on the stage. To do that, we need to use the motion and looks blocks. These are the blue and purple blocks that control how your sprite moves and looks on the stage. You can find them in the Code tab under the Motion and Looks categories. To make the enemy move or animate on the stage, follow these steps:

    1. Click on the enemy that you want to edit on the stage or in the sprite list below the stage.
    2. You will see a window with different tabs for editing. Click on the Code tab.
    3. Drag a when green flag clicked block from the Events category and snap it to the code area.
    4. This means that some actions will happen when the game starts.
    5. Drag a forever block from the Control category and snap it below the previous block.
    6. This means that some actions will repeat forever when the game starts.
    7. Drag a move (10) steps block from the Motion category and snap it inside the forever block.
    8. This means that the enemy will move 10 steps in its current direction forever.
    9. Drag an if on edge, bounce block from the Motion category and snap it below the previous block.
    10. This means that the enemy will bounce off the edges of the stage when it touches them.
    11. Your code should look like this:
    A screenshot of the code for bouncing

    The next step is to make the enemy animate its costumes when it moves. The Ghost sprite has two costumes: one with its mouth open and one with its mouth closed. To make the enemy animate its costumes when it moves, follow these steps:

    1. Drag a next costume block from the Looks category and snap it below the move (10) steps block inside the forever block.
    2. This means that the enemy will switch to its next costume every time it moves 10 steps.
    3. Drag a wait ( ) seconds block from the Control category and snap it below the previous block.
    4. Type in 0.1 in the round space of the wait ( ) seconds block.
    5. This means that the enemy will wait 0.1 seconds before switching to its next costume again.
    6. Your code should look like this:
    A screenshot of the code for animating

    Now you can test your code by clicking on the green flag. You should see your enemy move and animate on the stage.

    Conclusion

    Congratulations! You have just learned how to make a platform game with Scratch. You have learned how to:

    • Create a new project and choose a backdrop
    • Add a sprite and make it move
    • Make the sprite jump and fall
    • Add platforms and make them scroll
    • Add enemies and obstacles

    You have also learned how to use different types of blocks, such as motion, looks, events, control, data, operators, and sensing blocks. You have learned how to use variables, lists, costumes, sounds, and code to create your own interactive game.

    But this is just the beginning. There are many ways you can improve or extend your game. Here are some tips and suggestions:

    • Add more levels or platforms with different shapes, sizes, colors, or backgrounds.
    • Add more enemies or obstacles with different behaviors, speeds, or animations.
    • Add more sprites or characters with different abilities, costumes, or sounds.
    • Add more features or challenges, such as coins, power-ups, traps, or timers.
    • Add more effects or feedback, such as music, sound effects, score, or messages.

    The only limit is your imagination. You can use Scratch to create any kind of game you want. You can also share your game with others and explore more Scratch projects online. Scratch is a great way to learn coding and express your creativity. Have fun!

    Frequently Asked Questions

    Here are some common questions and answers about making a platform game with Scratch:

    Q: What is Scratch?

    A: Scratch is a free programming language and online community where you can create your own interactive stories, games, and animations. Scratch is designed for children aged 8 to 16, but anyone can use it to learn the basics of coding and express their creativity.

    Q: What is a platform game?

    A: A platform game is a type of video game where the player controls a character that can jump, run, and avoid obstacles on different levels or platforms. Some examples of popular platform games are Super Mario Bros., Sonic the Hedgehog, and Donkey Kong.

    Q: How do I make my sprite jump higher or lower?

    A: You can make your sprite jump higher or lower by changing the value of the change y by (10) block inside the when space key pressed block. The higher the value, the higher your sprite will jump. The lower the value, the lower your sprite will jump. For example, if you change the value to 20, your sprite will jump twice as high as before. If you change the value to 5, your sprite will jump half as high as before.

    Q: How do I make my platforms move faster or slower?

    A: You can make your platforms move faster or slower by changing the value of the change x by (10) and change x by (-10) blocks inside the when right arrow key pressed and when left arrow key pressed blocks. The higher the absolute value, the faster your platforms will move. The lower the absolute value, the slower your platforms will move. For example, if you change the value to 20 and -20, your platforms will move twice as fast as before. If you change the value to 5 and -5, your platforms will move half as fast as before.

    Q: How do I make my enemy harder or easier to avoid?

    A: You can make your enemy harder or easier to avoid by changing the value of the move (10) steps block inside the forever block. The higher the value, the faster your enemy will move. The lower the value, the slower your enemy will move. For example, if you change the value to 20, your enemy will move twice as fast as before. If you change the value to 5, your enemy will move half as fast as before.

    Q: How do I add more sprites or characters to my game?

    A: You can add more sprites or characters to your game by following the same steps as for adding a sprite or a platform. You can choose a sprite from the library or draw your own. You can then edit its costumes, sounds, and code to make it look and behave differently. You can also duplicate an existing sprite by right-clicking on it and choosing Duplicate. You can then drag and drop the duplicated sprite anywhere on the stage or change its size, position, or costume.

    Q: How do I share my game with others or explore more Scratch projects?

    A: You can share your game with others or explore more Scratch projects by using the Share and Explore buttons in the top menu bar. To share your game with others, you need to create a free account on Scratch and save your project online. You can then click on the Share button and fill in some information about your game. You can also add tags, instructions, notes, or credits for your game. To explore more Scratch projects, you can click on the Explore button and browse through different categories of projects. You can also use the search bar or filters to find projects that interest you. You can view, play, comment, love, favorite, remix, or follow any project that you like.



    bc1a9a207d


LATEST ARTICLES: