ObjectiveThese two days on the internet to see a picture of the rise in posture, the picture shows the snake game, estimated that most people have played. But if it is just a snake game, then there is no place for people to pose. The crux of the problem is that the image of the sna
Javascript Snake game, javascript snake
Trial: http://hovertree.com/game/9/
A snake is a global game. It keeps walking upstream of the screen and eats eggs in all directions. As long as the snake's head hits around the screen or
algorithm immediately changes from O (n) to O (1). And we'll also find that we just need to record One direction and then the complexity of the space is reduced.
3) map. Describes the ground information.
Our Snake game map information is simple, with a total of 3 types of objects standing on the ground: walls, snakes, and prizes. In each update, we populate the map with information about 3 types of object
game main cycle logic is roughly as follows:
Initialize while
(true)
{
if (Player has keyboard action)
{
if (Esc key)
{
//jump Out of loop
}
else if (arrow key)
{
if (the game is in progress without end)
{
//snake moves in the direction of player
action
}
else//other key
{
//non-
processing
}
//assumes 300 milliseconds
Transfer from C language network
Today I show you the C language to write the greedy snake game, let everyone play a game of their own write ~ is pure C language Oh ~vc6.0 development No problem
First, start the interface:
The game interface is as follows:
The code is as
qt Edition snake gameReprint please indicate the source: Muni column http://blog.csdn.net/u012027907recently in the study of QT, took one months to master the most basic knowledge of QT, also completed the "QT version of the music player", "QT version of the snake Game", "QT version of Double Tetris" and "QT version of the scientific calculator," and so on, befor
Tutorial This is the first game I wrote. The function is not perfect yet. Only the most basic function. Let's take a rough look first.
Effect and source file:
greedy snake. rar
/uploadpic/2007-7/20077814321316.swf
In fact, the whole game to solve a number of problems.
1. How do I get snakes to move in the direction of the keyboard?
2. How to make food randomly d
1. First specify the Movement area width (stagew) and height of the snake (Stageh)2. Increase the keyboard to listen, get the keying code, if the key and the previous key is reversed will not change3. In the initialization, please note: The size of the snake head, snake body, food is 7 pixels4. Each moving step (move)
Ideas:1. First specify the Movement area width (stagew) and height of the snake (Stageh)2. Increase the keyboard to listen, get the keying code, if the key and the previous key is reversed will not change3. In the initialization, please note: The size of the snake head, snake body, food is 7 pixels4. Each moving step (
Just touch the Java text box drawing knowledge point, and then can follow the teacher's reminders to do some simple game, to jframe deepen, the following on the greedy snake give some source code, in fact, the implementation of the code is not much, just a little processing can be understood, the following
JS code: Game object, food, snake, game control ideas as follows (full code download in Https://github.com/774044859yf/ObjectSnakeGame)var Snake = { asnake: [],//Add an array of snakes size : 20,//
The game is still being improved...Currently, the latest version is 3.0. Compared with 2.0, four new game modes are available:1. Classic mode, that is, eating ordinary food and then long, promotion, acceleration, etc.2. Interesting mode: there are multiple functions of food, some of which can be added, some can be moved in turn, some can change the length of a snake
() operation. The so-called avoidance means turning in the direction of the snake, which may lead to a dead end. To prevent it from entering a dead end, this program temporarily uses the number of spaces enclosed by the body and wall of the snake on both sides of the side, the snake goes to the side with many spaces.
Before proceeding to the next step, please
A few days ago, I saw someone using Silverlight as a "greedy snake" in the garden. on the rise, I also wanted to use as3.0. Although this game has been ruined by many developers, however, as a beginner, it is also a learning method to repeat it.
Analysis of technical difficulties:
1. Composition of the snake bodyYou can use arrays to store a bunch of small balls
Js1k.com collected a small example of less than 1k JavaScript, there are a lot of cool games and special effects, this year the rules added a twist, the traditional classic type based on the addition of the WebGL type, and allowed to increase to 2K + + type, Many times want to try to submit a small game, but always can not write to let their satisfaction and control in such a small byte range.Can't write, stand on the shoulders of giants always have a
whole face of a snake is a gy*gx
The whole face of a snake is a gy*gx
GridOf
Chess Board, where each grid may have
the body of the snake (yellow in the picture)、
food (pictured in green)、
Nothing at all (blue in the picture)Three different states. This is how it is described in Python:
GX, Gy = the, the #棋盘大
Game programming notes-getting started
3. Snake Game implementation
Code download: http://download.csdn.net/detail/you_lan_hai/3738025
The core code implementation is as follows. For the algorithm description, see "Start (1 )":
# Include "app. H "# include
Greedy snake childhood memories, today just learn to this, just do one, but also learn it, need to grasp the knowledge:
1, JS function of the master,
2, JS array of applications,
3, JS small part of the learning of Ajax
4, JS in the splice, shift and other functions of the application,
Basically, here's the key part:The front end of the page, here can be self layout, and I provide a layout of my own here:
Here is the CSS
OneDescription: Snake game is a classic puzzle game, with a PC and mobile phone and other multi-platform version. It is simple and easy to play and is popular with people.TwoUser needs: 1. The game can be played on the browser.2. Can adjust the difficulty.3. You can view historical record.4. You can change the backgrou
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.