Home» » Download Unity 3D Snake Game Tutorial

Download Unity 3D Snake Game Tutorial

0Home

Download Unity 3d Games FreeUnity PlayerBuild a Snake Game Interface Creation. In this tutorial series, youll learn how to create a game like Snake. The objective of the game is to grab the apples on screen to raise the score. Read on Step 1 Application Overview. Using pre made graphics we will code an entertaining game using Lua and the Corona SDK APIs. The player will be able to hit a puck by dragging the paddle on the screen, you can modify the parameters in the code to customize the game. Step 2 Target Device. The first thing we have to do is select the platform we want to run our app within, this way well be able to choose the size for the images we will use. The i. OS platform has these characteristics i. Pad 12 1. 02. 4x. Pad 3 2. 04. 8x. Phonei. Pod Touch 3. 2D Snake Clone Game Tutorial Unity3D. Unity3D C 2D Tetris Clone Game Tutorial Unity3D C 3D RealTimeStrategy. Unity 2D Mario Clone Game. In this iDevBlogADay post, Im going to kick off a new tutorial series thats aimed at making a 2D spritebased game in Unity3D using only freely available tools. Phone 4i. Pod Touch 9. Phone 5i. Pod Touch 1. Because Android is an open platform, there are many different devices and resolutions. Download Unity Games' title='Download Unity Games' />A few of the more common screen characteristics are Asus Nexus 7 Tablet 8. Motorola Droid X 8. Samsung Galaxy SIII 7. In this tutorial, well be focusing on the i. OS platform with the graphic design, specifically developing for distribution to an i. Phonei. Pod touch, but the code presented here should apply to Android development with the Corona SDK as well. Step 3 Interface. A simple and friendly interface will be used. This involves multiple shapes, buttons, bitmaps and more. The interface graphic resources necessary for this tutorial can be found in the attached download. Step 4 Export Graphics. Depending on the device you have selected, you may need to export the graphics in the recommended ppi, you can do that in your favorite image editor. I used the Adjust Size. Preview app on Mac OS X. Remember to give the images a descriptive name and save them in your project folder. Step 5 Sound. Well use Sound Effects to enhance the feeling of the game, the sounds used in this app were generated by AS3. SFXR. Step 6 App Configuration. Unity Fps Game DownloadAn external file will be used to make the application go fullscreen across devices, the config. This file shows the original screen size and the method used to scale that content in case the app is run in a different screen resolution. Step 7 Main. lua. Lets write the application Open your prefered Lua editor any Text Editor will work, but you wont have syntax highlighting and prepare to write your awesome app. Remember to save the file as main. Step 8 Code Structure. Well structure our code as if it were a Class. If you know Action. Script or Java, you should find the structure familiar. Necesary Classes. D RealTimeStrategy RTS Game Tutorial Unity3D. D RTS Game Tutorial Unity3D C Read more. Variables and Constants. Declare Functions. Main function. class methods other functions. Main function. Step 9 Hide Status Bar. Status. Bardisplay. Hidden. Status. BarThis code hides the status bar. The status bar is the bar on top of the device screen that shows the time, signal, and other indicators. Step 1. 0 Background. A simple graphic is used as the background for the application interface, the next line of code stores it. Background. local bg display. Imagebg. pngStep 1. Title View. This is the Title View, it will be the first interactive screen to appear in our game, these variables store its components. Title View. local credits. Btn. local title. View. Step 1. 2 Credits View. This view will show the credits and copyright of the game, this variable will be used to store it. Credits. View. local credits. View. Step 1. 3 Game Background. This image will be placed on top of our previous background. The following lines also store the graphics for the on screen pad. Game Background. Step 1. Apple. This is the apple graphic, referenced in the next variable. Grabbing these items will increase the snake sizeparts. Step 1. 5 Head. The first part of the snake, it will be in the stage at start. A hit area will be created on top of it and both will be grouped in the head variable. Hit. Area. local head. Step 1. 6 Snake Part. This graphic will be added each time the snake eats an apple. Step 1. 7 Score. The next line handles the textfield that will display the scores. Step 1. 8 Variables. This are the variables well use, read the comments in the code to know more about them. Const 1. 7 of pixels to move every timer count. Part last part added to snake. Part. local parts parts group. Step 1. 9 Declare Functions. Declare all functions as local at the start. Main. local start. Button. Listeners. Credits. local hide. Credits. local show. Game. View. local game. Listeners. local move. Player. local hit. Test. Objects. Step 2. Constructor. Next well create the function that will initialize all the game logic. Main. end. Step 2. Add Title View. Now we place the Title. Telecharger La Bible Pour Les Nuls Pdf more. View in the stage and call a function that will add the tap listeners to the buttons. Main. title. Bg display. Imagetitle. Bg. Center. X 1. 00. Btn display. Imageplay. Btn. Center. X 2. 7, display. Center. Y 1. 0. Btn display. Imagecredits. Btn. Center. X 4. 8, display. Center. Y 6. 5. View display. Grouptitle. Bg, play. Btn, credits. Btn. Button. Listenersadd. Next Time. In this part of the series youve learned the interface and the basic setup of the game. In the next and final part of the series, well handle the Snake movement, collision detection, and the final steps to take prior to app release like testing, creating a start screen, adding an icon and, finally, building the app. Stay tuned for the final partD Mario Clone Game Tutorial Unity. D C2. D Mario Game Tutorial Unity. D CPart 2. Play Demo. We will create one of the most famous game character in this tutorial MARIO I guess everybody knows this plumber guys story. He survives against the monsters for the meet princess. In this tutorial, I will show you how to create animations and little examples for some funtions of game. Before the begining, please download the sprite sheet here or get your own from google. We need this sprite sheet to create animations and some objects. Lets start with Mario character. Create a Sprites folder and import sprite sheet here. Select sprite and  make the Sprite Mode Multiple. If you get another sprite, Pixels Per Unit value may be different but its 3. Open sprite editor. Click slice on Top Left and slice sprite to many small items. We will use these 5 frames to create animation for Mario. Click on frames and rename them. No. 1 MarioStand, No. MarioWalk1, No. MarioWalk2, No. MarioWalk3, No. MarioJump Apply changes and back to scene. Expand sprite file and you will see your 5 renamed sprites. Select 3 walk sprites and drag to scene. Give a name of your walk animation. Press play and test Marios movement. Now open animation window and create new clip. Drag MarioStand and change Samples value with one because we have only one frame. Do it for MarioJump too. Now open animator window. You see animations names not sprites here. Click Mario. Standor whatever you gave name for your stand animation and Set as Default. You can create transitions between animations by right clicking on them. Right click on stand animation, click on Make Transition and click on walk animation. These two animations has a connection between them. Connect these four situations like in picture above. This map says At start, Mario. Stand animation will be played. You can call Mario. Walk animation while current animation is Mario. Stand. At any state, you can call Mario. Jump animation. We need two parameters to call these animations automatically. Add Speed parameter as float and add is. Touched parameter as bool. Select the arrow from stand to walk and you will see conditions in Inspector window. Select Speed and edit this parameter that if it is greater than 0. That means if speed parameter is greater than 0, then call walk animation. Select the arrow from walk to stand and edit it Speed less than 0. That means if speed parameter is greater than 0, then call stand animation. Mario can jump at any situation so, select the arrow from Any State to jump and edit is. Touched false. Lastly, Mario can walk or stand after every jump action. Select the arrow from jump to stand and set is. Touched true. is. Touched boolean will check if Mario collides with ground or not in script. Add Rigidbody. 2D and Box. Collider. 2D to your Mario objet. You can reate a ground with sprite textures. Add Ground layer to ground. Now create a C script for Mario. Speed 0. 5f. public Layer. Mask ground. Layer. Animator mario. Animator. Transform g. Check. X 1. 0f. private float scale. Y 1. 0f. void Start. Animator Get. Component. Check transform. Find. ChildGCheck. Fixed. Update. Speed Input. Get. AxisHorizontal. Animator. Set. FloatSpeed, Mathf. Absm. Speed. bool is. Touched Physics. D. Overlap. Pointg. Check. Layer. if Input. Get. KeyKey. Code. Space. Touched. rigidbody. D. Add. ForceVector. Speed, Force. Mode. D. Force. is. Touched false. Animator. Set. Boolis. Touched, is. Touched. Speed gt 0. Scale new Vector. X, scale. Y. else if m. Speed lt 0. Scale new Vector. X, scale. Y. this. D. velocity new Vector. Speed speed, this. D. velocity. y. 1. Speed0. 5f public. Layer. Mask ground. Layer private. Animator mario. Animator private. Transform g. Check privatefloatscale. X1. 0f privatefloatscale. Y1. 0f void. Startmario. AnimatorGet. Component g. Checktransform. Find. ChildGCheck   void. Fixed. Updatefloatm. SpeedInput. Get. AxisHorizontal mario. Animator. Set. FloatSpeed,Mathf. Absm. Speed boolis. TouchedPhysics. 2D. Overlap. Pointg. Check. Layer ifInput. Get. KeyKey. Code. Spaceifis. Touchedrigidbody. D. Add. ForceVector. Speed,Force. Mode. D. Force is. Touchedfalse mario. Animator. Set. Boolis. Touched,is. Touched ifm. Speed gt 0transform. Scalenew. Vector. X,scale. Y elseifm. Speed lt 0transform. Scalenew. Vector. X,scale. Y this. D. Vector. Speedpeed,this. D. velocity. y Add an empty child named GCheck to Mario. Give it an icon to see it clearly. Replace it right bottom edge of Mario object because it checks if Mario collides with ground when it overlaps with ground. It must touch ground Now test it with right left arrows and space key. It should works but if doesnt, check layers, child position and code. If it works, Mario should moves around, he can jump and the right animation should be played at the right time. You can optimise the movement by changing speed values. I gave an example for basic animation and movement. Please feel free to reply this post if it is complicated or just for asking more actions such as roaming enemies, power up mushrooms, monster plants, collecting coins etc. Also I can share all source code if you want. Coffee Break Codes 2. D Mario Game Tutorial Unity.