danaxcr.blogg.se

How to edit the size in screen snake
How to edit the size in screen snake








  1. #How to edit the size in screen snake how to
  2. #How to edit the size in screen snake install
  3. #How to edit the size in screen snake update
  4. #How to edit the size in screen snake full
  5. #How to edit the size in screen snake free

Maximum_distance = math.sqrt((SCREENTILES ** 2) + (SCREENTILES ** 2)) While (x & gt -1) and (y & gt -1) and (x & lt max_x) and (y & lt max_y): # adjusting tuple coordinate to array base 0 coordinateīase_distance = math.sqrt((x_increment ** 2) + (y_increment ** 2)) In your game class, and the following method snake:ĭef loop(x_increment, y_increment, head_x, head_y): So you need to edit Snake.py on the part where it’s converting the number into direction as follow:Īssuming the snake's current direction is up,ĭirection 0 means the snake should go leftĭirection 1 means the snake should go rightĭirection 2 means the snake should go straight Play the snake with your keyboard! Have Fun! Step 5:Ĭhange the part where the snake is control by the keyboard to this part:Īnd don’t forget that the snake will only move up, left or right from its current direction. Open your terminal and run the game with the command:

#How to edit the size in screen snake install

Install the pygame and numpy library using following command line:Ĭreate a file that will control the snake. Call it Player.pyĪdd the following code to control the snake with your keyboard: I also customized minimal stuff such as the design of the snake, the code structure, comments… I edited the game to support python 3.5 because Tensorflow only supports this version. Don’t close the terminal for the rest of this tutorial.Ĭonda create -name tensorflowenv python=3 To do that, in your open terminal, run the following commands. Example:Ĭreate an anaconda create an environment.

#How to edit the size in screen snake full

Replace Full_Path with the full path of project folder. What you type should be something like this: Open your terminal and navigate into that folder.

how to edit the size in screen snake

In this tutorial, let’s call it Snake_Game. It’s called Minisnake written in Python 2.7 Step 1:Īnywhere on your computer, create a new project folder and give it a name. Now it's time to press Play and test the game:Įverything works as expected, now you have a playable Snake game in Unity 3D.We are going to solve the typical snake game I found on written by Daniel Westbrook in 2009.

  • Now for the materials, create 4 materials (Right Click -> Create -> Material) and name them respectively "ground_material", "snake_material", "head_material" and "fruit_material":įor the ground_material change its Shader to Unlit/Color and change the Main Color to black:įor the other 3 Materials change the Shader to Unlit/Texture and assign the Textures below:.
  • Main Camera variable is self-explanatory, assign the default Main Camera.
  • Attach SC_SnakeGameGenerator.cs script to _GameGenerator ObjectĪs you will notice SC_SnakeGameGenerator have some variables that need to be assigned:.
  • If (fruitBlockIndex Create Empty) and name it "_GameGenerator" Int newCoordinate = snakeCoordinates - 1 Int newCoordinate = snakeCoordinates + 1 Int newCoordinate = snakeCoordinates - areaResolution Int newCoordinate = snakeCoordinates + areaResolution

    how to edit the size in screen snake

    GameBlocks].transform.localEulerAngles = new Vector3(90, (snakeDirection = Direction.Down ? 180 : 0), 0) Int newCoordinate = snakeCoordinates + (snakeDirection = Direction.Down ? -1 : 1) If (snakeDirection = Direction.Up & (snakeCoordinates + 1) % areaResolution = 0)Įlse if (snakeDirection = Direction.Down & (snakeCoordinates + 1) % areaResolution = 1) GameBlocks].transform.localEulerAngles = new Vector3(90, (snakeDirection = Direction.Left ? -90 : 90), 0) Įlse if (snakeDirection = Direction.Up || snakeDirection = Direction.Down) If (snakeCoordinates.Contains(newCoordinate)) Int newCoordinate = snakeCoordinates + (snakeDirection = Direction.Left ? -areaResolution : areaResolution) If (timeTmp = (gameBlocks.Length - areaResolution)) GameBlocks].transform.localEulerAngles = new Vector3(90, 90, 0) SnakeCoordinates.Add(firstlock - (areaResolution * 2)) SnakeCoordinates.Add(firstlock - areaResolution) Int firstlock = Random.Range(0, areaResolution - 1) + (areaResolution * 3) MainStyle.alignment = TextAnchor.MiddleCenter MainCamera.orthographicSize = / 2 * differenceInSize MainCamera.orthographicSize = / 2 įloat differenceInSize = targetRatio / screenRatio = new Vector3(90, 0, 0) įloat screenRatio = (float)Screen.width / (float)Screen.height įloat targetRatio = / Scale the MainCamera to fit the game blocks TargetBounds.Encapsulate(gameBlocks.bounds)

    how to edit the size in screen snake

    GameBlocks = quadPrimitive.GetComponent()

    #How to edit the size in screen snake update

    Start is called before the first frame update Game area resolution, the higher number means more blocksĮnum Direction ĭirection snakeDirection = Direction.Right Public class SC_SnakeGameGenerator : MonoBehaviour

    #How to edit the size in screen snake free

    SC_SnakeGameGenerator.cs //You are free to use this script in Free or Commercial projects Unity version used in this tutorial: Unity 2018.3.0f2 (64-bit) Step 1: Create the Scriptīeing a "One Script Game" this tutorial only requires 1 script:

    #How to edit the size in screen snake how to

    In this post, I will be showing how to create a classic Snake Game in Unity 3D.










    How to edit the size in screen snake