Build your first basic Android game in just 7 minutes (with Unity)

Making a fully working game for Android is much easier than you might think. The key to successful Android development— or any kind of development— is to know what you want to achieve and find the necessary tools and skills to do it. Take the path of least resistance and have a clear goal in mind.

When it comes to creating games, the best tool in my opinion is Unity. Yes, you can make a game in Android Studio, but unless you’re experienced with Java and the Android SDK it will be an uphill struggle. You’ll need to understand what classes do. You’ll need to use custom views. You’ll be relying on some additional libraries. The list goes on.

Unity is a highly professional tool that powers the vast majority of the biggest selling titles on the Play Store.

Unity on the other hand does most of the work for you. This is a game engine, meaning that all the physics and many of the other features you might want to use are already taken care of. It’s cross platform and it’s designed to be very beginner-friendly for hobbyists and indie developers.

At the same time, Unity is a highly professional tool that powers the vast majority of the biggest selling titles on the Play Store. There are no limitations here and no good reason to make life harder for yourself. It’s free, too!

To demonstrate just how easy game development with Unity is, I’m going to show you how to make your first Android game in just 7 minutes.

No – I’m not going to explain how to do it in 7 minutes. I’m going to do it in 7 minutes. If you follow along too, you’ll be able to do the precise same thing!

Disclaimer: before we get started, I just want to point out that I’m slightly cheating. While the process of making the game will take 7 minutes, that presumes you’ve already installed Unity and gotten everything set up. But I won’t leave you hanging: you can find a full tutorial on how to do that over at Android Authority.

 

Adding sprites and physics

Start by double clicking on Unity to launch it. Even the longest journey starts with a single step.

Now create a new project and make sure you choose ‘2D’. Once you’re in, you’ll be greeted with a few different windows. These do stuff. We don’t have time to explain, so just follow my directions and you’ll pick it up as we go.

The first thing you’ll want to do is to create a sprite to be your character. The easiest way to do that is to draw a square. We’re going to give it a couple of eyes. If you want to be even faster still, you can just grab a sprite you like from somewhere.

Save this sprite and then just drag and drop it into your ‘scene’ by placing it in the biggest window. You’ll notice that it also pops up on the left in the ‘hierarchy’.

Now we want to create some platforms. Again, we’re going to make do with a simple square and we’ll be able to resize this freehand to make walls, platforms and what have you.

There we go, beautiful. Drop it in the same way you just did.

We already have something that looks like a ‘game’. Click play and you should see a static scene for now.

We can change that by clicking on our player sprite and looking over to the right to the window called the ‘inspector’. This is where we change properties for our GameObjects.

Choose ‘Add Component’ and then choose ‘Physics 2D > RigidBody2D’. You’ve just added physics to your player! This would be incredibly difficult for us to do on our own and really highlights the usefulness of Unity.

We also want to fix our orientation to prevent the character spinning and freewheeling around. Find ‘constraints’ in the inspector with the player selected and tick the box to freeze rotation Z. Now click play again and you should find your player now drops from the sky to his infinite doom.

Take a moment to reflect on just how easy this was: simply by applying this script called ‘RigidBody2D’ we have fully functional physics. Were we to apply the same script to a round shape, it would also roll and even bounce. Imagine coding that yourself and how involved that would be!

To stop our character falling through the floor, you’ll need to add a collider. This is basically the solid outline of a shape. To apply that, choose your player, click ‘Add Component’ and this time select ‘Physics 2D > BoxCollider2D’.

Take a moment to reflect on just how easy this was: simply by applying this script called ‘RigidBody2D’ we have fully functional physics.

Do the precise same thing with the platform, click play and then your character should drop onto the solid ground. Easy!

One more thing: to make sure that the camera follows our player whether they’re falling or moving, we want to drag the camera object that’s in the scene (this was created when you started the new project) on top of the player. Now in the hierarchy (the list of GameObjects on the left) you’re going to drag the camera so that it is indented underneath the player. The camera is now a ‘child’ of the Player GameObject, meaning that when the player moves, so too will the camera.

 

Your first script

We’re going to make a basic infinite runner and that means our character should move right across the screen until they hit an obstacle. For that, we need a script. So right click in the Assets folder down the bottom and create a new folder called ‘Scripts’. Now right click again and choose ‘Create > C# Script’. Call it ‘PlayerControls’.

For the most part the scripts we create will define specific behaviors for our GameObjects.

Now double click on your new script and it will open up in Visual Studio if you set everything up correctly.

