Snake and egg game


















Labirynth Rebirdh WebGL. Snake Sphere WebGL. Rexo HTML5. Fruit Tale WebGL. Gulper io HTML5. Cooking Show: Deviled Egg Flash. SnakeZ WebGL. Snake Incremental WebGL. Papa's Freezeria Flash. We use cookies for content recommendations, traffic measurement, and personalized ads.

By using this website, you agree to the Privacy Policy and Cookie Policy. There are three modules to create the snake game using the below python program. Those are:. In this python project, the player must move a snake so that it touches the fruit.

If the snake touches itself or the boundary of the game is over. What we learned through this article is to Python Code for Snake Game. Microsoft Solitaire. Classic Mahjong. Mahjong Dimensions. Mahjong Connect. Replace "0" with the variable score, and place the block inside the "if then" block. Drag a "show variable direction" block and change "direction" to "high score". Place this block outside the "if then" block. The code we've just written has enabled our game to keep track of a player's high score and compare it with other players' scores.

Some variables, like direction and length, do not need to be seen changing by the player. These variables are better as being behind-the-scenes, otherwise they might be distracting. To take them off the output screen, uncheck the checkboxes next to the variable names. Click and drag the variables on the output screen to reorganize where the shown variables show up on the output screen. You can put the variables wherever you want, but personally, I put the score variable on the top left of the output screen.

For the show score and high score variables, I right clicked on them and picked the option of "large readout". I also dragged them to the near middle of the screen, below the game over text. In the Costumes tab, I added text on the game over sign to clarify what the large readouts represent: score and high score. We're almost finished with the game over sign. All we have to do now is hide the score variable once it's game over.

We want the score variable to still be visible when the game is in play, but hidden when it's game over. To do this, drag a "hide variable direction" block from the Variables drawer and switch "direction" to "score". Attach this block below the "show variable high score" block. Drag a "show variable direction" block below the "hide variable high score" block. Switch "direction" to "score".

This is one of my favorite parts of the whole process, as sound effects really seem to bring the game to life for me. Go to the Sounds tab while on the snake sprite's code tab. Click the button on the bottom left of the page to search Scratch's sound library. Search up the sound "bonk" in the library, and click on the sound box that appears. Go back to the code tab. From the Sound drawer, drag a "play sound Bonk until done" block below the "broadcast game over" block.

This will produce the Bonk sound effect when the snake sprite hits the edge. Go to the apple sprite's sound tab. In Scratch's sound library, search up the sound effect "bite". Click on the option that shows up and go to the apple sprite's code tab. Drag a "play sound Bite until done" block from the Sound drawer and place it below the second "go to x: y: " block in the if then loop.

Just to be clear, this step is completely optional. The game we've built so far is a great stand-alone already, but if you want to make the game a little more interesting, continue reading. To make our game more interesting, we want to increase the snake's speed when it reaches a certain score milestone. This milestone is up to you, but I put mine at 10 points. Make sure the "create clone of myself" block is outside the "if then else" loop, at the very bottom of the forever loop.

Replace "50" with "10", or whatever other score milestone you have set. Change all the 5s and -5s with 10s and s. This bit of code will make the game speed up once the player reaches 10 points, making it a little bit more interesting for the player. Tip 4 months ago. When i receive :Game Over: set :length: to 0. Reply 4 months ago. I really have great scratch projects like paper minecraft and Cat vs. I'll show 'em sometime!

Reply 8 months ago. Tip 8 months ago. Reply 9 months ago. By queenoftrades Follow. More by the author:. About: Hi! I'm a young DIYer, and I like to dabble in a lot of subjects, from cardboard to baking. While the main focus of this account will be cardboard, I'll try to post the occasional baking and art tutorial.

Just… More About queenoftrades ». In Scratch, game characters are called "sprites". Our first sprite will be the snake.

Switch back to the code tab so that we can start programming our snake to move at our command!



0コメント

  • 1000 / 1000