Canvas: covet and covet

Source: Internet
Author: User

Canvas: covet and covet
 

I have always been a bit confused. I found this game last week. I was addicted to it after playing it! It should be said that it is a kind of abuse pleasure and a collection of regrets about the accidental death and a new mentality!

I was thinking about how the game would continue after I switched to another application! It is to save my data in time, and then hook me up from this game room, then other players will see that I suddenly disappeared here? So how can I ensure that my recovery does not conflict with other users!

At the same time, I found that every time I came in, the snake next to me was still in the original position, and the same would dodge my attacks, etc, I want to know how the historical data of other players can be used to determine the current switching behavior! At that time, I thought about the algorithm, escaped the time I switched in, and continued the game with other users at the current point! Well, it's complicated!

So when I wrote this article, in order to avoid these problems, I added a small judgment to other snakes to simulate players !! However! However! I only know today that this game itself is a standalone game! Watt ????

Okay, it's not important. After the preparation is complete, let's talk about the implementation problem. I made a video last Saturday evening. It's very urgent. There are a lot of problems that haven't been optimized. It's just a great deal of streaming!

Prepare the web version !! Draw the entire game using CANVAS! Then, call requestAnimationFrame to implement Frame Animation and play the game logic at the same time!

Layout Design

Layout is designed like this, and then, during initialization, the canvas is randomly shifted to PhoneWidth/2 + Random () (the height is the same, as if I had played more Chinese than I was playing a few English letters, coke)


When you operate the joystick, move the canvas in the opposite direction and the snake in the square direction to ensure that the snake is always in the middle!


I'm tired today. I don't want to write it first, Wang!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.