There’s already some code here, which is ‘boiler plate code’. That means that it’s code that you will need to use in nearly every script, so its ready-populated for you to save time. Now we’ll add a new object with this line above void Start():

Then place this next line of code within the Start() method to find the rigidbody. This basically tells Unity to locate the physics attached to the GameObject that this script will be associated with (our player of course). Start() is a method that is executed as soon as a new object or script is created. Locate the physics object:

XMLSELECT ALL

XMLSELECT ALL

rb = GetComponent<Rigidbody2D>();

Add this inside Update():

JAVASELECT ALL

JAVASELECT ALL

rb.velocity = new Vector2(3, rb.velocity.y);

Update() refreshes repeatedly and so any code in here will run over and over again until the object is destroyed. This all says that we want our rigidbody to have a new vector with the same speed on the y axis (rb.velocity.y) but with the speed of ‘3’ on the horizontal axis. As you progress, you’ll probably use ‘FixedUpdate()’ in future.

Save that and go back to Unity. Click your player character and then in the inspector select Add Component > Scripts and then your new script. Click play, and boom! Your character should now move towards the edge of the ledge like a lemming.

Note: If any of this sounds confusing, just watch the video to see it all being done – it’ll help!

 

Very basic player input

If we want to add a jump feature, we can do this very simply with just one additional bit of code:

JAVASELECT ALL

JAVASELECT ALL

if (Input.GetMouseButtonDown(0))  {
         rb.velocity = new Vector2(rb.velocity.x, 5);
         }

This goes inside the Update method and it says that ‘if the player clicks’ then add velocity on the y axis (with the value 5). When we use if, anything that follows inside the brackets is used as a kind of true or false test. If the logic inside said brackets is true, then the code in the following curly brackets will run. In this case, if the player clicks the mouse, the velocity is added.

Android reads the left mouse click as tapping anywhere on the screen! So now your game has basic tap controls.

 

Finding your footing

This is basically enough to make a Flappy Birds clone. Throw in some obstacles and learn how to destroy the player when it touches them. Add a score on top of that.

If you get this down, no challenge will be too great in future

But we have a little more time so we can get more ambitious and make an infinite runner type game instead. The only thing wrong with what we have at the moment is that tapping jump will jump even when the player isn’t touching the floor, so it can essentially fly.

Remedying this gets a little more complex but this is about as hard as Unity gets. If you get this down, no challenge will be too great in future.

Add the following code to your script above the Update() method:

CPPSELECT ALL

CPPSELECT ALL

public Transform groundCheck;
public Transform startPosition;
public float groundCheckRadius;
public LayerMask whatIsGround;
private bool onGround;

Add this line to the Update method above the if statement:

SELECT ALL

SELECT ALL

onGround = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);

Finally, change the following line so that it includes && onGround:

JAVASELECT ALL

JAVASELECT ALL

if (Input.GetMouseButtonDown(0) && onGround) {

The entire thing should look like this:

CSSELECT ALL

CSSELECT ALL

public class PlayerControls : MonoBehaviour
 {
     public Rigidbody2D rb;
     public Transform groundCheck;
     public Transform startPosition;
     public float groundCheckRadius;
     public LayerMask whatIsGround;
     private bool onGround;

void Start() {
     rb = GetComponent<Rigidbody2D>();
     }

    void Update() {
         rb.velocity = new Vector2(3, rb.velocity.y);
         onGround = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);        
         if (Input.GetMouseButtonDown(0) && onGround) {
                 rb.velocity = new Vector2(rb.velocity.x, 5);
                 }

    }

}

What we’re doing here is creating a new transform – a position in space – then we’re setting its radius and asking if it is overlapping a layer called ground. We’re then changing the value of the Boolean (which can be true or false) depending on whether or not that’s the case.

So, onGround is true if the transform called groundCheck is overlapping the layer ground.

If you click save and then head back to Unity, you should now see that you have more options available in your inspector when you select the player. These public variables can be seen from within Unity itself and that means that we can set them however we like.

Right-click in the hierarchy over on the left to create a new empty object and then drag it so that it’s just underneath the player in the Scene window where you want to detect the floor. Rename the object ‘Check Ground’ and then make it a child of the player just as you did with the camera. Now it should follow the player, checking the floor underneath as it does.

Select the player again and, in the inspector, drag the new Check Ground object into the space where it says ‘groundCheck’. The ‘transform’ (position) is now going to be equal to the position of the new object. While you’re here, enter 0.1 where it says radius.

