How To Add a Object in Unity 2D

Starting out in Unity is probably one of the most difficult parts of learning. After you make the base of your game creating objects is much easier, but requires a little work. I’ll show you how to create a little box to stand on, and interact with.

Step 1

First to start just hit the Game Object Button. A drop down menu will appear then hit Create Empty.

Step 2

Once created click on the object and view it in inspector. Then hit the big button called Add Component. You can add different components using the search bar or looking in the different categories. Add Sprite Renderer, and Box Collider 2D.

Step 3

Now you can either add a single picture of the block, or you can use a sheet of lots of sprites and add it to the object that way. The easier way to go if you only need 1 or 2 sprites is the first method, but if you are going to have about more than 4 sprites you should probably use a sprite sheet. I’m going to use a sprite sheet in this tutorial. First after you put your image in Unity select it then hit the Inspector button.

In that menu you’ll find another button that says Sprite Editor. Click on it. You’ll see a bigger version of the picture. Click and drag over the sprite you want to use, and then you can rename
it if you want.

Step 4

By the way if you want you can name your object to ground or something. Anyways once select your sprite from the sprite sheet.

Then drag this to your objects Sprite Renderer. That was a lot of work to add a little sprite.

Step 5

Finally! It is done! Now you can jump all over your white little block. Have fun!

 

How to make a basic text-based game in Python

1) Import ‘time.’

It will be used to create a timer for a clear-screen.

2)
This creates a waiting timer, which counts down in milliseconds.

3)
This will clear the screen of all text.

4)Your also going to need to have something to count progress in the game, something as simple as this will do:

Your code will need this, and will add to this to represent furthering the game.

5) Create several directories that represent the possible actions a player can choose from.
For example:

6) Put the entire game within a ‘while’ loop:

This forces the code to continually loop so the game doesn’t crash if a player re-does a previously used command.

7) At the beginning of while the loop, declare the cls(); and create a simple statement:

The ‘cls’ clears the screen, and the newly-created ‘response’ will allow the player to actually make inputs to the game, so it actually becomes a playable game.

8) Create many, many elif (else if) statements. Every elif will represent an action and progress level. The simplest way to have it would be:

9) For displaying text to the user:

10) For progression in a game, under any of the elifs, then place this under the code:

The last three steps will be repeated many times, and will generally line up to make a full story, possibly with extreme amounts of flavor text.

How to Create a Randomly Generated Game Board

 

This How to will show you how to create a randomly generated 8×8 map using C# code. The code does require some sprites to be useful, but any sprite will be able to be used to make your own version!

Hope this helps!

  1. Create your variables as public GameObject[] (name);. This will allow you to assign sprites to each individual group and will place them appropriately throughout the game board.
  2. Now, using for loops to prepare to generate a new board
  3. Now run a script, preperably named apprioprately (boardSetup), and set up a new GameObject to be the board. Then use for loops to fill in the outsides and insides of the board.
  4. Next, run a command that allows us to randomly layout objects, with a minimum and maximum set, which should be set as varibles at the beginning of the script. (ex. Public int maximum = 8;)
  5. Now we will actually be creating the board by calling the functions we created above and also adding how many enemies will be on per level, with a mathematic equation.
  6. Once done with the script, go to Unity and create a empty child under the GameObject tab. Rename the object GameManager and add the script to it.
  7. Then select the desired sprites for each category (outside wall, floor, food, enemy) and using shirt + click or cntl + click, drag and drop the prefabs onto the script.
  8. After filling in all the categories, drag the GameManager object into the prefabs folder and delete the object for the hierarchy.

Animation Tutorial

Below are pictures to my process in creating sprite animations in unity with captions to help you step by step. I made my sprites in adobe illustrator and photoshop. Keep in mind that you need to save copies of the files as illustrator, photoshop, and .png files just in case you need to edit, or reuse the files. Click on the photos for a full view of the screen.

 

 

Finished Roguelike 2D Game

The (should be) finished version of the game is linked below. After playing the game, if you could take the survey to give me some feedback that would be awesome! Thanks 🙂

To play the game ask me, (Im wearing the Iowa State t shirt), and I can have you play the game on the computer next to mine. Unfortunately the file size was too large to directly link. Sorry 🙁

Survey: https://goo.gl/forms/jheK5WK9LzX9QxB12

Gracias!