Finally, we need to define our ‘ground’ layer. To do this, select the terrain you created earlier, then up in the top right in the inspector, find where it says ‘Layer: Default’. Click this drop down box and choose ‘Add Layer’.

Now click back and this time select ‘ground’ as the layer for your platform (repeat this for any other platforms you have floating around). Finally, where it says ‘What is Ground’ on your player, select the ground layer as well.

You’re now telling your player script to check if the small point on the screen is overlapping anything matching that layer. Thanks to that line we added earlier, the character will now only jump when that is the case.

And with that, if you hit play, you can enjoy a pretty basic game requiring you to click to jump at the right time.

With that, if you hit play you can enjoy a pretty basic game requiring you to click to jump at the right time. If you set your Unity up properly with the Android SDK, then you should be able to build and run this and then play on your smartphone by tapping the screen to jump.

 

The road ahead

Obviously there’s a lot more to add to make this a full game. The player should to be able to die and respawn. We’d want to add extra levels and more.

My aim here was to show you how quickly you can get something basic up and running. Following these instructions, you should have been able to build your infinite runner in no time simply by letting Unity handle the hard stuff, like physics.

Source: https://www.androidauthority.com/can-build...

Code Cards: A game to learn How to Code

Code, in other words Coding is a term that we rarely use on ABDZ. Maybe because most of us are designers and designers shouldn't right? We beg to differ but we'll leave it for another article. How about a game that teaches you how to? Yay! It's an interesting concept and giving a perspective of a game helps achieve the goal of learning new things. Even though, they don't have any games left to buy, you can still print them yourself. From HTML 5, Ruby & Rails, CSS and Javascript, you get an overview of it all. Encouraging so I'll give it a try myself, I just need to find a couple of designers!

Behind the product, we have the mighty folks named Carlos Lagrange and Mario Gintili who created Code Cards. They are a combination of a designer and of course a developer, Code Cards was made back in 2014 and the final limited run of our original Code Cards was all sold out on March 2016. You can still download/print them yourself.

Source: http://abduzeedo.com/node/83716

15 free games that will help you learn how to code

When I started learning to code, the options were limited—lots of books (not even e-books), some very basic online tutorials, and a whole lot of experimentation.

Online learning has come a long way in the last few years. There are interactive courses, tons of online tutorials, and one of my personal favorite ways to practice coding: games.

While a game alone probably isn’t going to teach you everything you need to know about coding, it can be a really incredible way to practice the skills you’re learning. It makes practice fun. And if you’re anything like me, you might suddenly realize you’ve spent the last four hours reinforcing your coding skills without even realizing it.

I’ve tried out some of the most entertaining and useful games for learning to code. Check out my favorites below.

View As: One Page Slides

CodeMonkey

1. CodeMonkey

CodeMonkey teaches coding using CoffeeScript, a real programming language, to teach you to build your own games in HTML5. It’s aimed at kids, but it’s definitely fun for adults, too.

 

CodinGame

2. CodinGame

CodinGame offers up games to learn more than 25 programming languages, including JavaScript, Ruby, and PHP. One of the great things about CodinGame is that you can play with friends or colleagues, and also enter international coding competitions.

 

CSS Diner

3. CSS Diner

CSS Diner is a simple but fun way to learn CSS. There are 32 levels that will teach you the basics of how CSS selectors work. Each level gets progressively more complex, building on what you’ve learned in previous lessons.

 

Flexbox Froggy

4. Flexbox Froggy

Want to learn how CSS flexbox works? Check out Flexbox Froggy. It has a simple interface that teaches you the basics of how things align in flexbox while you help Froggy and his friends.

 

Flexbox Defense

5. Flexbox Defense

Flexbox Defense is another great way to practice your flexbox skills. This time, you’ll move gun towers into position along a path to defeat oncoming waves of enemies, using the same kinds of commands as Flexbox Froggy.

 

CodeCombat

6. CodeCombat

CodeCombat is aimed at teachers and students, but anyone can play. Learn Python, JavaScript, CoffeeScript, or the Lua game scripting language. On the beginner Dungeon level, you’ll move your Hero through the game using some basic commands according to the tutorial alongside the game.

 

Ruby Warrior

7. Ruby Warrior

If you want to learn Ruby, then Ruby Warrior is the game for you. There are beginner and intermediate tracks to suit your skill level. The lessons start out easy and go from there. You’ll need to login with Facebook to save your progress.

 

Untrusted

8. Untrusted

Untrusted is a meta-JavaScript adventure game that tests your JavaScript skills to solve problems. You use JavaScript to guide Dr. Eval through a machine continuum and alter his reality to move between levels. It’s a great game for practicing more complex JavaScript skills.

 

Code Hunt

9. Code Hunt

Code Hunt teaches you coding in a unique way. To play, you identify code fragments, analyze them, modify code to match the fragments, and then capture the working code fragment. You can use it to learn Java or C#.

 

Robocode

10. Robocode

If you ever watched the show BattleBots, then Robocode is for you. You’ll learn programming skills by building virtual robot battle tanks in Java or .NET. Battles are then played out onscreen in real time.

 

Checkio

11. CheckIO and Empire of Code

CheckIO and Empire of Code are both strategy games that can teach you JavaScript or Python. Empire of Code uses a space setting and you learn by defending your own base and attacking others, while CheckIO lets you improve your skills by using others’ solutions. 

 

VIM Adventures

12. VIM Adventures

Vim is a highly configurable text editor used by programmers. If you want to learn how to use Vim, then VIM Adventures is a great place to start! Use common VIM keyboard shortcuts to navigate your way through a Zelda-like adventure game.

 

Cyber Dojo

13. Cyber Dojo

Cyber Dojo has practice exercises and challenges for dozens of coding languages including Ruby, JavaScript, PHP, Python, and more. Each exercise spells out a challenge to complete with an example showing what the end result should look like. It’s a great way to practice your code skills.

 

Elevator Saga

14. Elevator Saga

Elevator Saga tests your JavaScript knowledge with challenges related to moving an elevator and transporting people in the most efficient manner possible. It starts out with a challenge to move 15 people in less than a minute, with challenges getting progressively harder from there.

 

Code Wars

15. Code Wars

Code Wars helps you improve your skills by training in challenges with others. They offer a huge variety of languages, including JavaScript, Swift, PHP, Python, Ruby, and Haskell. You’ll have to prove your skills first with a basic test of your understanding of the language you want to practice. 

Not quite ready to join in the games here? Check out Skillcrush’s free 10-Day Coding Bootcamp for a basic overview of what learning to code is all about!

Source: http://www.businessinsider.com/15-free-gam...

7 games with entertaining fail states that every dev should study

Winning is great. Losing stinks.

Still, losing doesn't have to be a negative part of the game's experience. Of course, trial and error and learning through failure makes victories more satisfying. And losing can often be just as much fun as winning, especially when developers work hard to make the fail state into a funny or interesting aspect of the game.

Some games take the sting out of defeat by making deaths memorable. Who can forget the first time they encountered the sound and animation of a Froggersquished beneath a car's tires? Other games are carefully orchestrate various aspects of play to make inevitable failures entertaining for players and spectators alike.

We've reached out to a handful of developers of games that are celebrated for their entertaining fail states to talk to them about games where losing is an integral part of the game's lasting appeal.

1) Duck Game

 

In a four-player multiplayer game, there will be three losers. As such, it's important to make sure that all four players are having fun on the journey to victory, rather than just at that all-desired winning state. In Landon Podbielski's frantic 2014 Duck Game, feathers literally fly when a player gets blasted to oblivion, and so do bodies. Watching any player death, even your own, is a hoot.

"Duck Game is all about being competitive, but is still fun if you just like setting yourself on fire or hopping around with a car on your head." says Thomas Jager of Blauwprint Games, developers of Super Flippin' Phones

Duck Game's many silly effects ensure that players are enjoying themselves in the moment-to-moment play of the game. Also, weaker players can still enjoy themselves when playing against better players due to the careful balance (or purposeful unbalancing) of the weapons. "Landon  very consciously made the game random enough to not be all about winning and to give even weak players an edge, while also being very fun if you're not even playing to win," says Jager.

TAKEAWAY: A little randomness can make losing feel less like failure.

2) Gang Beasts

 

Failure in games is often predictable, with players dying through loss of health, tumbling into a pit, etc. Gang Beasts makes failure interesting by making it unpredictable, using loose controls and some chubby, gelatinous characters to allow players to make other players fail in surprising, creative ways. 

"No other recent game I can think of has looked funnier when everyone is absolutely failing," says Corey Davis of Psyonix, developers of Rocket League."The physical animation makes everything hilarious to watch even if you're losing, and the general looseness of the controls makes every situation unpredictable."

The silly, wobbly characters are set loose in a variety of sketchy environments, like slippery bobbing ice floes. A system where players can grab and shove each other creates opportunities for sudden reversals of fortune, and chances to take your opponent down with you when you fail.

"I think the game is very good at giving players the opportunity to set their own goals--should I take out one specific player or just enjoying the hilarious slapstick physics?" says Jager. "What's important here is that there's more to the game to enjoy than just beating the others. Some Gang Beasts levels can even be played 'co-operatively' if you're just playing to see who can dodge incoming highway signs the longest without fighting, which makes for some hilarious situations."

TAKEAWAY: In giving players an absurd toy box of options/possibilities, players will be able to create their own unique, entertaining fail states within the game, encouraging creativity within the parameters of the game.

3) Dark Souls

 

"For games that are still enjoyable when you’re playing poorly, my nomination would be Dark Souls," saysBennett Foddy, creator of the masterpiece of excruciating frustration QWOP. "In fact, I found that once I started to get really good at it, a huge chunk of the enjoyment disappeared. I have a reverse-power-fantasy when it comes to those games."

In Dark Souls, failure is near constant, but it is often accompanied by learning some new aspect about the treacherous environment or overpowered enemies. Whenever the player dies, they have often seen some new mechanic or creature that they never knew about, finding yet another interesting piece of the game's world.

One of the reason's From Software's frustrating franchise has become so successful is precisely because failure is frequent and virtually inevitable. That makes the occasional hard-won win far, far sweeter.

TAKEAWAY: Failure gives victory meaning.

 

4) Flappy Bird

 

"For a game that’s fun to watch when someone’s playing poorly, it has to be something that looks way easier than it is,"" says Foddy. "I guess the best example is Flappy Bird. Watching people try to do the easiest-looking task and failing, over and over, is a special, boutique kind of humor that I love."

Flappy Bird only asks that players fly between pipes. It appears like it should be easy, until you try to master the sketchy flap mechanic. For the player, this can create a mixture of frustration and compulsion to complete the 'easy' task, but for a spectator, there is much humorous entertainment to be had from watching the player get steadily more irritated over a mundane task.

TAKEAWAY: A game that looks simple, but is frustratingly challenging, can create humor and fun for a viewing audience even as it convinces the player to try one more time, and then again, and then again... 

5) Snow Horse

 

Players might wince when their bad timing means that Tony Hawk faceplants in the cement. But they're more likely to chuckle when their screwup means that a snowboarding horses collapses into a snowdrift and loses his top hat.

In the aptly named Snow Horse, players control a snowboarding quadruped, complete with customizable headgear], then send them hurtling down the slopes. The game is very forgiving--you can easily get to the bottom of the track safely. But the temptation to get one more flip in, or trigger explosive confetti effects, encourage players to try one trick too many.

Failure results in a floppy horse collapsing and sliding to a stop. It's a jarringly abrupt transition back to a vague semblance of reality after the impossibly elaborate high flying stunts. That just tempts players to reincarnate their nag and catch more massive air.

TAKEAWAY: A simple realistic fail state can help to ground the most absurd gameplay scenarios. 

6) Worms

 

Play can still be fun when failure is almost guaranteed for the simplest of tasks, given certain circumstances.  

"The rope mechanic in the Worms franchise is the worst and best thing ever invented in gaming," saysChris Figueroa of Kinifi games, developers of equestrian snowboarding game Snow Horse. "The rope mechanic isn't the best way to get to one location or another, but if you do it successfully, IT FEELS AMAZING. You fail 99.1% of the time using the rope, but whenever you do, it's hilarious to watch."

Worms involves several heavily-armed worms out to kill each other in outlandish ways in 2D environments. Were it a more serious game, a failure-heavy mechanic like the rope would likely irritate. But in a game where exploding sheep can blow you off the map, such a high-risk maneuver seems eminently logical.

"It's like that with the entire game. There is no reason for me to throw a nuke at your player, but it sure is funny to watch someone explode." says Figueroa. Worms uses its silly concept to get away with high challenge, creating laughter where players might otherwise be annoyed.   

TAKEAWAY: Make sure that high risk high reward maneuvers lead to particularly enjoyable fail states.

7) Surgeon Simulator

Surgeon Simulator seems to have been designed from the ground up to make failure appealing. Using a ridiculous concept combined with unwieldy controls means failure is almost guaranteed. The level of stylization is perfect, presenting players with patients [victims] that don't seem quite real even though they are anatomically accurate, which makes the endless malpractice less guilt-inducing.

The game shades over from what at first looks like simple straightforward goals into a surgical sandbox experience. Why not use the bone saw? What happens when I stick myself with the hypodermic needle? Can I remove the brain? Instead of failure becoming something to be avoided, the player seeks to find the silliest ways to fail.

Source: http://www.gamasutra.com/view/news/279785/...